Tool · Trading / Risk management

Position Sizing

Calculate a position size from account equity, risk tolerance, entry price, and stop price. Add a target and win rate to calculate reward-to-risk and expectancy in R.

Version 0.1.0
Access Open
API key Not required
Payment None

Human interface

Calculate a position

$
Total account equity in quote currency.
%
The API receives this as a fraction; 1% becomes 0.01.
Below entry = long. Above entry = short.

Optional metrics

Adds reward-to-risk. Must be on the profitable side of entry.
%
Adds expectancy. Requires a target price.

What it calculates

Narrow, deterministic sizing math.

Risk amount
account equity × risk fraction
Per-unit risk
| entry price − stop price |
Position size
risk amount ÷ per-unit risk
Reward-to-risk
reward per unit ÷ risk per unit
Expectancy
(win rate × R multiple) − (1 − win rate)

Trade direction

The stop determines the side.

A stop below the entry price is treated as a long trade. A stop above entry is treated as a short trade. Entry and stop cannot be equal.

If a target is supplied, it must be on the profitable side of the entry: above entry for a long trade, or below entry for a short trade. A win rate can only be supplied when a target is also present because expectancy depends on the resulting R multiple.

Developer / agent interface

The human calculator and API use the same operation.

Endpoint

POST https://www.ytonlabs.com/api/position-sizing

curl -X POST \
  https://www.ytonlabs.com/api/position-sizing \
  -H "Content-Type: application/json" \
  -d '{
    "accountSize": 10000,
    "riskPct": 0.01,
    "entryPrice": 100,
    "stopPrice": 95,
    "targetPrice": 115,
    "winRate": 0.40
  }'

Scope

What version 0.1 does not model.

Calculation output is not an executable order.

The returned position size is a mathematical result from the supplied inputs. Real orders can be constrained by factors that this version deliberately does not model.

  • Trading fees
  • Slippage
  • Bid/ask spread
  • Leverage or margin constraints
  • Exchange or venue lot-size rules
  • Available market liquidity