S = risk_models.CovarianceShrinkage(prices).ledoit_wolf()
mu = pypfopt.expected_returns.capm_return(prices)
ef = EfficientFrontier(mu, S)
ef.add_objective(objective_functions.L2_reg, gamma=(0.1))
ef.efficient_risk(0.025)
weights = ef.clean_weights()
su = pd.DataFrame([weights])
#finding zero weights
num_small = len([k for k in weights if weights[k] <= 1e-4])
global_dict[int(userId)]['num_small'] = str(f"{num_small}/{len(ef.tickers)} tickers have zero weight")
fig = px.pie(su, values=weights.values(), names=su.columns)
fig.update_traces(textposition='inside')
fig.update_layout(width=500, height=500, uniformtext_minsize=12, uniformtext_mode='hide', title_text='Weights Distribution using Capital Asset Pricing Model', title_x=0.5)
And I have the following output:
Price graph showing GLBE was listed on May 2021
The weights return of the above code
The allocation return of the above code
When using another recently listed stock (MNDY) instead of GLBE I get similar results:
Is there more weights allocated in this setup to more recently listed stocks? or this is by chance ?
I have the following setup:
And I have the following output:
Price graph showing GLBE was listed on May 2021
The weights return of the above code
The allocation return of the above code
When using another recently listed stock (MNDY) instead of GLBE I get similar results:
Is there more weights allocated in this setup to more recently listed stocks? or this is by chance ?