记录主动成交数据,反映了买卖盘的活跃程度
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) } } }template: strategy.tpl:40:21: executing "strategy.tpl" at <.api.GetStrategyListByName>: wrong number of args for GetStrategyListByName: want 7 got 6