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

AttributeError: 'Index' object has no attribute 'tz' on Hourly data #26

Open
thomasf1 opened this issue Dec 5, 2019 · 0 comments
Open

Comments

@thomasf1
Copy link

thomasf1 commented Dec 5, 2019

When testing with hourly data instead of the daily on the example app (ms/ml) and calling the summary, I get the following error:

Traceback (most recent call last):
  File "pyback1.py", line 75, in <module>
    print(bt.summary())
  File "/usr/local/lib/python3.7/site-packages/pybacktest/backtest.py", line 174, in summary
    print((yaml.dump(self.report, allow_unicode=True, default_flow_style=False)))
  File "/usr/local/lib/python3.7/site-packages/cached_property.py", line 35, in __get__
    value = obj.__dict__[self.func.__name__] = self.func(obj)
  File "/usr/local/lib/python3.7/site-packages/pybacktest/backtest.py", line 164, in report
    return pybacktest.performance.performance_summary(self.equity)
  File "/usr/local/lib/python3.7/site-packages/cached_property.py", line 35, in __get__
    value = obj.__dict__[self.func.__name__] = self.func(obj)
  File "/usr/local/lib/python3.7/site-packages/pybacktest/backtest.py", line 152, in equity
    return pybacktest.parts.trades_to_equity(self.trades)
  File "/usr/local/lib/python3.7/site-packages/cached_property.py", line 35, in __get__
    value = obj.__dict__[self.func.__name__] = self.func(obj)
  File "/usr/local/lib/python3.7/site-packages/pybacktest/backtest.py", line 142, in trades
    assert p.index.tz == tp.index.tz, "Cant operate on singals and prices " \
AttributeError: 'Index' object has no attribute 'tz'

The data looks similar, with the date format being more detailed.

I was using pd.to_datetime on a csv (without a timezone information). If there is no TimeZone information it would be nice to have a better error message.

Solution: Add a Timezone, pd.to_datetime(x, utc=True) in my case

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

1 participant