@@ -19,6 +19,14 @@ By default the depth cache will fetch the order book via REST request every 30 m
1919This duration can be changed by using the `refresh_interval ` parameter. To disable the refresh pass 0 or None.
2020The socket connection will stay open receiving updates to be replayed once the full order book is received.
2121
22+ Websocket Errors
23+ ----------------
24+
25+ If the underlying websocket is disconnected and is unable to reconnect None is returned for the depth_cache parameter.
26+
27+ Examples
28+ --------
29+
2230.. code :: python
2331
2432 # 1 hour interval refresh
@@ -30,22 +38,28 @@ The socket connection will stay open receiving updates to be replayed once the f
3038 .. code :: python
3139
3240 def process_depth (depth_cache ):
33- print (" symbol {} " .format(depth_cache.symbol))
34- print (" top 5 bids" )
35- print (depth_cache.get_bids()[:5 ])
36- print (" top 5 asks" )
37- print (depth_cache.get_asks()[:5 ])
41+ if depth_cache is not None :
42+ print (" symbol {} " .format(depth_cache.symbol))
43+ print (" top 5 bids" )
44+ print (depth_cache.get_bids()[:5 ])
45+ print (" top 5 asks" )
46+ print (depth_cache.get_asks()[:5 ])
47+ else :
48+ # depth cache had an error and needs to be restarted
3849
3950 At any time the current `DepthCache ` object can be retrieved from the `DepthCacheManager `
4051
4152.. code :: python
4253
4354 depth_cache = dcm.get_depth_cache()
44- print (" symbol {} " .format(depth_cache.symbol))
45- print (" top 5 bids" )
46- print (depth_cache.get_bids()[:5 ])
47- print (" top 5 asks" )
48- print (depth_cache.get_asks()[:5 ])
55+ if depth_cache is not None :
56+ print (" symbol {} " .format(depth_cache.symbol))
57+ print (" top 5 bids" )
58+ print (depth_cache.get_bids()[:5 ])
59+ print (" top 5 asks" )
60+ print (depth_cache.get_asks()[:5 ])
61+ else :
62+ # depth cache had an error and needs to be restarted
4963
5064 To stop the `DepthCacheManager ` from returning messages use the `close ` method.
5165This will close the internal websocket and this instance of the `DepthCacheManager ` will not be able to be used again.
0 commit comments