Size

forge.signalsclassSince Forge API 1
Signaturepython
forge.signals.Size(*,kind: str,note: str | None = None,value: float | np.ndarray | None = None,annual: float | None = None,lookback: int | None = None,round: str = 'down') -> None

How much each entry trades. Build one with a constructor, like fg.Size.risk_pct(1.0).

Parameters

NameTypeDefault
kindstr
notestr | NoneNone
valuefloat | np.ndarray | NoneNone
annualfloat | NoneNone
lookbackint | NoneNone
roundstr'down'

Members

NameSignatureSummary
fixed_margin(value: float, *, round: str = 'down', note: str | None = None) -> SizeA position that uses this much margin, in the account currency.
lots(value: float | np.ndarray, *, round: str = 'down', note: str | None = None) -> SizeA fixed number of lots, or one number per bar.
notional(value: float, *, round: str = 'down', note: str | None = None) -> SizeA position of this value, in the account currency.
pct_equity(value: float, *, round: str = 'down', note: str | None = None) -> SizeA position worth this percent of the account's equity.
risk_cash(value: float, *, round: str = 'down', note: str | None = None) -> SizeRisk this much money, in the account currency, on each trade.
risk_pct(value: float, *, round: str = 'down', note: str | None = None) -> SizeRisk this percent of the account on each trade, from the entry to the stop.
units(value: float | np.ndarray, *, round: str = 'down', note: str | None = None) -> SizeA fixed number of units of the instrument, or one number per bar.
vol_target(annual: float, *, lookback: int = 20, round: str = 'down', note: str | None = None) -> SizeSize so the position's yearly volatility is this fraction of the account, like 0.1.

lots and units take a number or one per bar. The risk methods size the entry so the stop loses that much, so they need a stop. round is "down" (the default, never above the amount) or "nearest", to the broker's lot step.