Skip to main content

position-sizing-data

Reference data and arithmetic for risk-based position sizing across forex, stocks and crypto futures.

The same tables are published as a citable dataset: doi:10.5281/zenodo.22840538, and used by the web calculator at https://positionsizetool.com/. Source repository: https://github.com/tk25719/position-sizing-data.

Install

pip install position-sizing-data

What is in it

Function Returns
contract_specifications() Pip size, contract size and minimum unit step for 131 instruments, across forex pairs, metals, energies, indices, crypto futures, stocks and ETFs.
pip_values() Pip value and the loss on a 20 pip move for standard, mini, micro and nano lots.
losing_streak_equity() Equity remaining after 1 to 20 consecutive losses at 0.5%, 1% and 2% risk per trade.
drawdown_recovery() Gain required on the reduced balance to return to the original balance, for drawdowns from 5% to 90%.
position_size(...) The risk-to-units calculation itself.

Read the tables:

from position_sizing_data import contract_specifications

rows = contract_specifications()
print(rows[0])

Compute a size:

from position_sizing_data import position_size

result = position_size(
    balance=10000.0,
    risk_percent=1.0,
    entry=1.1000,
    stop=1.0980,
    unit_step=1000.0,   # 0.01 lot
)
print(result)
# {'risk_budget': 100.0, 'units': 50000.0, 'tradable_units': 50000.0, 'worst_case_loss': 100.0}

The formula

units = (risk_budget - commission) / ((|entry - stop| + spread) x quote_rate)

The tradable size is that number rounded down to unit_step. position_size returns the worst-case loss recomputed from the rounded size, which is what the account actually loses when the stop is hit.

Where the numbers come from

The rows in contract_specifications() are typical retail contract specifications, not exchange-published official values. Verify the contract size and unit step against your own broker before placing an order. The other three tables are closed-form arithmetic:

  • losing streak: remaining = (1 - risk)^n
  • drawdown recovery: gain_required = 1 / (1 - drawdown) - 1
  • pip value: pip_value = units x pip_size

Licence

MIT for the code. Data files are CC0 1.0 Universal, to the extent applicable. This is not investment advice.

Metadata

Release files for position-sizing-data 0.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for position-sizing-data 0.1.1
File Size Uploaded
position_sizing_data-0.1.1.tar.gz 8.9 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for position-sizing-data 0.1.1
File Interpreter ABI Platform
position_sizing_data-0.1.1-py3-none-any.whl Python 3 none any Details

Total release size: 16.6 kB

Release files / position_sizing_data-0.1.1.tar.gz

Download URL position_sizing_data-0.1.1.tar.gz
Size 8.9 kB
Tags Source
SHA-256 checksum
How to use checksums
e754c4e89905867827fe49ac3ca1fe9f5334dd304792ec6f7df46c94c4a4aed3
BLAKE2b-256 checksum
How to use checksums
1ec81a2abb25629719bf844ad310a935a299c91078d7c3f3fd41882f10d16afb
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 19, 2026.

Transparency log

Release files / position_sizing_data-0.1.1-py3-none-any.whl

Download URL position_sizing_data-0.1.1-py3-none-any.whl
Size 7.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
fd9c6d50e5ff676fcc2bee121516ccbf372617cdfe852e9488046ae27a94e899
BLAKE2b-256 checksum
How to use checksums
e2da20e0680fea632f22b1b5765117eab341295902fbb76d63dca81fe00bf950
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 19, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

0.1.1 This release

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page