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:
ZeroFactorExposureConstraint enforces 0 net portfolio weight in a given factor.
Instantiate with the following arguments:
factor_exposure
: pd.DataFrame (asset ID columns and datetime index) or pd.Series (asset ID index, if same value across datetime)MaxFactorExposureConstraint enforces max portfolio weight in a given factor.
Instantiate with the following arguments:
factor_exposure
: pd.DataFrame (asset ID columns and datetime index) or pd.Series (asset ID index, if same value across datetime)MinFactorExposureConstraint enforces min portfolio weight in a given factor.
Instantiate with the following arguments:
factor_exposure
: pd.DataFrame (asset ID columns and datetime index) or pd.Series (asset ID index, if same value across datetime)MaxAbsoluteFactorExposureConstraint enforces max absolute portfolio weight in a given factor.
Instantiate with the following arguments:
factor_exposure
: pd.DataFrame (asset ID columns and datetime index) or pd.Series (asset ID index, if same value across datetime)ZeroTradeFactorExposureConstraint enforces 0 net trade weight in a given factor.
Instantiate with the following arguments:
factor_exposure
: pd.DataFrame (asset ID columns and datetime index) or pd.Series (asset ID index, if same value across datetime)MaxTradeFactorExposureConstraint enforces max trade weight in a given factor.
Instantiate with the following arguments:
factor_exposure
: pd.DataFrame (asset ID columns and datetime index) or pd.Series (asset ID index, if same value across datetime)MinTradeFactorExposureConstraint enforces min trade weight in a given factor.
Instantiate with the following arguments:
factor_exposure
: pd.DataFrame (asset ID columns and datetime index) or pd.Series (asset ID index, if same value across datetime)MaxAbsoluteTradeFactorExposureConstraint enforces max absolute trade weight in a given factor.
Instantiate with the following arguments:
factor_exposure
: pd.DataFrame (asset ID columns and datetime index) or pd.Series (asset ID index, if same value across datetime)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:
MaxLongTradeLeverageConstraint enforces a max on the long leverage of the trade.
Instantiate with the following arguments:
MaxShortTradeLeverageConstraint enforces a max on the short leverage of the trade.
Instantiate with the following arguments:
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:
MaxAbsTurnoverConstraint enforces an absolute (trade) turnover weight limit.
Instantiate with the following arguments:
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:
ZeroWeightConstraint enforces zero portfolio weight for included assets.
Instantiate with the following arguments:
ZeroTradeWeightConstraint enforces zero trade weight for included/excluded assets.
Instantiate with the following arguments:
MaxTradeWeightConstraint enforces max trade weight for included/excluded assets.
Instantiate with the following arguments:
MinTradeWeightConstraint enforces min trade weight for included/excluded assets.
Instantiate with 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.