Skip to content

Position Sizers

Positon sizers are crucial for managing risk and optimising your returns in trading. They determine how much capital to allocate to each trade based on various factors such as risk tolerance, account size, and market conditions.

Of course, the naive way to size a position in Dejavu is to use the buy() and sell() methods without any arguments, which will default to buying or selling one unit of the asset. However, this approach does not take into account the size of your account or the risk associated with the trade.

Here are some common types of position sizers:

dejavu.strategy.sizers.fixed.FixedUnits

Bases: PositionSizer

This is the most basic position sizer, and it simply allocates a fixed number of units per trade, regardless of price or portfolio size.

__init__(units=100)

Parameters:

Name Type Description Default
units float

Number of units to trade. Defaults to 100.

100

dejavu.strategy.sizers.fixed.FixedDollar

Bases: PositionSizer

Similar to FixedUnits, this is a basic position sizer, and it simply allocates how much capital (money) to allocate to a single trade.

__init__(dollar_amount=5000)

Parameters:

Name Type Description Default
dollar_amount float

Number of dollars to allocate to the trade. Defaults to $5,000.

5000

dejavu.strategy.sizers.risk.PercentRisk

Bases: PositionSizer

Risk a fixed % of equity per trade. Requires a stop_distance kwarg (e.g. 1 ATR or a fixed $ stop).

qty = (equity * risk_pct) / stop_distance

__init__(risk_pct=0.01)

Parameters:

Name Type Description Default
risk_pct float

percentage of total portfolio equity to risk per trade (e.g. 0.01 for 1%)

0.01