1 votos

¿Por qué obtengo devoluciones nan del paquete PyPortfolioOpt?

from pypfopt.efficient_frontier import EfficientFrontier
from pypfopt import risk_models
from pypfopt import expected_returns

# Read in price data
df = pd.read_csv("Asset_Regime.csv", parse_dates=True, index_col="date")

# Calculate expected returns and sample covariance
mu = expected_returns.mean_historical_return(df)
S = risk_models.sample_cov(df)

# Optimise for maximal Sharpe ratio
ef = EfficientFrontier(mu, S)
raw_weights = ef.max_sharpe()
cleaned_weights = ef.clean_weights()
print(cleaned_weights)
ef.portfolio_performance(verbose=True)

Mis datos se ven como

 US Equities World Equities  US Treasuries   High Yield  Corp Bonds  Real Estate Commodities
date                            
Jan-85  0.081301    0.028511    0.031500    0.037908    0.048963    0.056605    0.021351
Feb-85  0.030075    -0.009204   -0.044692   0.012689    -0.042029   0.016448    -0.015217
Mar-85  -0.007299   0.075134    0.028719    0.004323    0.032666    -0.006716   0.037171
Apr-85  -0.012255   -0.002459   0.023084    0.018215    0.037125    0.000906    -0.035116
May-85  0.064516    0.040245    0.086780    0.042363    0.104199    0.027241    0.004351

y vuelve

 {'US Equities': nan, 'World Equities': nan, 'US Treasuries': nan, 'High Yield': nan, 'Corp Bonds': nan, 'Real Estate': nan, 'Commodities': nan}
Expected annual return: nan%
Annual volatility: nan%
Sharpe Ratio: nan
(nan, nan, nan)

Finanhelp.com

FinanHelp es una comunidad para personas con conocimientos de economía y finanzas, o quiere aprender. Puedes hacer tus propias preguntas o resolver las de los demás.

Powered by:

X