You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When using the get_klines function, the opening prices for symbols are often times inaccurate.
Code snippet to reproduce the behavior:
import pandas as pd
from dotenv import load_dotenv
from binance.client import Client
import os
import datetime
load_dotenv()
client = Client(api_key, api_secret, testnet=True)
candles = client.get_klines(symbol='BNBUSDT', interval=Client.KLINE_INTERVAL_1HOUR)
df = pd.DataFrame(candles)
ts = df.iloc[-4][0]/1000
dt = datetime.datetime.fromtimestamp(ts)
dt.strftime("%Y-%m-%d %H:%M:%S")
open_price = []
for col in range(len(df.index)):
open_price.append(df.iloc[col][1])
print(open_price[-4])
print(dt)
Python version: 3.7
Virtual Env: Visual Studio Code
OS: Windows 10
python-binance version
Expected to get accurate open price of a kline as shown on binance.
the code gives the result:
240.60000000
2023-12-10 17:00:00
While for the same time interval on binance, for the same kline, the price given is 240.3 and not 240.6.
Similar inaccuracies happen with some of the other open prices.
The text was updated successfully, but these errors were encountered:
The client is using the testnet API.
To avoid this, set testnet = False when creating the client. This will then pull the real market prices. client = Client(testnet=False)
Thank you very much for the reply.
The solution is simple, but I was unaware of the difference in prices over
the testNET, so it eluded me.
Thank you again.
בתאריך יום ו׳, 29 בדצמ׳ 2023, 1:56, מאת phong-phuong <
***@***.***>:
When using the get_klines function, the opening prices for symbols are often times inaccurate.
Code snippet to reproduce the behavior:
import pandas as pd
from dotenv import load_dotenv
from binance.client import Client
import os
import datetime
load_dotenv()
client = Client(api_key, api_secret, testnet=True)
candles = client.get_klines(symbol='BNBUSDT', interval=Client.KLINE_INTERVAL_1HOUR)
df = pd.DataFrame(candles)
ts = df.iloc[-4][0]/1000
dt = datetime.datetime.fromtimestamp(ts)
dt.strftime("%Y-%m-%d %H:%M:%S")
open_price = []
for col in range(len(df.index)):
open_price.append(df.iloc[col][1])
print(open_price[-4])
print(dt)
Expected to get accurate open price of a kline as shown on binance.
the code gives the result:
240.60000000
2023-12-10 17:00:00
While for the same time interval on binance, for the same kline, the price given is 240.3 and not 240.6.
Similar inaccuracies happen with some of the other open prices.
The text was updated successfully, but these errors were encountered: