Commit bb6f53e4 by zihan

尝试结合rest请求

parent c470d5d7
......@@ -5,7 +5,7 @@ const biboxApi = require('./api_kucoin');
const IPReader = require('./util');
const IPs = IPReader.allIps;
let coinInfoMap = null;
const totalOrderbook = {};
// const totalOrderbook = {};
const Strategy3MaxAmountMap = {
USDT: 300,
BTC: 0.05,
......@@ -45,18 +45,14 @@ class BiboxCollector extends BaseCollector{
_subscribeSymbols(symbols,callback,subscribeDepth){
this._fetchDepthByWebsocket(symbols,subscribeDepth,callback)
setTimeout(()=>{
this._fetchDepthByRest(symbols,subscribeDepth,callback);
},20000);
}
_fetchDepthByRest(symbols,depth,callback){
const restSymbols = symbols;
for(let symbol of symbols){
const midCurrency = symbol.split("-")[0];
if(restCurrencies.includes(midCurrency)){
restSymbols.push(symbol);
}
}
const perInterval = 8;
const totalInterval = perInterval * restSymbols.length;
// const IPs = IPReader.allIps;
const perInterval = 50;
const totalInterval = perInterval * restSymbols.length +100;
setInterval(()=>{
const sortedSymbols = restSymbols.sort(()=>{
return Math.random()>0.5
......@@ -74,7 +70,7 @@ class BiboxCollector extends BaseCollector{
const data = result.data;
const timeStamp = data.timestamp;
callback(data.SELL.slice(0,depth).map((item)=>[item[0],item[1]]),data.BUY.slice(0,depth).map((item)=>[item[0],item[1]]),symbol,timeStamp);
totalOrderbook[symbol]={asks:data.SELL,bids:data.BUY};
// totalOrderbook[symbol]={asks:data.SELL,bids:data.BUY};
});
},i*perInterval);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment