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
72fca0f9
Commit
72fca0f9
authored
Oct 04, 2018
by
rongjun
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
bug
parent
aabb5e0a
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
41 additions
and
24 deletions
+41
-24
api_kucoin.js
api_kucoin.js
+1
-1
kucoinCollector.js
kucoinCollector.js
+40
-23
No files found.
api_kucoin.js
View file @
72fca0f9
...
@@ -86,7 +86,7 @@ class biboxApi {
...
@@ -86,7 +86,7 @@ class biboxApi {
for
(
const
symbol
of
symbols
){
for
(
const
symbol
of
symbols
){
this
.
_subscribeSymbol
(
wss
,
id
,
symbol
,
depth
)
this
.
_subscribeSymbol
(
wss
,
id
,
symbol
,
depth
)
}
}
}
else
if
(
response
.
t
ype
===
'subscribe'
){
}
else
if
(
response
.
t
opic
.
startsWith
(
'/trade'
)
){
const
timeStamp
=
response
.
data
.
time
;
const
timeStamp
=
response
.
data
.
time
;
const
symbol
=
response
.
data
.
topic
.
replace
(
'/trade/'
,
''
).
replace
(
'_TRADE'
,
''
);
const
symbol
=
response
.
data
.
topic
.
replace
(
'/trade/'
,
''
).
replace
(
'_TRADE'
,
''
);
let
asks
=
totalOrderbook
[
symbol
].
asks
||
[];
let
asks
=
totalOrderbook
[
symbol
].
asks
||
[];
...
...
kucoinCollector.js
View file @
72fca0f9
...
@@ -134,29 +134,29 @@ class BiboxCollector extends BaseCollector{
...
@@ -134,29 +134,29 @@ class BiboxCollector extends BaseCollector{
_subscribeSymbols
(
symbols
,
callback
,
subscribeDepth
){
_subscribeSymbols
(
symbols
,
callback
,
subscribeDepth
){
// this._fetchDepthByRest(symbols,subscribeDepth,callback);
// this._fetchDepthByRest(symbols,subscribeDepth,callback);
this
.
api
.
subscribeSymbolsAndTicker
(
symbols
,(
error
,
result
)
=>
{
//
this.api.subscribeSymbolsAndTicker(symbols,(error,result)=>{
if
(
error
){
//
if(error){
console
.
log
(
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}
//
//{"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 timeStamp = result.data.time;
const
symbol
=
result
.
data
.
topic
.
replace
(
'/trade/'
,
''
).
replace
(
'_TRADE'
,
''
);
//
const symbol = result.data.topic.replace('/trade/','').replace('_TRADE','');
const
updateData
=
[[
result
.
data
.
price
,
result
.
data
.
count
]];
//
const updateData = [[result.data.price,result.data.count]];
let
asks
=
totalOrderbook
[
symbol
].
asks
||
[];
//
let asks = totalOrderbook[symbol].asks|| [];
let
bids
=
totalOrderbook
[
symbol
].
bids
||
[];
//
let bids = totalOrderbook[symbol].bids|| [];
if
(
result
.
data
.
type
===
'BUY'
){
//
if(result.data.type === 'BUY'){
asks
=
mergeDepthAsk
(
asks
,
updateData
);
//
asks = mergeDepthAsk(asks,updateData);
}
else
if
(
result
.
data
.
type
===
'SELL'
){
//
}else if(result.data.type === 'SELL'){
bids
=
mergeDepthBid
(
bids
,
updateData
);
//
bids = mergeDepthBid(bids,updateData);
}
//
}
if
(
symbol
===
'NEO-BTC'
){
//
if(symbol === 'NEO-BTC'){
console
.
log
(
""
)
//todo 这里输出日志,与网页对比
//
console.log("") //todo 这里输出日志,与网页对比
}
//
}
callback
(
asks
.
slice
(
0
,
subscribeDepth
),
bids
.
slice
(
0
,
subscribeDepth
),
symbol
,
timeStamp
);
//
callback(asks.slice(0,subscribeDepth), bids.slice(0,subscribeDepth), symbol, timeStamp);
}
//
}
})
//
})
this
.
_fetchDepthByWebsocket
(
symbols
,
subscribeDepth
,
callback
)
}
}
_fetchDepthByRest
(
symbols
,
depth
,
callback
){
_fetchDepthByRest
(
symbols
,
depth
,
callback
){
...
@@ -194,6 +194,23 @@ class BiboxCollector extends BaseCollector{
...
@@ -194,6 +194,23 @@ class BiboxCollector extends BaseCollector{
},
totalInterval
);
},
totalInterval
);
}
}
_fetchDepthByWebsocket
(
symbols
,
depth
,
callback
){
this
.
api
.
subscribeSymbols
(
symbols
,
depth
,
(
error
,
result
)
=>
{
if
(
error
){
console
.
error
(
"subscribe error"
);
console
.
error
(
error
);
}
else
{
console
.
log
(
"subscribe success"
);
return
;
const
data
=
result
.
data
;
const
timeStamp
=
result
.
timestamp
;
const
symbol
=
result
.
symbol
;
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
);
}
})
}
_runMonitor
(
callback
){
_runMonitor
(
callback
){
let
balanceMap
=
{};
let
balanceMap
=
{};
let
need
=
1
;
let
need
=
1
;
...
...
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