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
9cca8d76
Commit
9cca8d76
authored
Apr 04, 2018
by
ken
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
zb
parent
3fbf179f
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
2 additions
and
2 deletions
+2
-2
zb.js
zb.js
+2
-2
No files found.
zb.js
View file @
9cca8d76
const
stream
=
'wss://api.zb.com:9999/websocket'
;
const
WebSocket
=
require
(
'ws'
);
const
options
=
{};
const
observerSymbol
=
[
"btcusdt"
];
const
observerSymbol
=
[
"btcusdt"
,
'ethusdt'
,
'ltcusdt'
,
'eosusdt'
,
'bccusdt'
,
'etcusdt'
,
'qtumusdt'
,
'hsrusdt'
,
'xrpusdt'
];
const
redis
=
require
(
'redis'
);
const
redisClient
=
redis
.
createClient
();
const
publishKey
=
"ZB@2"
;
...
...
@@ -51,9 +51,9 @@ const _subscribe = function(callback, opened_callback = false) {
function
subscribe
()
{
_subscribe
((
depth
)
=>
{
console
.
log
(
depth
.
timestamp
*
1000
);
const
key
=
depth
.
channel
.
replace
(
'_'
,
''
).
toUpperCase
()
+
'@zb'
;
const
symbol
=
depth
.
channel
.
replace
(
'_depth'
,
''
).
toUpperCase
();
console
.
log
(
symbol
+
'@'
+
depth
.
timestamp
*
1000
+
' latency='
+
(
Date
.
now
()
-
depth
.
timestamp
*
1000
)
+
'ms'
);
const
publishContent
=
JSON
.
stringify
({
symbol
,
time
:
depth
.
timestamp
*
1000
})
const
depthJson
=
JSON
.
stringify
({
asks
:
depth
.
asks
.
reverse
(),
bids
:
depth
.
bids
,
symbol
})
redisClient
.
set
(
key
,
depthJson
);
...
...
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