Closed gmulaku closed 2 years ago
Does this answer your question?
(PS: if you fence your code with triple backticks it renders nicely!)
I am sorry but I still don't understand how to optimize my portfolio using the tracking error... I was thinking that if I write it as an objective, maybe I will be able to put it in this code instead of "objective_1"
result = optimize.minimize(objective_1, x0, bounds = bounds, method='SLSQP', tol=1e-8, constraints=cons_1)
w_1 = result.x.reshape((numberOfAssets, 1))
It looks like your script is built in scipy rather than PyPortfolioOpt. Could you please have a look at the User Guide, which should help you re-write the problem in PyPortfolioOpt. After which it should be simple enough to incorporate the tracking error constraint linked previously.
Hi @robertmartin8 , I had exactly the same question as @gmulaku.
Unfortunately, the link you shared on the FAQs doesn't help me completely, because I don't know how I should add the weights, of the benchmark.
Maybe this is more of a financial question, but I don't understand why should I specify weights.
If I send equal weights to add_constraint() will that help?
Could you provide an example?
Thanks so much in advance!
Hi @aloariza,
As mentioned in the docs, you can pass a numpy array of the benchmark weights.
This is only relevant if you are trying to optimise a portfolio with a tracking error objective/constraint.
Best, Robert
What are you trying to do? I am trying to optimize my portfolio of 22 stocks but I have to limit the Tracking Error to 4%, with respect to MSCI World index.
What have you tried? I am able to obtain the optimal allocation without the TE using Scipy.optimize. You can find my code here :
What I would like to do is to put the Tracking Error you defined in an other issue as a constraint in my solver so that my optimal weights are impacted by the TE constraint.