Position Sizing
risk_position_sizeFixed-fractional position sizing — a local calculation, not a data-provider lookup. Given account_size, risk_percent, entry and stop, returns position size in units, notional, implied leverage, stop distance, and — if a target is given — the reward:risk ratio. Direction (long/short) is inferred from the stop's side of entry. Deterministic: same inputs always give the same result.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| stop | Yes | Stop-loss price (below entry = long, above = short) | |
| entry | Yes | Planned entry price | |
| target | No | Optional take-profit price, used only to report reward:risk | |
| account_size | Yes | Total account equity in USD | |
| risk_percent | Yes | Percent of the account to risk if the stop is hit, e.g. 1 for 1% |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| warnings | No | ||
| direction | Yes | long or short, inferred from the stop's side of entry | |
| riskAmountUsd | Yes | Risk budget, USD | |
| riskPerUnitUsd | No | Risk per unit (|entry-stop|), USD | |
| impliedLeverage | No | Notional / account equity as a multiple (3.5 = 3.5x) | |
| rewardRiskRatio | No | Reward:risk ratio; omitted when no target was given | |
| stopDistancePct | No | Stop distance from entry in percentage points | |
| positionSizeUnits | Yes | Position size in base-asset units | |
| positionNotionalUsd | Yes | Position notional, USD |