pat42w / EF_Portfolio_Optimization

This project aims to test Portfolio Optimization methods on stock data in python.
MIT License
2 stars 0 forks source link

Infinities arising in the max , mean and actual stats #15

Closed pat42w closed 3 years ago

pat42w commented 3 years ago

database=df_Nasdaq startdate=pd.to_datetime("2015-08-01") enddate=pd.to_datetime("2016-12-01") dmf.portfolio_generate_test(database,startdate,enddate,p_max=250, min_returns=0.01, s_asset=0, asset_len=50, silent=False, obj_method="SHARPE")

Results in inf

eohara-ie commented 3 years ago

Do we need to pull extra resources on to this? ;)

pat42w commented 3 years ago

image Isolated the issue to this GEG stock, but it seems to be an issue from when the data was pulled as a repull through yfinance fixes it. i will add in watching for these "mid nans" into the priceDB_validation() function.

pat42w commented 3 years ago

Fix applied using df.fillna(method='bfill') this uses the next valid days price to fill the preceeing days ensuring day 1 of the actual period does not have an nan.

I have checked a handful of different cases in the EF_analysis notebook& it has fixed these, So I'm happy to close this issue, i will regenerate the portfolios overnight to ensure it fixed all the infs it overnight