SquareRootMarketImpactSlippage

class qf_lib.backtesting.execution_handler.slippage.square_root_market_impact_slippage.SquareRootMarketImpactSlippage(price_impact: float, data_provider: qf_lib.data_providers.data_provider.DataProvider, max_volume_share_limit: Optional[float] = None)[source]

Bases: qf_lib.backtesting.execution_handler.slippage.base.Slippage

Slippage based on the square-root formula for market impact modelling. The price slippage is calculated by multiplying no-slippage-price by (1 + market impact), where the market impact is defined as the product of volatility, square of the volume and volatility ratio(volume traded in bar / average daily volume) and a constant value (price_impact).

The direction of the slippage is always making the price worse for the trader (it increases the price when buying and decreases when selling).

Parameters
  • price_impact (float) – factor which implies how big will be the slippage

  • data_provider (DataProvider) – DataProvider component

  • max_volume_share_limit (float, None) – number from range [0,1] which denotes how big (volume-wise) the Order can be i.e. if it’s 0.5 and a daily volume for a given asset is 1,000,000 USD, then max volume of the Order can be 500,000 USD. If not provided, no volume checks are performed.