Hello, i’d like to use get_order_book.py to collect price and qty but i can’t figure out how to actually use the information it gives me: let’s say i only want the price and qty of the first bid on BTC, how do i select those infos from the return the function gives me ?
There are several 3rd party packages written in python and they may use different method to wrap the response. But you can refer to the document here and see how the original object look like. https://binance-docs.github.io/apidocs/spot/en/#order-book
1 Like
thx but i just don’t understand how to extract what i want even tho i think i understand how is organized the response, ex:
Here’s the code:
from binance_f import RequestClient
from binance_f.constant.test import *
request_client = RequestClient(api_key=g_api_key, secret_key=g_secret_key)
result = request_client.get_order_book(symbol = "BTCUSDT", limit = 10)
And the response:
{"lastUpdateId":304023054784,"E":1617679391546,"T":1617679391540,"bids":[["58876.56","3.673"],["58875.97","0.050"],["58875.64","0.162"],["58875.40","0.035"],["58874.40","0.008"],["58873.44","0.400"],["58873.43","0.064"],["58873.00","0.100"],["58872.96","0.285"],["58872.43","0.017"]],"asks":[["58876.57","0.002"],["58881.69","0.088"],["58884.04","0.170"],["58884.05","0.085"],["58884.06","0.330"],["58886.53","0.010"],["58886.96","0.085"],["58887.70","0.085"],["58887.71","0.085"],["58887.72","0.100"]]}
Process finished with exit code 0
Now i know the first bid is [“58876.56”,“3.673”] but how do i extract that info from the dictionary ?
This is a python programming question. You can go research on how to handle json objects on python. If you have gotten the data you want, handling it in Python is trivial.
1 Like
thx