Slippage#
- class qf_lib.backtesting.execution_handler.slippage.base.Slippage(data_provider: AbstractPriceDataProvider, max_volume_share_limit: float | None = None)[source]#
Bases:
objectBase class for slippage models. It can limit the Order’s volume. This model needs to know the daily volume of the traded asset, thus it uses the data provider in order to be able to access the volume value for the day.
- Parameters:
data_provider (AbstractPriceDataProvider) – 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.
- process_orders(date: datetime, orders: Sequence[Order], no_slippage_fill_prices: Sequence[float]) Tuple[Sequence[float], Sequence[float]][source]#
Calculates fill prices and quantities for Orders. For Orders that can’t be executed (missing security price, etc.) float(“nan”) will be returned.
- Parameters:
- Returns:
sequence of fill prices (order corresponds to the order of orders provided as an argument of the method), sequence of fill order quantities
- Return type: