Back to Community
CVXOPT Beta optimization help needed

TL;DR - How do I add a target to CVXOPT instead of just minimizing the variable. Alternatively, how Do I add beta calculations to an algorithm like this instead of variance? Or is there another optimizer that would be better?

So I got the idea from Blue's Beta tool and something else I stumbled upon to meet my needs for an algorithm I want to attempt to use in the contest but can't because beta is too high.

My algo is a framework of separate algorithms that each return a portfolio weight (sub-portfolios), which are then combined and ordered with some fancy ordering logic into a total portfolio. So my intent is for for this code is to function in the following way:

  1. It calculates my total portfolio's beta
  2. It will take that number and reverse it, that will become the "target" beta of the CVXOPT
  3. The CVXOPT will look at the individual returns and betas of the ETF's I specify and optimize them to attempt to reach the target beta while not suffering too much losses.
  4. The CVXOPT will return the weights of it's sub-portfolio that will get added to the total portfolio. It has no clue what the total portfolio will be, it only makes decisions based on it the target it's given and the ETF's it's allowed to use.

So far by combining Blue's code and the markowitz optimization I think I have accomplished goals #1, #3, and #4 (code below) but I'm stuck on goal #2. I can't seem to figure out how to get CVXOPT to function in a way that I can specify a target beta. I'll be honest, I have no idea how the constraint matrices work but I'm assuming I need a new one. If this isn't the best optimizer to use then maybe someone here can show me how to use a different optimizer such as scipy.optimize() for a target beta instead of for minimum variance if that would be easier.

Clone Algorithm
Backtest from to with initial capital
Total Returns
Max Drawdown
Benchmark Returns
Returns 1 Month 3 Month 6 Month 12 Month
Alpha 1 Month 3 Month 6 Month 12 Month
Beta 1 Month 3 Month 6 Month 12 Month
Sharpe 1 Month 3 Month 6 Month 12 Month
Sortino 1 Month 3 Month 6 Month 12 Month
Volatility 1 Month 3 Month 6 Month 12 Month
Max Drawdown 1 Month 3 Month 6 Month 12 Month
# Backtest ID: 5932d30df917a2699b62e58f
There was a runtime error.