1
Follow
0
Followers
Bitte lesen Sie alle 15 Minuten den Bargeldbetrag und zeichnen Sie eine Karte mit dem Verlauf des Geldes.
Importieren der benötigten Bibliothek
import time
import requests
import matplotlib.pyplot as plt
Einstellungen für API-Anfragen
api_url = "https://api.binance.com/api/v3/account"
headers = {'X-MBX-APIKEY': 'wCDLQUiV6o1EDfDsEFAMDWWGqZ8tzmOaEgAd'}
Liste der Initialisierungsmittel
funds = []
def main():
while True:
try:
API-Anfragen für die Finanzierung
response = requests.get(api_url, headers=headers).json()
usdt_balance = float(next(item for item in response['balances'] if item['asset'] == 'USDT')['free'])
Aufzeichnen von Geld und Zeit
funds.append(usdt_balance)
Die Kapitalkurve zeichnen
plt.plot(funds)
plt.xlabel('Time')
plt.ylabel('Funds')
plt.title('USDT Funds')
plt.grid(True)
plt.savefig('funds_plot.png')
plt.close()
15 Minuten Schlaf
time.sleep(900)
except Exception as e:
Falsch gedruckt
Log("Error:", str(e))
time.sleep(5)
Related Recommendations
Inventor Quant Workflow FAQ (Continuously Updated)Financial Magic Zone Global KOL RecruitmentFAQ Summary (Updating...)PINE Language Introductory Tutorial of FMZ QuantPrimary Tutorial of Strategy Writing with FMZ Quant Trading Platform (Must Read)Getting Started with FMZ Quant Trading Platform (Must Read)MyLanguage Doc
Comment
All comments (3)
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
