Using Off-The-Shelf Constraint Models

Usage

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!

Optional Arguments

All constraint models take the following optional arguments:

  • exclude_assets: [str]
  • include_assets: [str]
    • Can't be used alongside exclude_assets

InvestOS provides the following constraint models:

Factor Constraints, Portfolio

ZeroFactorExposureConstraint

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

MaxFactorExposureConstraint enforces max portfolio weight in a given factor.

Instantiate with the following arguments:

  • limit: float = 0.05
  • factor_exposure: pd.DataFrame (asset ID columns and datetime index) or pd.Series (asset ID index, if same value across datetime)

MinFactorExposureConstraint

MinFactorExposureConstraint enforces min portfolio weight in a given factor.

Instantiate with the following arguments:

  • limit: float = -0.05
  • factor_exposure: pd.DataFrame (asset ID columns and datetime index) or pd.Series (asset ID index, if same value across datetime)

MaxAbsoluteFactorExposureConstraint

MaxAbsoluteFactorExposureConstraint enforces max absolute portfolio weight in a given factor.

Instantiate with the following arguments:

  • limit: float = 0.4
  • factor_exposure: pd.DataFrame (asset ID columns and datetime index) or pd.Series (asset ID index, if same value across datetime)

Factor Constraints, Trade

ZeroTradeFactorExposureConstraint

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

MaxTradeFactorExposureConstraint enforces max trade weight in a given factor.

Instantiate with the following arguments:

  • limit: float = 0.05
  • factor_exposure: pd.DataFrame (asset ID columns and datetime index) or pd.Series (asset ID index, if same value across datetime)

MinTradeFactorExposureConstraint

MinTradeFactorExposureConstraint enforces min trade weight in a given factor.

Instantiate with the following arguments:

  • limit: float = -0.05
  • factor_exposure: pd.DataFrame (asset ID columns and datetime index) or pd.Series (asset ID index, if same value across datetime)

MaxAbsoluteTradeFactorExposureConstraint

MaxAbsoluteTradeFactorExposureConstraint enforces max absolute trade weight in a given factor.

Instantiate with the following arguments:

  • limit: float = 0.01
  • factor_exposure: pd.DataFrame (asset ID columns and datetime index) or pd.Series (asset ID index, if same value across datetime)

Leverage Constraints, Portfolio

MaxLeverageConstraint

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:

  • limit: float = 1.0

MaxShortLeverageConstraint

MaxShortLeverageConstraint enforces a limit on the short leverage of the portfolio.

To instantiate MaxShortLeverageConstraint you will need to set the following argument:

  • limit: float = 1.0

MaxLongLeverageConstraint

MaxLongLeverageConstraint enforces a limit on the long leverage of the portfolio.

To instantiate MaxLongLeverageConstraint you will need to set the following argument:

  • limit: float = 1.0

Leverage Constraints, Trade

MaxLongTradeLeverageConstraint

MaxLongTradeLeverageConstraint enforces a max on the long leverage of the trade.

Instantiate with the following arguments:

  • limit: float = 0.025

MaxShortTradeLeverageConstraint

MaxShortTradeLeverageConstraint enforces a max on the short leverage of the trade.

Instantiate with the following arguments:

  • limit: float = 0.025

Long Constraints, Portfolio

LongOnlyConstraint

LongOnlyConstraint enforces no short positions.

LongCashConstraint

LongCashConstraint enforces no short cash positions.

To instantiate LongCashConstraint you will need to set the following argument:

  • include_assets: [str] = ["cash"]

EqualLongShortConstraint

EqualLongShortConstraint enforces equal long and short exposure.

To instantiate EqualLongShortConstraint you will need to set the following argument:

  • exclude_assets: [str] = ["cash"]

Turnover Constraints, Trade

MaxAbsTurnoverConstraint

MaxAbsTurnoverConstraint enforces an absolute (trade) turnover weight limit.

Instantiate with the following arguments:

  • limit: float = 0.05

Weight Constraints, Portfolio

MaxWeightConstraint

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:

  • limit: float = 0.025
  • exclude_assets: [str] = ["cash"]

MinWeightConstraint

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:

  • limit: float = -0.025
  • exclude_assets: [str] = ["cash"]

ZeroWeightConstraint

ZeroWeightConstraint enforces zero portfolio weight for included assets.

Instantiate with the following arguments:

  • include_assets: [str] = ["TBU"]

Weight Constraints, Trade

ZeroTradeWeightConstraint

ZeroTradeWeightConstraint enforces zero trade weight for included/excluded assets.

Instantiate with the following arguments:

  • include_assets: [str] = ["TBU"]

MaxTradeWeightConstraint

MaxTradeWeightConstraint enforces max trade weight for included/excluded assets.

Instantiate with the following arguments:

  • limit: float = 0.05

MinTradeWeightConstraint

MinTradeWeightConstraint enforces min trade weight for included/excluded assets.

Instantiate with the following arguments:

  • limit: float = -0.03

A Quick Note

If you aren't using a convex optimization based investment strategy (like SPO), constraint models don't do anything.

Next: Custom Constraint Models

Next, let's explore building our own constraint models: Custom Constraint Models.