mhallsmoore / qstrader

QuantStart.com - QSTrader backtesting simulation engine.
https://www.quantstart.com/qstrader/
MIT License
2.91k stars 854 forks source link

pandas 1.0.3 error AttributeError: 'DataFrame' object has no attribute 'ix' #313

Closed ch01ca closed 4 years ago

ch01ca commented 4 years ago

AttributeError: 'DataFrame' object has no attribute 'ix' python3.7.7 pandas 1.0.3

More details

---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
<ipython-input-1-83cb49361568> in <module>
     68     tickers = ["SPY"]
     69     filename = None
---> 70     run(config, testing, tickers, filename)

<ipython-input-1-83cb49361568> in run(config, testing, tickers, filename)
     54         config, strategy, tickers,
     55         initial_equity, start_date, end_date,
---> 56         events_queue, title=title
     57     )
     58     results = backtest.start_trading(testing=testing)

~/anaconda3/envs/qs/lib/python3.7/site-packages/qstrader/trading_session.py in __init__(self, config, strategy, tickers, equity, start_date, end_date, events_queue, session_type, end_session_time, price_handler, portfolio_handler, compliance, position_sizer, execution_handler, risk_manager, statistics, sentiment_handler, title, benchmark)
     50         self.benchmark = benchmark
     51         self.session_type = session_type
---> 52         self._config_session()
     53         self.cur_time = None
     54 

~/anaconda3/envs/qs/lib/python3.7/site-packages/qstrader/trading_session.py in _config_session(self)
     66                 self.config.CSV_DATA_DIR, self.events_queue,
     67                 self.tickers, start_date=self.start_date,
---> 68                 end_date=self.end_date
     69             )
     70 

~/anaconda3/envs/qs/lib/python3.7/site-packages/qstrader/price_handler/yahoo_daily_csv_bar.py in __init__(self, csv_dir, events_queue, init_tickers, start_date, end_date, calc_adj_returns)
     36         self.start_date = start_date
     37         self.end_date = end_date
---> 38         self.bar_stream = self._merge_sort_ticker_data()
     39         self.calc_adj_returns = calc_adj_returns
     40         if self.calc_adj_returns:

~/anaconda3/envs/qs/lib/python3.7/site-packages/qstrader/price_handler/yahoo_daily_csv_bar.py in _merge_sort_ticker_data(self)
     66         backtesting. In live trading ticks may arrive "out of order".
     67         """
---> 68         df = pd.concat(self.tickers_data.values()).sort_index()
     69         start = None
     70         end = None

~/anaconda3/envs/qs/lib/python3.7/site-packages/pandas/core/reshape/concat.py in concat(objs, axis, join, ignore_index, keys, levels, names, verify_integrity, sort, copy)
    279         verify_integrity=verify_integrity,
    280         copy=copy,
--> 281         sort=sort,
    282     )
    283 

~/anaconda3/envs/qs/lib/python3.7/site-packages/pandas/core/reshape/concat.py in __init__(self, objs, axis, join, keys, levels, names, ignore_index, verify_integrity, copy, sort)
    327 
    328         if len(objs) == 0:
--> 329             raise ValueError("No objects to concatenate")
    330 
    331         if keys is None:

ValueError: No objects to concatenate

​
mhallsmoore commented 4 years ago

Hi @cero1010,

This issue has now been fixed on both the master and advanced-algorithmic-trading branches. The issue was the deprecation of the .ix call in Pandas when utilising the latest 1.0.3 version. Instead of using .ix the correct method is now .iloc.

The requirements.txt has been fully updated to reflect up to date Python packages.

Please let us know if you have any further trouble with the installation.

Regards,

Mike.