Search code examples
pythonbinancebinance-api-client

get_historical_klines() missing 1 required positional argument: 'start_str'


I'm trying to get historical data; however upon executing the code:

def get_data():
    historical_data = client.get_historical_klines(symbol=config.SYMBOL, interval=Client.KLINE_INTERVAL_1MINUTE, limit=100, klines_type=HistoricalKlinesType.SPOT)
    print(historical_data)

I get the error:

historical_data = client.get_historical_klines(symbol=config.SYMBOL, interval=Client.KLINE_INTERVAL_1MINUTE, limit=100, klines_type=HistoricalKlinesType.SPOT)
TypeError: get_historical_klines() missing 1 required positional argument: 'start_str'

What seems to be wrong? Thanks!


Solution

  • You have to provide how much historical data you need. This is made with a 'start_str'. For example :

    '1 day ago UTC'
    '1 hour ago UTC'
    

    So you shoud use the function like that:

    klines = client.get_historical_klines(SYMBOL, Client.KLINE_INTERVAL_15MINUTE , "1 day ago UTC")