-
Notifications
You must be signed in to change notification settings - Fork 2.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Inaccurate prices with get_klines #1379
Comments
The client is using the testnet API. |
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 <
***@***.***>:
… 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)
—
Reply to this email directly, view it on GitHub
<#1379 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ALX46DEM7SQMJLJWG6OSEMLYLYBMTAVCNFSM6AAAAABAOYCG42VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQNZRGYZTCMZZGY>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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: