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

stats.sharpe raise error when input is pd.Series. #384

Open
g199209 opened this issue Nov 24, 2024 · 0 comments
Open

stats.sharpe raise error when input is pd.Series. #384

g199209 opened this issue Nov 24, 2024 · 0 comments

Comments

@g199209
Copy link

g199209 commented Nov 24, 2024

commit 8ce8784 introduce this bug.

This patch adds a lot of data = data.tz_localize(None) in utils.py, for example in _prepare_prices.

But if input data is pd.Series, not Dataframe, data.tz_localize is wrong.

>>> data = pd.Series([0.000000, 0.000008])
>>> data
0    0.000000
1    0.000008
dtype: float64
>>> data.tz_localize(None)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/mingfei/.local/lib/python3.12/site-packages/pandas/core/generic.py", line 11725, in tz_localize
    ax = _tz_localize(ax, tz, ambiguous, nonexistent)
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/mingfei/.local/lib/python3.12/site-packages/pandas/core/generic.py", line 11708, in _tz_localize
    raise TypeError(
TypeError: index is not a valid DatetimeIndex or PeriodIndex
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