সক্রিয় লেনদেনের ডেটা রেকর্ড করা হয়, যা বিক্রয় এবং ক্রয়ের সক্রিয়তার প্রতিফলন করে
var tradeHistory = {buyData:{amount:0, money:0}, sellData:{amount:0, money:0}} if(_G('tradeHistory')){ tradeHistory = _G('tradeHistory') } function onexit(){ Log('exit,saving data...') _G('tradeHistory', tradeHistory) } function main(){ var client = Dial("wss://stream.binance.com:9443/ws/" + Pair.toLowerCase() + "@trade", 60) var updateTime = new Date().getTime() while(true){ var trade = JSON.parse(client.read()) if(trade.m){ tradeHistory.sellData.amount += parseFloat(trade.q) tradeHistory.sellData.money += parseFloat(trade.q) * parseFloat(trade.p) }else{ tradeHistory.buyData.amount += parseFloat(trade.q) tradeHistory.buyData.money += parseFloat(trade.q) * parseFloat(trade.p) } var buyNet = _N(tradeHistory.buyData.money - tradeHistory.sellData.money, 3) logSting = 'active buy amount:' + _N(tradeHistory.buyData.amount, 3) + ' total money: ' + _N(tradeHistory.buyData.money, 3) + '\n' logSting += 'active sell amount:' + _N(tradeHistory.sellData.amount, 3) + ' total money: ' + _N(tradeHistory.sellData.money, 3) + '\n' logSting += 'Net inflow of funds: ' + _N(tradeHistory.buyData.money - tradeHistory.sellData.money, 3) LogStatus(logSting) if(new Date().getTime() - updateTime > Interval*1000){ updateTime = new Date().getTime() LogProfit(buyNet) $.PlotLine('buyNet', buyNet) $.PlotLine('buy', _N(tradeHistory.buyData.money,3)) $.PlotLine('sell', _N(tradeHistory.sellData.money,3)) Log(logSting) } } }