Skip to content

contango.strategy.rule_based.position_sizers.fixed_position_sizer

contango.strategy.rule_based.position_sizers.fixed_position_sizer

FixedPositionSizer

FixedPositionSizer(fixed_units: int)

Bases: PositionSizer[TradingContext]

A position sizer with a fixed amount of units.

Initializes `FixedPositionSizer.

Parameters:

Name Type Description Default
fixed_units int

The unchanging amount of units to order for every trade.

required
Source code in src\contango\strategy\rule_based\position_sizers\fixed_position_sizer.py
11
12
13
14
15
16
17
18
def __init__(self, fixed_units: int) -> None:
    """
    Initializes `FixedPositionSizer.

    Args:
        fixed_units: The unchanging amount of units to order for every trade.
    """
    self._fixed_units = fixed_units

size

size(context: TradingContext) -> int

Returns the fixed size set during initialization.

Source code in src\contango\strategy\rule_based\position_sizers\fixed_position_sizer.py
20
21
22
23
24
def size(self, context: TradingContext) -> int:
    """
    Returns the fixed size set during initialization.
    """
    return self._fixed_units