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
b0716d4e
Commit
b0716d4e
authored
Oct 04, 2018
by
zihan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
深度数据合并bug修复
parent
17a258b8
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
28 additions
and
45 deletions
+28
-45
api_kucoin.js
api_kucoin.js
+28
-45
No files found.
api_kucoin.js
View file @
b0716d4e
...
@@ -10,6 +10,32 @@ const constants = require('./constants');
...
@@ -10,6 +10,32 @@ const constants = require('./constants');
const
{
IPs
,
mergeDepth
}
=
require
(
'./util'
);
const
{
IPs
,
mergeDepth
}
=
require
(
'./util'
);
let
totalOrderbook
=
{};
let
totalOrderbook
=
{};
let
getUpdatedData
=
function
(
currentData
,
response
)
{
const
updateData
=
[];
let
newCount
=
0
;
let
has
=
false
;
for
(
const
a
of
currentData
)
{
if
(
response
.
data
.
price
===
a
[
0
])
{
has
=
true
;
newCount
=
a
[
1
];
if
(
response
.
data
.
action
===
'ADD'
)
{
newCount
+=
response
.
data
.
count
;
}
else
if
(
response
.
data
.
action
===
'CANCEL'
)
{
newCount
-=
response
.
data
.
count
;
}
break
;
}
}
if
(
!
has
&&
response
.
data
.
action
!==
'CANCEL'
)
{
updateData
.
push
([
response
.
data
.
price
,
response
.
data
.
count
])
}
else
{
// updateData = [[response.data.price, newCount]];
updateData
.
push
([
response
.
data
.
price
,
newCount
]);
}
return
updateData
;
};
class
biboxApi
{
class
biboxApi
{
constructor
()
{
constructor
()
{
this
.
apiKey
=
'5ba054d2e0abb830dee81e1d'
;
this
.
apiKey
=
'5ba054d2e0abb830dee81e1d'
;
...
@@ -93,58 +119,15 @@ class biboxApi {
...
@@ -93,58 +119,15 @@ class biboxApi {
const
symbol
=
response
.
topic
.
replace
(
'/trade/'
,
''
).
replace
(
'_TRADE'
,
''
);
const
symbol
=
response
.
topic
.
replace
(
'/trade/'
,
''
).
replace
(
'_TRADE'
,
''
);
let
asks
=
totalOrderbook
[
symbol
].
asks
||
[];
let
asks
=
totalOrderbook
[
symbol
].
asks
||
[];
let
bids
=
totalOrderbook
[
symbol
].
bids
||
[];
let
bids
=
totalOrderbook
[
symbol
].
bids
||
[];
let
updateData
=
[];
let
newCount
=
0
if
(
response
.
data
.
type
===
'SELL'
){
if
(
response
.
data
.
type
===
'SELL'
){
const
oldD
=
totalOrderbook
[
symbol
];
const
oldD
=
totalOrderbook
[
symbol
];
let
has
=
false
;
const
updateData
=
getUpdatedData
(
oldD
.
asks
,
response
);
for
(
const
a
of
oldD
.
asks
){
if
(
response
.
data
.
price
===
a
[
0
])
{
has
=
true
;
newCount
=
a
[
1
];
if
(
response
.
data
.
action
===
'ADD'
)
{
newCount
+=
response
.
data
.
count
;
}
else
if
(
response
.
data
.
action
===
'CANCEL'
)
{
newCount
-=
response
.
data
.
count
;
}
else
{
}
break
;
}
}
if
(
!
has
){
updateData
=
[[
response
.
data
.
price
,
response
.
data
.
count
]];
}
else
{
updateData
=
[[
response
.
data
.
price
,
newCount
]];
}
asks
=
mergeDepth
(
asks
,
updateData
,
true
);
asks
=
mergeDepth
(
asks
,
updateData
,
true
);
}
else
if
(
response
.
data
.
type
===
'BUY'
){
}
else
if
(
response
.
data
.
type
===
'BUY'
){
const
oldD
=
totalOrderbook
[
symbol
];
const
oldD
=
totalOrderbook
[
symbol
];
let
has
=
false
;
const
updateData
=
getUpdatedData
(
oldD
.
bids
,
response
);
for
(
const
a
of
oldD
.
bids
){
if
(
response
.
data
.
price
===
a
[
0
])
{
has
=
true
;
newCount
=
a
[
1
];
if
(
response
.
data
.
action
===
'ADD'
)
{
newCount
+=
response
.
data
.
count
;
}
else
if
(
response
.
data
.
action
===
'CANCEL'
)
{
newCount
-=
response
.
data
.
count
;
}
else
{
}
break
;
}
}
if
(
!
has
){
updateData
=
[[
response
.
data
.
price
,
response
.
data
.
count
]];
}
else
{
updateData
=
[[
response
.
data
.
price
,
newCount
]];
}
bids
=
mergeDepth
(
bids
,
updateData
,
false
);
bids
=
mergeDepth
(
bids
,
updateData
,
false
);
}
}
if
(
symbol
===
'NEO-BTC'
){
console
.
log
()
//todo 这里输出日志,与网页对比
}
totalOrderbook
[
symbol
].
bids
=
bids
totalOrderbook
[
symbol
].
bids
=
bids
totalOrderbook
[
symbol
].
asks
=
asks
totalOrderbook
[
symbol
].
asks
=
asks
const
ret
=
{
data
:
{
SELL
:
asks
,
BUY
:
bids
},
timestamp
:
timeStamp
,
symbol
:
symbol
}
const
ret
=
{
data
:
{
SELL
:
asks
,
BUY
:
bids
},
timestamp
:
timeStamp
,
symbol
:
symbol
}
...
...
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