Please read cash every 15 minutes.

Author: feizai008, Created: 2023-10-11 02:30:09, Updated:

Please read the cash flow every 15 minutes and draw a chart of the cash flow.

Import the library you want

import time import requests import matplotlib.pyplot as plt

Set the API request parameters

api_url = “https://api.binance.com/api/v3/account” headers = {‘X-MBX-APIKEY’: ‘wCDLQUiV6o1EDfDsEFAMDWWGqZ8tzmOaEgAd’}

List of Initial Funds

funds = []

def main (: while True: try: # Launching an API to request funding response = requests.get ((api_url, headers=headers).json)) usdt_balance = float ((next)) item for item in response [balances] if item [asset]

        # 记录资金和时间
        funds.append(usdt_balance)
        
        # 绘制资金曲线
        plt.plot(funds)
        plt.xlabel('Time')
        plt.ylabel('Funds')
        plt.title('USDT Funds')
        plt.grid(True)
        plt.savefig('funds_plot.png')
        plt.close()
        
        # 休眠15分钟
        time.sleep(900)
        
    except Exception as e:
        # 打印错误信息
        Log("Error:", str(e))
        time.sleep(5)

More

The Little DreamIs it implemented in JavaScript or Python?

The Little DreamYou know what? let lastExecutionTimestamp = 0; // is used to save the timestamp of the last logical execution function mainLogic (()) { // Put your specific logic here LogProfit ((profit) // Graph, profit is the numerical value of a specific income What do you mean? // Updates the last runtime bar to the current time lastExecutionTimestamp = Date.now (); I'm not sure. function main (() { const currentTimestamp = Date.now(); // Retrieves the current time stamp // If the last execution time has been 15 minutes if (currentTimestamp - lastExecutionTimestamp >= 15 * 60 * 1000) { mainLogic ((); // Execute specific logic I'm not sure. I'm not sure. What's up? This is probably the structure.

feizai008How does java do this? Every 15 minutes, it reads the USDT cash flow and maps the cash flow.