What are you trying to do?
I have a table of asset class scores that I am trying to add various constraints from. However, some of these scores are only applicable to certain asset classes. For example, 'Duration' would have values for Bond sectors, but are 'NaN' for Equity sectors. I don't want to use 0s for equities, as any equity allocation would understate the calculated duration of the total bonds.
Score Duration
Sector
Bond A 30 10.0
Bond B 40 5.0
Equity A 50 NaN
Equity B 60 NaN
ef.add_constraint(lambda w: Constraint['Duration'].values @ w >= 0)
ef.add_constraint(lambda w: Constraint['Duration'].values @ w <= 7)
Error message:
ERROR in LDL_factor: Error in KKT matrix LDL factorization when computing the nonzero elements. The problem seems to be non-convex
ERROR in osqp_setup: KKT matrix factorization.
The problem seems to be non-convex.
...
SolverError: Workspace allocation error!
Add custom constraints that would take a weighted average of the Duration ignoring sectors with 'NaN'. The np.nansum() functions work outside these constraint definitions when I try calculating the portfolio Duration scores given a weight vector.
C:\ProgramData\anaconda3\Lib\site-packages\cvxpy\expressions\expression.py:621: UserWarning:
This use of ``*`` has resulted in matrix multiplication.
Using ``*`` for matrix multiplication has been deprecated since CVXPY 1.1.
Use ``*`` for matrix-scalar and vector-scalar multiplication.
Use ``@`` for matrix-matrix and matrix-vector multiplication.
Use ``multiply`` for elementwise multiplication.
...
Exception: Cannot evaluate the truth value of a constraint or chain constraints, e.g., 1 >= x >= 0.
What data are you using?
See example below. The code is working for me with the basic 'Score' constraint, but fails when I tried adding either 'Duration' constraint from above.
What are you trying to do? I have a table of asset class scores that I am trying to add various constraints from. However, some of these scores are only applicable to certain asset classes. For example, 'Duration' would have values for Bond sectors, but are 'NaN' for Equity sectors. I don't want to use 0s for equities, as any equity allocation would understate the calculated duration of the total bonds.
What have you tried? I have tried the following:
Error message:
Error message:
What data are you using? See example below. The code is working for me with the basic 'Score' constraint, but fails when I tried adding either 'Duration' constraint from above.