8000 AttributeError: 'Index' object has no attribute 'tz' on Hourly data · Issue #26 · ematvey/pybacktest · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
AttributeError: 'Index' object has no attribute 'tz' on Hourly data #26
Open
@thomasf1

Description

@thomasf1

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0