InitialRiskWithVolumePositionSizer
- class qf_lib.backtesting.position_sizer.initial_risk_with_volume_position_sizer.InitialRiskWithVolumePositionSizer(broker: Broker, data_provider: DataProvider, order_factory: OrderFactory, signals_register: SignalsRegister, initial_risk: float, max_target_percentage: float = None, tolerance_percentage: float = 0.0, max_volume_percentage: float = 1.0)[source]
Bases:
InitialRiskPositionSizer
Variant of initial risk position sizer, which additionally controls the target size based on the mean daily volume.
- Parameters:
broker (Broker) –
data_provider (DataProvider) –
order_factory (OrderFactory) –
initial_risk (float) – should be set once for all signals. It corresponds to the value that we are willing to lose on single trade. For example: initial_risk = 0.02, means that we are willing to lose 2% of portfolio value in single trade
max_target_percentage (float) – max leverage that is accepted by the position sizer. if None, no max_target_percentage is used.
tolerance_percentage (float) – percentage used by OrdersFactory target_percent_orders function; it defines tolerance to the target percentages
max_volume_percentage (float) – percentage used to cap the target value, so that according to historical volume data, the position will not exceed max_volume_percentage * mean volume within last 100 days