Using Off-The-Shelf Cost Models


Using cost models is simple!

You simply pass instantiated cost model instances into your desired investment strategy:

from investos.portfolio.strategy import YourDesiredStrategy

strategy = YourDesiredStrategy(
    actual_returns = actual_returns,
        CostModelA(*args, **kwargs),
        CostModelB(*args, **kwargs)

and that's it!

Optional Arguments

All cost models take the following optional arguments:

  • exclude_assets: [str]
  • include_assets: [str]
    • Can't be used with exclude_assets
  • gamma: float = 1
    • Gamma doesn't impact actual costs
    • Gamma only (linearly) increases estimated costs during convex optimization trade list generation
    • If you aren't using a convex optimization investment strategy, gamma does nothing

InvestOS provides the following cost models:


ShortHoldingCost calculates per period cost for holding short positions, given customizable short_rate.

To instantiate ShortHoldingCost you will need to set the following arguments:

  • short_rates: pd.DataFrame | pd.Series | float,


TradingCost calculates per period cost for trades based on forecast spreads, standard deviations, volumes, and actual prices.

To instantiate TradingCost you will need to set the following arguments:

  • forecast_volume: pd.DataFrame | pd.Series,
  • forecaststddev: pd.DataFrame | pd.Series,
  • actual_prices: pd.DataFrame,
  • sensitivity_coeff: float = 1
    • For scaling transaction cost from market impact
    • 1 assumes trading 1 day's volume moves asset price by 1 forecast standard deviation in returns
  • half_spread: pd.DataFrame | pd.Series | float
    • Half of forecast spread between bid and ask for each asset
    • This model assumes half_spread represents the cost of executing a trade

Next: The Choice Is Yours

Want to explore creating your own custom cost model? Check out Custom Cost Models.

Want to learn more about using constraint models? Check out Constraint Models.