Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
E
exchange-binance
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
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
zhangheng
exchange-binance
Commits
de2d1e6c
Commit
de2d1e6c
authored
Jun 02, 2023
by
wangfa
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
合约价格同步
parent
7e45bdef
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
33 additions
and
0 deletions
+33
-0
.gitignore
+2
-0
um_price_stream.py
+31
-0
No files found.
.gitignore
0 → 100644
View file @
de2d1e6c
/.idea
\ No newline at end of file
um_price_stream.py
0 → 100644
View file @
de2d1e6c
import
websocket
import
json
from
db.redis_db
import
RedisClientLocal
SOCKET
=
"wss://fstream.binance.com/ws"
SUBSCRIBE_MESSAGE
=
"{
\"
method
\"
:
\"
SUBSCRIBE
\"
,
\"
params
\"
:[
\"
!markPrice@arr
\"
]}"
MARK_PRICES
=
{}
def
on_open
(
ws
):
print
(
"Connection established."
)
ws
.
send
(
SUBSCRIBE_MESSAGE
)
def
on_close
(
ws
):
print
(
"Connection closed."
)
def
on_message
(
ws
,
message
):
message
=
json
.
loads
(
message
)
for
item
in
message
:
print
(
item
)
MARK_PRICES
[
item
[
"s"
]]
=
item
[
"p"
]
redis_con
.
con
()
.
set
(
f
"laravel_cache:premium-price:binance:{item['s']}"
,
item
[
'p'
])
if
__name__
==
"__main__"
:
redis_con
=
RedisClientLocal
()
ws
=
websocket
.
WebSocketApp
(
SOCKET
,
on_open
=
on_open
,
on_close
=
on_close
,
on_message
=
on_message
)
ws
.
run_forever
()
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