investos.portfolio.constraint_model package

Submodules

investos.portfolio.constraint_model.base_constraint module

class investos.portfolio.constraint_model.base_constraint.BaseConstraint(**kwargs)

Bases: object

Base class for constraint objects used in convex portfolio optimization strategies.

Subclass BaseConstraint, and create your own weight_expr method to create custom constraints.

metadata_dict()
weight_expr(t, w_plus, z, v, asset_idx)

investos.portfolio.constraint_model.leverage_constraint module

class investos.portfolio.constraint_model.leverage_constraint.MaxLeverageConstraint(limit: float = 1.0, exclude_assets=['cash'], **kwargs)

Bases: BaseConstraint

A constraint that 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.

class investos.portfolio.constraint_model.leverage_constraint.MaxLongLeverageConstraint(limit: float = 1.0, exclude_assets=['cash'], **kwargs)

Bases: BaseConstraint

A constraint that enforces a limit on the long leverage of the portfolio.

class investos.portfolio.constraint_model.leverage_constraint.MaxShortLeverageConstraint(limit: float = 1.0, exclude_assets=['cash'], **kwargs)

Bases: BaseConstraint

A constraint that enforces a limit on the short leverage of the portfolio.

investos.portfolio.constraint_model.weight_constraint module

class investos.portfolio.constraint_model.weight_constraint.MaxWeightConstraint(limit: float = 0.025, exclude_assets=['cash'], **kwargs)

Bases: BaseConstraint

A constraint that enforces a limit on the weight of each asset in a portfolio.

Parameters:
  • limit (float, optional) – The maximum weight of each asset in the portfolio. Defaults to 0.05.

  • **kwargs – Additional keyword arguments.

weight_expr(self, t, w_plus, z, v):

Returns a series of holding constraints based on the portfolio weights after trades.

class investos.portfolio.constraint_model.weight_constraint.MinWeightConstraint(limit: float = -0.025, exclude_assets=['cash'], **kwargs)

Bases: BaseConstraint

A constraint that enforces a limit on the weight of each asset in a portfolio.

Parameters:
  • limit (float, optional) – The minimum weight of each asset in the portfolio. Defaults to -0.05.

  • **kwargs – Additional keyword arguments.

weight_expr(self, t, w_plus, z, v):

Returns a series of holding constraints based on the portfolio weights after trades.

investos.portfolio.constraint_model.trade_constraint module

class investos.portfolio.constraint_model.long_constraint.EqualLongShortConstraint(exclude_assets=['cash'], **kwargs)

Bases: BaseConstraint

A constraint that enforces equal long and short exposure.

Parameters:

**kwargs – Additional keyword arguments.

class investos.portfolio.constraint_model.long_constraint.LongCashConstraint(include_assets=['cash'], **kwargs)

Bases: BaseConstraint

A constraint that enforces no short cash positions.

Parameters:

**kwargs – Additional keyword arguments.

class investos.portfolio.constraint_model.long_constraint.LongOnlyConstraint(**kwargs)

Bases: BaseConstraint

A constraint that enforces no short positions. Including no short cash position.

Parameters:

**kwargs – Additional keyword arguments.