Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
Z
zbNode
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
ken
zbNode
Commits
7022c15a
Commit
7022c15a
authored
Sep 10, 2018
by
ken
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
depth
parent
efe5e04b
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
3 deletions
+7
-3
zb.js
zb.js
+7
-3
No files found.
zb.js
View file @
7022c15a
...
...
@@ -14,6 +14,7 @@ const accountInfoChannel = "getaccountinfo";
const
APIKEY
=
"6b07db0c-dc4f-4a90-9955-665041bdbdbf"
;
const
APISECRET
=
"7ac9bcc3-5f0c-4eaf-99c9-80cb6a45165a"
;
const
lastEventTimeMap
=
{};
const
lastLastEventTimeMap
=
{};
const
lastDataMap
=
{};
const
lastLastDataMap
=
{};
let
balanceByRestOk
=
true
;
...
...
@@ -161,10 +162,12 @@ function _handleDepthData(symbol, data, source) {
const
key
=
symbol
.
replace
(
'_'
,
''
).
toUpperCase
()
+
'DEPTH@zb'
;
symbol
=
symbol
.
toUpperCase
();
const
lastEventTime
=
lastEventTimeMap
[
symbol
]
||
0
;
const
lastLastEventTime
=
lastLastEventTimeMap
[
symbol
]
||
0
;
const
asks
=
data
.
asks
.
reverse
().
slice
(
0
,
5
);
const
bids
=
data
.
bids
.
slice
(
0
,
5
);
const
currentJsonData
=
JSON
.
stringify
({
asks
,
bids
});
if
(
data
.
timestamp
>
lastEventTime
||
(
data
.
timestamp
===
lastEventTime
&&
currentJsonData
!==
lastDataMap
[
symbol
]))
{
if
(
data
.
timestamp
>
lastEventTime
||
(
data
.
timestamp
===
lastEventTime
&&
currentJsonData
!==
lastDataMap
[
symbol
]
&&
(
currentJsonData
!==
lastLastDataMap
[
symbol
]
||
lastLastEventTime
!=
data
.
timestamp
)))
{
if
(
symbol
===
"BTCUSDT"
)
{
let
consoleMethod
=
console
.
log
;
if
(
data
.
timestamp
===
lastEventTime
)
{
...
...
@@ -173,8 +176,9 @@ function _handleDepthData(symbol, data, source) {
consoleMethod
(
symbol
+
'@'
+
data
.
timestamp
*
1000
+
' from '
+
source
);
consoleMethod
(
currentJsonData
);
}
lastLastEventTimeMap
[
symbol
]
=
lastEventTimeMap
[
symbol
];
lastEventTimeMap
[
symbol
]
=
data
.
timestamp
;
//
lastLastDataMap[symbol] = lastDataMap[symbol];
lastLastDataMap
[
symbol
]
=
lastDataMap
[
symbol
];
lastDataMap
[
symbol
]
=
currentJsonData
;
const
publishContent
=
JSON
.
stringify
({
symbol
,
time
:
data
.
timestamp
*
1000
});
...
...
@@ -244,7 +248,7 @@ function getBalanceByRest() {
function
run
()
{
subscribe
();
const
depthInterval
=
Math
.
max
(
60
*
1000
/
(
900
*
ips
.
length
/
observerSymbol
.
length
),
80
);
const
depthInterval
=
Math
.
max
(
60
*
1000
/
(
900
*
ips
.
length
/
observerSymbol
.
length
),
55
);
console
.
log
(
depthInterval
);
setInterval
(()
=>
{
for
(
const
symbol
of
observerSymbol
)
{
...
...
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