The resource loading... loading...

Please teach me JS code problems.

Author: Beans, Created: 2024-12-01 11:59:19, Updated:

I wrote a code to monitor whether a pending order is being processed and to get order data from the trading platform using exchange.GetOrders (); Then the interval is 1000 milliseconds. But the platform suggests: Mistakes GetTicker: {code:-1003,msg:Too many requests; current limit of IP(8.216.89.72) is 2400 requests per minute. Please use the websocket for live updates to avoid polling the API.”}

How can we solve this problem? If you don't use the code below, what else can you do?

function main() {
    setContract();  // 设置合约
    initDatas();    // 初始化数据
    initialize();   //检查是否存在多单和空单

    while (true) {
        ////监测交易平台的订单是否成交
        var orders = exchange.GetOrders();
        if (orders) {
            for (var i = 0; i < orders.length; i++) {
                if (orders[i].Status === ORDER_STATE_CLOSED) {
                    Log('挂单已成交: id=', orders[i].Id, '成交价:', orders[i].Price, '成交量:', orders[i].Amount);
                    calculateProfit(ticker);                        //统计收益****
                }
            }
        }
        else { Log("获取订单失败,返回值为null"); }

        ////监测从TradingView发出的WebHook消息
        var command = GetCommand();                     //获取WebHook消息
        if (command) {// 如果有消息,则执行命令
            Log("接收到的命令:", command, "#FF1CAE");
            TV_FMZ_Strategy(command); //开单平单操作
        }

        Take_Profit_Stop_Loss();   //止盈止损操作
        Sleep(_Interval);          // 程序运行间隔
    }
}

More

BeansGood, thank you.

Inventors quantify - small dreamsYou can check where the GetTicker function is called.

Inventors quantify - small dreamsHello, an error message indicates that the GetTicker function is being called too frequently.