HomeInvesting & Real Estate › Position Size Calculator

Position Size Calculator

Computes how many shares (or units) to buy or short so that hitting the stop-loss loses a fixed percentage of the account, using the fixed-fractional method: risk amount divided by the risk per share.

When to use

You have an entry and stop-loss price and want the number of shares that keeps the potential loss at a chosen fraction of the account.

Do not use when: You want the mathematically optimal fraction to bet from a known edge (Kelly criterion) or the reward side of the trade (use risk-reward-ratio). Informational only; not financial advice.

Formula

risk_amount = account_size × risk_percent/100; risk_per_share = |entry_price − stop_loss_price|; shares = floor(risk_amount / risk_per_share); position_value = shares × entry_price

Fixed-fractional position sizing: the loss at the stop, not the position value, is held to a constant fraction of capital. Slippage, gaps through the stop and commissions can make the real loss larger. Informational mathematics only; not financial advice.

Inputs

ParameterTypeUnitRequiredDescription
account_sizenumberyesTotal trading capital. Range: > 0, ≤ 1000000000000
risk_percentnumber%yesShare of the account you are willing to lose if the stop is hit (commonly 0.5–2 %). Range: > 0, ≤ 100
entry_pricenumberyesPlanned entry price per share or unit. Range: > 0, ≤ 1000000000
stop_loss_pricenumberyesPrice at which the trade is exited at a loss; below the entry for a long, above it for a short. Range: ≥ 0, ≤ 1000000000

Outputs

OutputTypeUnitDescription
risk_amountnumberaccount_size × risk_percent / 100.
risk_per_sharenumber|entry_price − stop_loss_price|.
stop_distance_percentnumber%risk_per_share / entry_price × 100.
sharesintegerfloor(risk_amount / risk_per_share).
position_valuenumbershares × entry_price.
position_percent_of_accountnumber%position_value / account_size × 100 (above 100 % requires leverage).
actual_risk_amountnumbershares × risk_per_share.
directionstringLong when the stop is below the entry, short when above.

Example

50,000 account, 1 % risk, entry 100, stop 95: {"account_size":50000,"risk_percent":1,"entry_price":100,"stop_loss_price":95}{"risk_amount":500,"risk_per_share":5,"stop_distance_percent":5,"shares":100,"position_value":10000,"position_percent_of_account":20,"actual_risk_amount":500,"direction":"Long (stop-loss below entry)"}

Short: 20,000 account, 2 % risk, entry 40, stop 42: {"account_size":20000,"risk_percent":2,"entry_price":40,"stop_loss_price":42}{"risk_amount":400,"risk_per_share":2,"shares":200,"position_value":8000,"position_percent_of_account":40,"direction":"Short (stop-loss above entry)"}

GET https://tttkmbb.com/api/v1/calculate/position-sizing?account_size=50000&risk_percent=1&entry_price=100&stop_loss_price=95

Machine access

Sources

FAQ

Why is the share count rounded down?

Rounding up would risk more than the chosen percentage; flooring keeps the actual risk at or below the target, which actual_risk_amount reports.

What if the position is larger than the account?

A tight stop can imply a position above 100 % of capital; that requires margin and the calculator flags it in the position percentage rather than capping it.

Related calculators