Like cost models, using constraint models is also easy!
You simply pass instantiated models into your desired convex optimization investment strategy:
from investos.portfolio.strategy import SPO
strategy = SPO(
actual_returns = actual_returns,
...,
constraints=[
ConstraintModelA(*args, **kwargs),
ConstraintModelB(*args, **kwargs)
],
)
and that's it!
All constraint models take the following optional arguments:
InvestOS provides the following constraint models:
MaxLeverageConstraint enforces a limit on the (absolute) leverage of the portfolio.
E.g. For leverage of 2.0x, a portfolio with 100MM net value (i.e. the portfolio value if it were converted into cash, ignoring liquidation / trading costs) could have 200MM of (combined long and short) exposure.
To instantiate MaxLeverageConstraint you will need to set the following argument:
MaxShortLeverageConstraint enforces a limit on the short leverage of the portfolio.
To instantiate MaxShortLeverageConstraint you will need to set the following argument:
MaxLongLeverageConstraint enforces a limit on the long leverage of the portfolio.
To instantiate MaxLongLeverageConstraint you will need to set the following argument:
LongOnlyConstraint enforces no short positions.
LongCashConstraint enforces no short cash positions.
To instantiate LongCashConstraint you will need to set the following argument:
EqualLongShortConstraint enforces equal long and short exposure.
To instantiate EqualLongShortConstraint you will need to set the following argument:
MaxWeightConstraint enforces a limit (as a percentage) on the weight of each asset in your portfolio.
To instantiate MaxWeightConstraint you will need to set the following arguments:
MinWeightConstraint enforces a limit (as a percentage) on the weight of each asset in your portfolio.
To instantiate MinWeightConstraint you will need to set the following arguments:
If you aren't using a convex optimization based investment strategy (like SPO), constraint models don't do anything.
Next, let's explore building our own constraint models: Custom Constraint Models.