dydx-v3-python icon indicating copy to clipboard operation
dydx-v3-python copied to clipboard

adds ws client (threaded)

Open 0xfMissingNo opened this issue 4 years ago • 1 comments

In [1]: from dydx3 import Client

In [2]: from dydx3.constants import API_HOST_MAINNET

In [3]: cl = Client(API_HOST_MAINNET)

In [4]: cl.ws.start()

-- connection established --
In [5]: cl.ws.subscribe_to_orderbook('ETH-USD')

{"type":"channel_data","connection_id":"28f90048-272f-4af7-a0ff-2cb41a6e7085","message_id":2,"id":"ETH-USD","channel":"v3_orderbook","contents":{"offset":"1553537494","bids":[],"asks":[["3158.1","1.959"]]}}
{"type":"channel_data","connection_id":"28f90048-272f-4af7-a0ff-2cb41a6e7085","message_id":3,"id":"ETH-USD","channel":"v3_orderbook","contents":{"offset":"1553537498","bids":[["3140.4","82.289"],["3139.3","0.032"]],"asks":[]}}
{"type":"channel_data","connection_id":"28f90048-272f-4af7-a0ff-2cb41a6e7085","message_id":4,"id":"ETH-USD","channel":"v3_orderbook","contents":{"offset":"1553537505","bids":[],"asks":[["3159.2","0"]]}}
In [6]: cl.ws.stop()
{"type":"channel_data","connection_id":"28f90048-272f-4af7-a0ff-2cb41a6e7085","message_id":134,"id":"ETH-USD","channel":"v3_orderbook","contents":{"offset":"1553538703","bids":[],"asks":[["3156.8","6.336"]]}}
{"type":"channel_data","connection_id":"28f90048-272f-4af7-a0ff-2cb41a6e7085","message_id":135,"id":"ETH-USD","channel":"v3_orderbook","contents":{"offset":"1553538704","bids":[],"asks":[["3156.9","47.276"]]}}
{"type":"channel_data","connection_id":"28f90048-272f-4af7-a0ff-2cb41a6e7085","message_id":130,"id":"ETH-USD","channel":"v3_orderbook","contents":{"offset":"1553538662","bids":[["3156.6","0"]],"asks":[["3156.6","48.09"]]}}
-- connection closed --


0xfMissingNo avatar Sep 24 '21 00:09 0xfMissingNo

Tested this ws client on python 3.8 and it works great. Thanks for the PR even though it looks like it's not getting merged

SC4RECOIN avatar Mar 22 '22 00:03 SC4RECOIN