Skip to content
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

builtins.AttributeError: 'Series' object has no attribute 'ix' #33

Open
enjoysmath opened this issue May 1, 2021 · 1 comment
Open

Comments

@enjoysmath
Copy link

enjoysmath commented May 1, 2021

This is an issue with the pictured hello world code (bottom left).

image

Actually, here is the shortest MWE:


import matplotlib
import matplotlib.pyplot as plt
import pybacktest
import pandas as pd

short_ma = 50
long_ma = 200

ohlc = pybacktest.load_from_yahoo('AAPL', start=2000)
ohlc.tail()

ms = ohlc.C.rolling(short_ma).mean()
ml = ohlc.C.rolling(long_ma).mean()

buy = cover = (ms > ml) & (ms.shift() < ml.shift())  # ma cross up
sell = short = (ms < ml) & (ms.shift() > ml.shift())  # ma cross down

bt = pybacktest.Backtest(locals(), 'ma_cross')

print(bt.summary())

matplotlib.rcParams['figure.figsize'] = (15.0, 8.0)

bt.plot_equity()
@aiot-tech
Copy link

replacing ix with loc, it may be solved.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants