JerBouma / FinanceToolkit

Transparent and Efficient Financial Analysis
https://www.jeroenbouma.com/projects/financetoolkit
MIT License
2.99k stars 361 forks source link

[BUG] 3 errors in tests: ValueError: Invalid frequency: ME #160

Open yurivict opened 3 weeks ago

yurivict commented 3 weeks ago

Test failures:


==================================================================================== test session starts ====================================================================================
platform freebsd14 -- Python 3.11.10, pytest-8.1.1, pluggy-1.5.0 -- /usr/local/bin/python3.11
cachedir: .pytest_cache
hypothesis profile 'default' -> database=DirectoryBasedExampleDatabase(PosixPath('/usr/ports/finance/py-financetoolkit/work-py311/FinanceToolkit-1.9.8/.hypothesis/examples'))
rootdir: /usr/ports/finance/py-financetoolkit/work-py311/FinanceToolkit-1.9.8
configfile: pyproject.toml
plugins: time-machine-2.11.0, flaky-3.8.1, aspectlib-2.0.0, typeguard-4.4.0, requests-mock-1.12.1, timeout-2.1.0, cov-5.0.0, hypothesis-6.116.0, xdist-3.6.1, mock-3.10.0, recorder-0.3.0, recording-0.13.2
collected 279 items / 3 errors                                                                                                                                                              

========================================================================================== ERRORS ===========================================================================================
__________________________________________________________________ ERROR collecting tests/models/test_models_controller.py __________________________________________________________________
offsets.pyx:4447: in pandas._libs.tslibs.offsets._get_offset
    ???
E   KeyError: 'ME'

The above exception was the direct cause of the following exception:
offsets.pyx:4549: in pandas._libs.tslibs.offsets.to_offset
    ???
offsets.pyx:4453: in pandas._libs.tslibs.offsets._get_offset
    ???
E   ValueError: Invalid frequency: ME

The above exception was the direct cause of the following exception:
tests/models/test_models_controller.py:22: in <module>
    models_module = toolkit.models
financetoolkit/toolkit_controller.py:684: in models
    return Models(
financetoolkit/models/models_controller.py:100: in __init__
    self._within_historical_data = helpers.determine_within_historical_data(
financetoolkit/models/helpers.py:40: in determine_within_historical_data
    pd.Grouper(freq=f"{symbol}E" if symbol in ["M", "Q", "Y"] else symbol)
/usr/local/lib/python3.11/site-packages/pandas/core/resample.py:2046: in __init__
    freq = to_offset(freq)
offsets.pyx:4460: in pandas._libs.tslibs.offsets.to_offset
    ???
offsets.pyx:4557: in pandas._libs.tslibs.offsets.to_offset
    ???
E   ValueError: Invalid frequency: ME
_____________________________________________________________ ERROR collecting tests/performance/test_performance_controller.py _____________________________________________________________
offsets.pyx:4447: in pandas._libs.tslibs.offsets._get_offset
    ???
E   KeyError: 'ME'

The above exception was the direct cause of the following exception:
offsets.pyx:4549: in pandas._libs.tslibs.offsets.to_offset
    ???
offsets.pyx:4453: in pandas._libs.tslibs.offsets._get_offset
    ???
E   ValueError: Invalid frequency: ME

The above exception was the direct cause of the following exception:
tests/performance/test_performance_controller.py:22: in <module>
    performance_module = toolkit.performance
financetoolkit/toolkit_controller.py:919: in performance
    return Performance(
financetoolkit/performance/performance_controller.py:111: in __init__
    self._within_historical_data = determine_within_historical_data(
financetoolkit/performance/helpers.py:67: in determine_within_historical_data
    pd.Grouper(
/usr/local/lib/python3.11/site-packages/pandas/core/resample.py:2046: in __init__
    freq = to_offset(freq)
offsets.pyx:4460: in pandas._libs.tslibs.offsets.to_offset
    ???
offsets.pyx:4557: in pandas._libs.tslibs.offsets.to_offset
    ???
E   ValueError: Invalid frequency: ME
____________________________________________________________________ ERROR collecting tests/risk/test_risk_controller.py ____________________________________________________________________
offsets.pyx:4447: in pandas._libs.tslibs.offsets._get_offset
    ???
E   KeyError: 'ME'

The above exception was the direct cause of the following exception:
offsets.pyx:4549: in pandas._libs.tslibs.offsets.to_offset
    ???
offsets.pyx:4453: in pandas._libs.tslibs.offsets._get_offset
    ???
E   ValueError: Invalid frequency: ME

The above exception was the direct cause of the following exception:
tests/risk/test_risk_controller.py:12: in <module>
    risk_module = toolkit.risk
financetoolkit/toolkit_controller.py:1001: in risk
    return Risk(
financetoolkit/risk/risk_controller.py:102: in __init__
    self._within_historical_data = determine_within_historical_data(
financetoolkit/risk/helpers.py:65: in determine_within_historical_data
    pd.Grouper(
/usr/local/lib/python3.11/site-packages/pandas/core/resample.py:2046: in __init__
    freq = to_offset(freq)
offsets.pyx:4460: in pandas._libs.tslibs.offsets.to_offset
    ???
offsets.pyx:4557: in pandas._libs.tslibs.offsets.to_offset
    ???
E   ValueError: Invalid frequency: ME
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Interrupted: 3 errors during collection !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
==================================================================================== 3 errors in 11.50s =====================================================================================
*** Error code 2

Version: 1.9.8 Python-3.11 FreeBSD 14.1