I've been trying to backtest a strategy using backtrader and need some help using the correct format for datetimes used by the variable cerebro of backtrader.
This snippet is an example of my problem:
timestamps = [price[0] / 1000 for price in prices]
for symbol in symbols:
timestamps, closes = get_coingecko_data(symbol, "usd", 242)
data_dict = {'datetime': pd.to_datetime(timestamps, unit='s'), 'close': closes}
data = bt.feeds.PandasData(dataname=pd.DataFrame.from_dict(data_dict), open=None, high=None, low=None, volume=None, openinterest=None)
After running backtrader's variable "cerebro with cerebro.run()
I keep getting this error:
AttributeError: 'int' object has no attribute 'to_pydatetime'
It seems that the type of the timestamp given by CoinGecko are in this form:
<class 'pandas.core.indexes.datetimes.DatetimeIndex'>
Any help in fixing this error in my code is appreciated.