So my script below is pulling live date from a websocket and parsing it. It can either come as [params][channel], or it can come as a [params][type].
As you can see from my code below depending on which it is I parse it and assign values in the date to my variables.
However the script never goes into the second elif statement. Even when there is a data1["params"]["type"] == "test_request". For some reason it is not moving onto the elif statement, but straight onto pass. I know this because I switched the if statement around and the first if statement is the only one that runs.
I am thinking it is caused by the try except. Any help would be appreciated.
response1 = await websocket.recv()
data1 = json.loads(response1)
try:
if data1["params"]["channel"]:
if data1["params"]["channel"] == perp_ticker:
perp_bid_price = data1["params"]["data"]["best_bid_price"]
perp_ask_price = data1["params"]["data"]["best_ask_price"]
elif data1["params"]["channel"] == far2_ticker:
far2_bid_price = data1["params"]["data"]["best_bid_price"]
far2_ask_price = data1["params"]["data"]["best_ask_price"]
elif data1["params"]["channel"] == far3_ticker:
far3_bid_price = data1["params"]["data"]["best_bid_price"]
far3_ask_price = data1["params"]["data"]["best_ask_price"]
elif data1["params"]["type"] == "test_request" :
await websocket.send(msg_publictest)
print('response sent to heartbeat')
except:
pass
Aucun commentaire:
Enregistrer un commentaire