Skip to content

ValueError: assignment destination is read-only #14

Closed
@alexlusak

Description

@alexlusak

I was simply trying to run the demo, but I am getting the following error:

Traceback (most recent call last):
  File "backtest.py", line 49, in <module>
    output = bt.run()
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/backtesting/backtesting.py", line 675, in run
    strategy.init()
  File "backtest.py", line 29, in init
    self.sma1 = self.I(SMA, self.data.Close, self.n1)
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/backtesting/backtesting.py", line 124, in I
    value = func(*args, **kwargs)
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/backtesting/test/__init__.py", line 23, in SMA
    return pd.Series(arr).rolling(n).mean()
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/pandas/core/window.py", line 1875, in mean
    return super().mean(*args, **kwargs)
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/pandas/core/window.py", line 1178, in mean
    return self._apply("roll_mean", "mean", **kwargs)
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/pandas/core/window.py", line 910, in _apply
    values = self._prep_values(b.values)
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/pandas/core/window.py", line 239, in _prep_values
    values[np.isinf(values)] = np.NaN
ValueError: assignment destination is read-only

I have downloaded the latest version of numpy (1.17.0) in addition to pandas (0.25.0), so I'm suspecting there may be something different in one of the newer version of these libraries. Any insight to why this may be throwing this error would be appreciated.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions