PositionSizer

class qf_lib.backtesting.position_sizer.position_sizer.PositionSizer(broker: Broker, data_provider: DataProvider, order_factory: OrderFactory, signals_register: SignalsRegister)[source]

Bases: object

The PositionSizer abstract class converts signals to orders with size specified.

Methods:

size_signals(signals[, use_stop_losses, ...])

Based on the signals provided, creates a list of Orders where proper sizing has been applied

size_signals(signals: List[Signal], use_stop_losses: bool = True, time_in_force: TimeInForce = TimeInForce.OPG, frequency: Optional[Frequency] = None) List[Order][source]

Based on the signals provided, creates a list of Orders where proper sizing has been applied

Parameters:
  • signals (List[Signal]) – list of signals, based on which the orders will be created

  • use_stop_losses (bool) – if true, for each MarketOrder generated for a signal, additionally a StopOrder will be created

  • time_in_force (TimeInForce) – time in force, which will be used to create the Orders based on the provided Signals

  • frequency (Frequency) – frequency of trading, further used to create Orders

  • details (StopOrders) –

  • -------------------

  • quantity (For each Market Order a Stop Order is generated if and only if the quantity in Market Order + position) –

  • close (for this ticker != 0. This means that StopOrders are not generated if the MarketOrder should completely) –

  • ticker. (the position for the) –