Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
K
kucoin
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
rongjun
kucoin
Commits
8bb4ee55
Commit
8bb4ee55
authored
Oct 04, 2018
by
zihan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
日志调整;去掉冗余代码;调整下单频率
parent
124c8ec9
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
24 additions
and
55 deletions
+24
-55
api_kucoin.js
api_kucoin.js
+1
-5
kucoinCollector.js
kucoinCollector.js
+22
-49
kucoinStrategy3.js
kucoinStrategy3.js
+1
-1
No files found.
api_kucoin.js
View file @
8bb4ee55
...
...
@@ -132,14 +132,10 @@ class biboxApi {
}
totalOrderbook
[
symbol
].
bids
=
bids
;
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
}
callback
(
null
,
ret
);
}
else
{
console
.
log
(
data
);
//
console.log(data);
}
});
wss
.
on
(
'error'
,
(
error
)
=>
{
...
...
kucoinCollector.js
View file @
8bb4ee55
...
...
@@ -106,58 +106,31 @@ class BiboxCollector extends BaseCollector{
return
10
*
1000
;
}
_requestSymbolFullOrderbook
(
index
,
symbols
,
depth
,
baseCollectorCallback
){
if
(
index
<
symbols
.
length
){
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
){
}
// _requestSymbolFullOrderbook(index,symbols,depth,baseCollectorCallback){
// if(index < symbols.length){
// 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);
// });
// }
// }
_subscribeSymbols
(
symbols
,
callback
,
subscribeDepth
){
// this._fetchDepthByRest(symbols,subscribeDepth,callback);
// this.api.subscribeSymbolsAndTicker(symbols,(error,result)=>{
// if(error){
// console.log(error);
// }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 timeStamp = result.data.time;
// const symbol = result.data.topic.replace('/trade/','').replace('_TRADE','');
// const updateData = [[result.data.price,result.data.count]];
// let asks = totalOrderbook[symbol].asks|| [];
// let bids = totalOrderbook[symbol].bids|| [];
// if(result.data.type === 'BUY'){
// asks = mergeDepthAsk(asks,updateData);
// }else if(result.data.type === 'SELL'){
// bids = mergeDepthBid(bids,updateData);
// }
// if(symbol === 'NEO-BTC'){
// console.log("") //todo 这里输出日志,与网页对比
// }
// callback(asks.slice(0,subscribeDepth), bids.slice(0,subscribeDepth), symbol, timeStamp);
// }
// })
this
.
_fetchDepthByWebsocket
(
symbols
,
subscribeDepth
,
callback
)
}
_fetchDepthByRest
(
symbols
,
depth
,
callback
){
const
restSymbols
=
symbols
;
...
...
kucoinStrategy3.js
View file @
8bb4ee55
...
...
@@ -132,7 +132,7 @@ class BiboxStrategy3 extends Strategy3 {
}
_getMinTradeInterval
(){
return
30
*
1000
;
return
15
*
1000
;
}
_needConsiderDepthCount
(){
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment