Lumiwealth / quantstats_lumi

Apache License 2.0
83 stars 27 forks source link

ValueError: Invalid frequency: ME when using qs.reports.html #32

Open tampaguy2012 opened 5 months ago

tampaguy2012 commented 5 months ago

I'm encountering a ValueError: Invalid frequency: ME when using the qs.reports.html function. This error seems to be generated internally within the library, even when I provide a valid integer value for the periods_per_year argument.

Steps to Reproduce

Import libraries

import pandas as pd import quantstats_lumi as qs

Create Sample Data

dates = pd.date_range('2023-05-01', periods=10) portfolio_data = [1.02, 0.98, 1.05, 1.01, 1.03, 0.97, 0.99, 1.06, 1.0, 0.99] benchmark_data = [1.01, 0.99, 1.03, 1.02, 1.06, 0.96, 0.98, 1.05, 0.98, 1.0]

portfolio = pd.Series(portfolio_data, index=dates, name="Port") bench = pd.Series(benchmark_data, index=dates, name='SPY')

Attempt to generate the report:

qs.reports.html(portfolio, benchmark=bench, output='test_output.html', periods_per_year=365)

The above code produces the following traceback (shortened for clarity):

ValueError: Invalid frequency: ME

tampaguy2012 commented 5 months ago

I've tried the following troubleshooting steps:

grzesir commented 5 months ago

You have an old version of pandas, make sure that you upgrade to the latest version

Robert Grzesik 347-635-3416

On Tue, May 7, 2024 at 7:16 PM tampaguy2012 @.***> wrote:

I've tried the following troubleshooting steps:

  • Ensuring the periods_per_year argument is a valid integer.
  • Restarting my runtime environment.
  • Inspecting my code for any potential sources of the "ME" string.

— Reply to this email directly, view it on GitHub https://github.com/Lumiwealth/quantstats_lumi/issues/32#issuecomment-2099460651, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAIYQK4E7OQSUUZSMNXLV23ZBFODZAVCNFSM6AAAAABHL4IQISVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDAOJZGQ3DANRVGE . You are receiving this because you are subscribed to this thread.Message ID: @.***>

bibib2211 commented 3 months ago

I have the same issue, have verified that the error occurs even with the latest version of pandas. Pandas documentation https://pandas.pydata.org/docs/whatsnew/v2.2.0.html#deprecate-aliases-m-q-y-etc-in-favour-of-me-qe-ye-etc-for-offsets suggests these are the frequency strings that should be in use, not sure what is going on.