Commit 8bb4ee55 by zihan

日志调整;去掉冗余代码;调整下单频率

parent 124c8ec9
...@@ -132,14 +132,10 @@ class biboxApi { ...@@ -132,14 +132,10 @@ class biboxApi {
} }
totalOrderbook[symbol].bids = bids; totalOrderbook[symbol].bids = bids;
totalOrderbook[symbol].asks = asks; totalOrderbook[symbol].asks = asks;
// if(symbol === 'ETH-BTC' && response.data.action === 'CANCEL'){
// // console.log(JSON.stringify(totalOrderbook['ETH-BTC']));
// console.log(JSON.stringify(response.data));
// }
const ret = {data: {SELL: asks, BUY: bids}, timestamp: timeStamp, symbol: symbol} const ret = {data: {SELL: asks, BUY: bids}, timestamp: timeStamp, symbol: symbol}
callback(null,ret); callback(null,ret);
}else{ }else{
console.log(data); // console.log(data);
} }
}); });
wss.on('error', (error) => { wss.on('error', (error) => {
......
...@@ -106,58 +106,31 @@ class BiboxCollector extends BaseCollector{ ...@@ -106,58 +106,31 @@ class BiboxCollector extends BaseCollector{
return 10 *1000; return 10 *1000;
} }
_requestSymbolFullOrderbook(index,symbols,depth,baseCollectorCallback){ // _requestSymbolFullOrderbook(index,symbols,depth,baseCollectorCallback){
if(index < symbols.length){ // if(index < symbols.length){
this._doSubscribeSymbols(symbols,baseCollectorCallback,depth); // this._doSubscribeSymbols(symbols,baseCollectorCallback,depth);
}else{
const symbol = symbols[index];
const ipAddress = IPs[index%IPs.length];
this.api.getOrderbook(symbol,depth,ipAddress,(error,result)=>{
if(error){
console.error("get depth by rest error:");
console.error(error);
this._requestSymbolFullOrderbook(index,symbols,depth,baseCollectorCallback);
return;
}
const data = result.data;
const timeStamp = data.timestamp;
baseCollectorCallback(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};
this._requestSymbolFullOrderbook(index+1,symbols,depth,baseCollectorCallback);
});
}
}
_doSubscribeSymbols(symbols,callback,subscribeDepth){
}
_subscribeSymbols(symbols,callback,subscribeDepth){
// this._fetchDepthByRest(symbols,subscribeDepth,callback);
// this.api.subscribeSymbolsAndTicker(symbols,(error,result)=>{
// if(error){
// console.log(error);
// }else{ // }else{
// //{"data":{"volume":0.03502337,"price":0.03367632,"count":1.04,"action":"ADD","time":1538538428679,"type":"BUY"},"topic":"/trade/ETH-BTC_TRADE","type":"message","seq":32748778883081} // const symbol = symbols[index];
// const ipAddress = IPs[index%IPs.length];
// //
// const timeStamp = result.data.time; // this.api.getOrderbook(symbol,depth,ipAddress,(error,result)=>{
// const symbol = result.data.topic.replace('/trade/','').replace('_TRADE',''); // if(error){
// const updateData = [[result.data.price,result.data.count]]; // console.error("get depth by rest error:");
// let asks = totalOrderbook[symbol].asks|| []; // console.error(error);
// let bids = totalOrderbook[symbol].bids|| []; // this._requestSymbolFullOrderbook(index,symbols,depth,baseCollectorCallback);
// if(result.data.type === 'BUY'){ // return;
// asks = mergeDepthAsk(asks,updateData);
// }else if(result.data.type === 'SELL'){
// bids = mergeDepthBid(bids,updateData);
// } // }
// if(symbol === 'NEO-BTC'){ // const data = result.data;
// console.log("") //todo 这里输出日志,与网页对比 // const timeStamp = data.timestamp;
// baseCollectorCallback(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};
// this._requestSymbolFullOrderbook(index+1,symbols,depth,baseCollectorCallback);
// });
// } // }
// callback(asks.slice(0,subscribeDepth), bids.slice(0,subscribeDepth), symbol, timeStamp);
// } // }
// })
this._fetchDepthByWebsocket(symbols,subscribeDepth,callback)
_subscribeSymbols(symbols,callback,subscribeDepth){
this._fetchDepthByWebsocket(symbols,subscribeDepth,callback)
} }
_fetchDepthByRest(symbols,depth,callback){ _fetchDepthByRest(symbols,depth,callback){
const restSymbols = symbols; const restSymbols = symbols;
......
...@@ -132,7 +132,7 @@ class BiboxStrategy3 extends Strategy3 { ...@@ -132,7 +132,7 @@ class BiboxStrategy3 extends Strategy3 {
} }
_getMinTradeInterval(){ _getMinTradeInterval(){
return 30*1000; return 15*1000;
} }
_needConsiderDepthCount(){ _needConsiderDepthCount(){
......
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