bybit-exchange / pybit

Official Python3 API connector for Bybit's HTTP and WebSockets APIs.
Other
418 stars 135 forks source link

get_kline() returns NONE or EMPTY Lists #247

Open Tole01 opened 1 month ago

Tole01 commented 1 month ago

I'm trying to access to API V5's info though pybit version 5.8.0. When I try the next code I receive kline information such as {'retCode': 0, 'retMsg': 'OK', 'result': {'category': 'spot', 'symbol': 'KASUSDT', 'list': []}, 'retExtInfo': {}, 'time': 1727663723656} but the key or property 'list' is empty an there's just NONE type data. Can someone explain me why is this happening and how can I solve it?

image

ervuks commented 1 month ago

Hello. I was able to retrieve data without start and end properties. In your example, where do you set timeframe.
Make sure you creating timestamps correctly This is code I used:

from pybit.unified_trading import HTTP

session = HTTP(
    testnet=False,
    api_key="",
    api_secret="",
)

response = session.get_kline(
    category="spot",
    symbol="KASUSDT",
    interval="5",
    limit="1",
)
print(response)

And received following response:

{'retCode': 0, 'retMsg': 'OK', 'result': {'category': 'spot', 'symbol': 'KASUSDT', 'list': [['1727764200000', '0.16173', '0.16185', '0.16173', '0.16183', '8637.88', '1397.3137097']]}, 'retExtInfo': {}, 'time': 1727764249578}