pybroker.slippage module

Implements slippage models.

class RandomSlippageModel(min_pct: float, max_pct: float)[source]

Bases: SlippageModel

Implements a simple random slippage model.

Parameters:
  • min_pct – Min percentage of slippage.

  • max_pct – Max percentage of slippage.

apply_slippage(ctx: ExecContext, buy_shares: Decimal | None = None, sell_shares: Decimal | None = None)[source]

Applies slippage to ctx.

class SlippageModel[source]

Bases: ABC

Base class for implementing a slippage model.

abstract apply_slippage(ctx: ExecContext, buy_shares: Decimal | None = None, sell_shares: Decimal | None = None)[source]

Applies slippage to ctx.