Type/to search
1
Follow
0
Followers
Bagaimana cara membaca dana spot setiap 15 menit?
Help
Created 2023-10-11 02:30:09  
 3
 1099

Tolong baca uang tunai setiap 15 menit dan buatlah peta pergerakan uang tunai.

Mengimpor perpustakaan yang dibutuhkan

import time
import requests
import matplotlib.pyplot as plt

Setel parameter permintaan API

api_url = "https://api.binance.com/api/v3/account"
headers = {'X-MBX-APIKEY': 'wCDLQUiV6o1EDfDsEFAMDWWGqZ8tzmOaEgAd'}

Daftar dana inisialisasi

funds = []

def main():
while True:
try:
#Memulai Permintaan API untuk Dana
response = requests.get(api_url, headers=headers).json()
usdt_balance = float(next(item for item in response['balances'] if item['asset'] == 'USDT')['free'])

Catat uang dan waktu

funds.append(usdt_balance)
#Menggambar Curve Keuangan
plt.plot(funds)
plt.xlabel('Time')
plt.ylabel('Funds')
plt.title('USDT Funds')
plt.grid(True)
plt.savefig('funds_plot.png')
plt.close()

Tidur 15 menit

time.sleep(900)
except Exception as e:

Mencetak informasi yang salah

Log("Error:", str(e))
time.sleep(5)

Related Recommendations
Comment
All comments (3)

    用javascript语言实现,还是python?

    3 years ago

    java怎么实现呢? 每隔15分钟读取一次usdt现货资金 并绘制出资金走势图

    3 years ago
    javascript
    let lastExecutionTimestamp = 0; // 用于保存上一次执行逻辑的时间戳 function mainLogic() { // 这里放置你的具体逻辑 LogProfit(profit) // 画图,profit是具体的收益数值 // 更新上一次执行时间戳为当前时间 lastExecutionTimestamp = Date.now(); } function main() { const currentTimestamp = Date.now(); // 获取当前时间戳 // 如果距离上一次执行时间已经过去了 15 分钟 if (currentTimestamp - lastExecutionTimestamp >= 15 * 60 * 1000) { mainLogic(); // 执行具体逻辑 } }

    大概就是这个结构。

    3 years ago
  • 1
Forums
PINE Language
Get the app
iPhone Download
© 2015 - ∞ INVENTOR PTE LTD (SG)