You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I tried running your Backtest with Backtrader example and got stuck at this code:
models = {}
rms = ['MV', 'CVaR', 'WR', 'CDaR']
for j in rms:
weights = pd.DataFrame([])
for i in index_:
Y = returns.iloc[i-1000:i,:] # taking last 4 years (250 trading days per year)
# Building the portfolio object
port = pf.Portfolio(returns=Y)
# Add portfolio constraints
port.ainequality = A
port.binequality = B
# Calculating optimum portfolio
# Select method and estimate input parameters:
method_mu='hist' # Method to estimate expected returns based on historical data.
method_cov='hist' # Method to estimate covariance matrix based on historical data.
port.assets_stats(method_mu=method_mu, method_cov=method_cov, d=0.94)
# Estimate optimal portfolio:
port.solvers = ['MOSEK']
port.alpha = 0.05
model='Classic' # Could be Classic (historical), BL (Black Litterman) or FM (Factor Model)
rm = j # Risk measure used, this time will be variance
obj = 'Sharpe' # Objective function, could be MinRisk, MaxRet, Utility or Sharpe
hist = True # Use historical scenarios for risk measures that depend on scenarios
rf = 0 # Risk free rate
l = 0 # Risk aversion factor, only useful when obj is 'Utility'
w = port.optimization(model=model, rm=rm, obj=obj, rf=rf, l=l, hist=hist)
if w is None:
w = weights.tail(1).T
weights = pd.concat([weights, w.T], axis = 0)
models[j] = weights.copy()
models[j].index = index_
I am getting the following error:
How can I resolve this? Thank you.
The text was updated successfully, but these errors were encountered:
I tried running your Backtest with Backtrader example and got stuck at this code:
I am getting the following error:
How can I resolve this? Thank you.
The text was updated successfully, but these errors were encountered: