0

through my api key i am importing the data from alpaca. but using the backtest library i receive this error.

ValueError: data must be a pandas.DataFrame with columns 'Open', 'High', 'Low', 'Close', and (optionally) 'Volume'

the code use to import data is

from alpaca_trade_api.rest import REST, TimeFrame, TimeFrameUnit

api = REST(api_key, api_secret, base_url, api_version='v2')
**data**=api.get_bars("aapl", TimeFrame(1, TimeFrameUnit.Day), "2022-01-01", "2023-03-03", adjustment='raw').df

backtest code

bt=Backtest (**data**, SMACROSS,cash=1000, commission=0, exclusive_orders=True)
output=bt.run()
bt.plot()

0 Answers0