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

How to actually install? #1322

Open
insanebaba opened this issue Mar 7, 2025 · 0 comments
Open

How to actually install? #1322

insanebaba opened this issue Mar 7, 2025 · 0 comments

Comments

@insanebaba
Copy link

Correct me if I am wrong, but How is anyone supposed to install this on mac machine?

  1. This library uses python 3.11, so cannot use newer version.
  2. It also uses pyfoliio which was last updated 5 years ago and uses numpy <2.0, while the project uses numpy > 3. If there's a separate finrl-meta project available, is that supposed to be maintained , or meta in this repo is maintained? so I need to install that separately ?

I have tried multiple empty environments using conda, also tried 3.10 and 3.12 for python. Then I tried downloading and installing from local repo removing pyfolio as it was one of the recommendations.

Currently I have successfully installed the repo in fresh conda env finrl, but unable to run forst function

df_baseline = get_baseline(ticker='AAPL', start='2018-09-15', end='2021-09-04') # ^DJI
stats = backtest_stats(df_baseline, value_col_name = 'close')

with getting error from numpy as pyfolio uses <2.0 version of numpy

---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
Cell In[7], line 1
----> 1 stats = backtest_stats(df_baseline, value_col_name = 'close')

File /opt/homebrew/Caskroom/miniconda/base/envs/finrl/lib/python3.11/site-packages/finrl/plot.py:40, in backtest_stats(account_value, value_col_name)
     38 def backtest_stats(account_value, value_col_name="account_value"):
     39     dr_test = get_daily_return(account_value, value_col_name=value_col_name)
---> 40     perf_stats_all = timeseries.perf_stats(
     41         returns=dr_test,
     42         positions=None,
     43         transactions=None,
     44         turnover_denom="AGB",
     45     )
     46     print(perf_stats_all)
     47     return perf_stats_all

File /opt/homebrew/Caskroom/miniconda/base/envs/finrl/lib/python3.11/site-packages/pyfolio/timeseries.py:726, in perf_stats(returns, factor_returns, positions, transactions, turnover_denom)
    724 stats = pd.Series()
    725 for stat_func in SIMPLE_STAT_FUNCS:
--> 726     stats[STAT_FUNC_NAMES[stat_func.__name__]] = stat_func(returns)
    728 if positions is not None:
    729     stats['Gross leverage'] = gross_lev(positions).mean()

File /opt/homebrew/Caskroom/miniconda/base/envs/finrl/lib/python3.11/site-packages/empyrical/stats.py:797, in sortino_ratio(returns, required_return, period, annualization, out, _downside_risk)
    791 ann_factor = annualization_factor(period, annualization)
    793 average_annual_return = nanmean(adj_returns, axis=0) * ann_factor
    794 annualized_downside_risk = (
    795     _downside_risk
    796     if _downside_risk is not None else
--> 797     downside_risk(returns, required_return, period, annualization)
    798 )
    799 np.divide(average_annual_return, annualized_downside_risk, out=out)
    800 if return_1d:

File /opt/homebrew/Caskroom/miniconda/base/envs/finrl/lib/python3.11/site-packages/empyrical/stats.py:875, in downside_risk(returns, required_return, period, annualization, out)
    866     return out
    868 ann_factor = annualization_factor(period, annualization)
    870 downside_diff = np.clip(
    871     _adjust_returns(
    872         np.asanyarray(returns),
    873         np.asanyarray(required_return),
    874     ),
--> 875     np.NINF,
    876     0,
    877 )
    879 np.square(downside_diff, out=downside_diff)
    880 nanmean(downside_diff, axis=0, out=out)

File /opt/homebrew/Caskroom/miniconda/base/envs/finrl/lib/python3.11/site-packages/numpy/__init__.py:400, in __getattr__(attr)
    397     raise AttributeError(__former_attrs__[attr], name=None)
    399 if attr in __expired_attributes__:
--> 400     raise AttributeError(
    401         f"`np.{attr}` was removed in the NumPy 2.0 release. "
    402         f"{__expired_attributes__[attr]}",
    403         name=None
    404     )
    406 if attr == "chararray":
    407     warnings.warn(
    408         "`np.chararray` is deprecated and will be removed from "
    409         "the main namespace in the future. Use an array with a string "
    410         "or bytes dtype instead.", DeprecationWarning, stacklevel=2)

AttributeError: `np.NINF` was removed in the NumPy 2.0 release. Use `-np.inf` instead.

OS : Sequioa M4 mac mini
all dependencies mentioned for brew have been installed.

Let me know what shall I do

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