in this commands;
import requests
import pandas as pd
url = "https://api.binance.com/api/v3/depth?symbol=BNBUSDT&limit=100"
payload = {}
headers = {
'Content-Type': 'application/json'
}
response = requests.request("GET", url, headers=headers, data=payload).json()
depth = pd.DataFrame(response, columns=["bids","asks"])
print(depth)
outputs :
........ | bids | asks |
---|---|---|
0 | [382.40000000, 86.84800000] | [382.50000000, 196.24600000] |
1 | [382.30000000, 174.26400000] | [382.60000000, 116.10300000] |
and first i need to change the table this format
........ | bidsValue | bidsQuantity | asksValue | asksQuantity | rangeTotalbidsQuantity | rangeTotalasksQuantity |
---|---|---|---|---|---|---|
0 | 382.40000000 | 86.84800000 | 382.50000000 | 196.24600000 | ||
1 | 382.30000000 | 174.26400000 | 382.60000000 | 116.10300000 |
and then turn the columns values float so that be able to calculate in a specific range values quantity (e.g 0bidsValue 400.00 and ?bidsValue 380.00 ("?" because of i don't know row number) first i must find row number of bidsValue 380.00 (for example it is 59) then calculate 0bidsQuantity to 59bidsQuantity) and last write the results in rangeTotalbidsQuantity column.
I've been trying for hours, I tried many commands from "pandas.Dataframe" but I couldn't do it. Thank you!