stefan-jansen / pyfolio-reloaded

Portfolio and risk analytics in Python
https://pyfolio.ml4trading.io/
Apache License 2.0
389 stars 111 forks source link

AttributeError: 'Series' object has no attribute 'iteritems' #40

Closed octadelsueldo closed 11 months ago

octadelsueldo commented 11 months ago

Problem Description

Please provide a minimal, self-contained, and reproducible example:

returns, positions, transactions = pf.utils.extract_rets_pos_txn_from_zipline(results)

Please provide the full traceback:

--------------------------------------------------------------------------
AttributeError                           Traceback (most recent call last)
~\AppData\Local\Temp\tmp_ocfh14j\ipykernel_45932\1667671850.py in ?()
----> 1 returns, positions, transactions = pf.utils.extract_rets_pos_txn_from_zipline(results)

~\anaconda3\envs\zip38\lib\site-packages\pyfolio\utils.py in ?(backtest)
    170     if backtest.index.tzinfo is None:
    171         backtest.index = backtest.index.tz_localize("UTC")
    172     returns = backtest.returns
    173     raw_positions = []
--> 174     for dt, pos_row in backtest.positions.iteritems():
    175         df = pd.DataFrame(pos_row)
    176         df.index = [dt] * len(df)
    177         raw_positions.append(df)

~\anaconda3\envs\zip38\lib\site-packages\pandas\core\generic.py in ?(self, name)
   5985             and name not in self._accessors
   5986             and self._info_axis._can_hold_identifiers_and_holds_name(name)
   5987         ):
   5988             return self[name]
-> 5989         return object.__getattribute__(self, name)

AttributeError: 'Series' object has no attribute 'iteritems'

Please provide any additional information below:

While running 03_ml4t_with_zipline.ipynb of machine learning for trading

Versions

octadelsueldo commented 11 months ago

I updated the pyfolio-reloaded package (using pip) and it was solved