FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
python-binance/examples/depth_cache_threaded_example.py at master · SoniCoder/python-binance · GitHub
SoniCoder
/
python-binance
Public
forked from
sammchardy/python-binance
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
Code
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
python-binance
/
examples
/
depth_cache_threaded_example.py
Copy path
More file actions
More file actions
Latest commit
History
History
History
38 lines (28 loc) · 1.14 KB
Breadcrumbs
python-binance
/
examples
/
depth_cache_threaded_example.py
Copy path
File metadata and controls
38 lines (28 loc) · 1.14 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#!/usr/bin/env python3
import
os
import
sys
root
=
os
.
path
.
dirname
(
os
.
path
.
dirname
(
os
.
path
.
abspath
(
__file__
)))
sys
.
path
.
append
(
root
)
import
logging
from
binance
.
ws
.
depthcache
import
ThreadedDepthCacheManager
logging
.
basicConfig
(
level
=
logging
.
DEBUG
)
logger
=
logging
.
getLogger
(
__name__
)
def
main
():
dcm
=
ThreadedDepthCacheManager
()
dcm
.
start
()
def
handle_depth_cache
(
depth_cache
):
if
isinstance
(
depth_cache
,
dict
)
and
depth_cache
.
get
(
'e'
)
==
'error'
:
logger
.
error
(
f"Received depth cache error in callback:
{
depth_cache
}
"
)
type
=
depth_cache
.
get
(
'type'
)
if
type
==
'BinanceWebsocketClosed'
:
# Automatically attempts to reconnect
return
logger
.
error
(
f"Error received - Closing depth cache:
{
depth_cache
}
"
)
dcm
.
stop
()
return
logger
.
info
(
f"symbol
{
depth_cache
.
symbol
}
"
)
logger
.
info
(
depth_cache
.
get_bids
()[:
5
])
dcm
.
start_depth_cache
(
handle_depth_cache
,
symbol
=
'BNBBTC'
)
dcm
.
join
()
if
__name__
==
"__main__"
:
main
()
Back
|
FazBrowse Home
|
New Git URL