Skip to content

RiskBased


class backtide.sizers.RiskBased(risk_pct)

Size based on acceptable risk and stop loss distance.

Computes quantity = (equity * risk_pct) / stop_distance. Industry standard approach: you define how much equity you're willing to lose and the distance to your stop, and the sizer works backwards. Requires stop_distance to be passed to calculate().

Parameters

risk_pct : float

Fraction of equity at risk per trade (e.g. 0.01 for 1%).


See Also

BaseSizer

Abstract base class for all position sizers.

KellyCriterion

Kelly Criterion sizing.

VolatilityScaled

Size based on volatility (ATR).


Methods

calculate Calculate the order quantity for this sizer.


method backtide.sizerscalculate(equity, price, stop_distance=None, atr=None)

Calculate the order quantity for this sizer.

Parameters

equity : float

Current portfolio equity in the same currency as price. When a sizer is attached to an order, the engine passes equity converted to that instrument's quote currency.

price : float
Reference price of the instrument.

stop_distance : float | None, default=None
Distance from entry to stop loss, in price units.

atr : float | None, default=None
Current ATR value. Required for volatility-based sizers.

Returns

int | float

The number of units to trade. Positive for buys, negative for sells.