Skip to content

ValueError: assignment destination is read-only #14

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
alexlusak opened this issue Jul 27, 2019 · 3 comments
Closed

ValueError: assignment destination is read-only #14

alexlusak opened this issue Jul 27, 2019 · 3 comments
Labels
bug Something isn't working

Comments

@alexlusak
Copy link

alexlusak commented Jul 27, 2019

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.

@kernc kernc added the bug Something isn't working label Aug 1, 2019
@kernc
Copy link
Owner

kernc commented Aug 2, 2019

The issue is with pandas 0.25.0. The temporary workaround is to:

pip install pandas==0.24.2

@kernc kernc changed the title Pandas error when running demo ValueError: assignment destination is read-only Aug 6, 2019
@kernc
Copy link
Owner

kernc commented Aug 7, 2019

The issue is fixed in pandas master and in the upcoming pandas 0.25.1 release.

@kernc kernc closed this as completed Aug 7, 2019
@alexlusak
Copy link
Author

Amazing, thanks for staying on top of this.

kernc added a commit that referenced this issue Sep 22, 2019
Goblincomet pushed a commit to Goblincomet/forex-trading-backtest that referenced this issue Jul 5, 2023
Goblincomet pushed a commit to Goblincomet/forex-trading-backtest that referenced this issue Jul 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants