Commit bb6f53e4 by zihan

尝试结合rest请求

parent c470d5d7
...@@ -5,7 +5,7 @@ const biboxApi = require('./api_kucoin'); ...@@ -5,7 +5,7 @@ const biboxApi = require('./api_kucoin');
const IPReader = require('./util'); const IPReader = require('./util');
const IPs = IPReader.allIps; const IPs = IPReader.allIps;
let coinInfoMap = null; let coinInfoMap = null;
const totalOrderbook = {}; // const totalOrderbook = {};
const Strategy3MaxAmountMap = { const Strategy3MaxAmountMap = {
USDT: 300, USDT: 300,
BTC: 0.05, BTC: 0.05,
...@@ -45,18 +45,14 @@ class BiboxCollector extends BaseCollector{ ...@@ -45,18 +45,14 @@ class BiboxCollector extends BaseCollector{
_subscribeSymbols(symbols,callback,subscribeDepth){ _subscribeSymbols(symbols,callback,subscribeDepth){
this._fetchDepthByWebsocket(symbols,subscribeDepth,callback) this._fetchDepthByWebsocket(symbols,subscribeDepth,callback)
setTimeout(()=>{
this._fetchDepthByRest(symbols,subscribeDepth,callback);
},20000);
} }
_fetchDepthByRest(symbols,depth,callback){ _fetchDepthByRest(symbols,depth,callback){
const restSymbols = symbols; const restSymbols = symbols;
for(let symbol of symbols){ const perInterval = 50;
const midCurrency = symbol.split("-")[0]; const totalInterval = perInterval * restSymbols.length +100;
if(restCurrencies.includes(midCurrency)){
restSymbols.push(symbol);
}
}
const perInterval = 8;
const totalInterval = perInterval * restSymbols.length;
// const IPs = IPReader.allIps;
setInterval(()=>{ setInterval(()=>{
const sortedSymbols = restSymbols.sort(()=>{ const sortedSymbols = restSymbols.sort(()=>{
return Math.random()>0.5 return Math.random()>0.5
...@@ -74,7 +70,7 @@ class BiboxCollector extends BaseCollector{ ...@@ -74,7 +70,7 @@ class BiboxCollector extends BaseCollector{
const data = result.data; const data = result.data;
const timeStamp = data.timestamp; 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); 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); },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