Long/Short Gross-Net Constraints
Install and import#
npm install fintech-algorithmsimport { optimizeGrossNetConstrained } from "fintech-algorithms/portfolio-construction/practical-constraints/long-short-gross-net-constraints";Signature#
optimizeGrossNetConstrained(mu, covariance, lambdaRisk, netMin, netMax, grossMax, options)Computes long, short, net, and gross exposure from signed weights, checks a net interval and gross cap, and solves the mean-variance problem under both.
Parameters#
| Name | Type | Notes |
|---|---|---|
mu | unknown | |
covariance | unknown | |
lambdaRisk | unknown | |
netMin | unknown | |
netMax | unknown | |
grossMax | unknown | |
options | GrossNetOptions | optional |
Worked example#
executed Captured by running this function on the input its own test provides. Real output of real code — but not asserted against a published figure.
Input#
[0.2, 0.04][
[0.04, 0],
[0, 0.01]
]1111.6{}Call#
optimizeGrossNetConstrained(mu, covariance, lambdaRisk, netMin, netMax, grossMax, options)Returns#
object with 9 fields: status, weights, objective, exposures, constraints, minimalSplit, enumeratedStates, totalStates, …
{
"status": "optimal",
"weights": [1.3, -0.30000000000000004],
"objective": 0.1795,
"exposures": {
"long": 1.3,
"short": 0.30000000000000004,
"net": 1,
"gross": 1.6,
"identityResidual": 0
},
"constraints": {
"exposures": {
"long": 1.3,
"short": 0.30000000000000004,
"net": 1,
"gross": 1.6,
"identityResidual": 0
},
"netLower": {
"bound": 1,
"residual": 0,
"satisfied": true
},
"netUpper": {
"bound": 1,
"residual": 0,
"satisfied": true
},
"grossCap": {
"bound": 1.6,
"residual": 0,
"satisfied": true
},
"minimumFeasibleGross": 1,
"boundsCompatible": true,
"feasible": true
},
"minimalSplit": {
"longPart": [1.3, 0],
"shortPart": [0, 0.30000000000000004],
"sum": 1.6
},
"enumeratedStates": 54,
"totalStates": 54,
"certificate": {
"kind": "exhaustive-orthant-active-set",
"complete": true,
"continuousKkt": true,
"kktResidual": 1.8070036208091741e-16,
"grossFromSignedWeights": true,
"globalOptimality": "every orthant and every active set of its concave subproblem was checked"
}
}Other exports#
This module also exports
signedExposures, exposureMeasures, portfolioVariance, checkExposureConstraints, minimalSplit, auditAuxiliarySplit, canonicalExample. Every module additionally exports run as an alias of its
primary function, and a meta object carrying its catalog id, domain, family,
shape and article URL.
Diagrams#
How it works#
This page states the contract — how to call it correctly. The article explains the concept: why it works, and where it breaks.
References#
- Input data preparation
- Transaction costs