Position Sizer calculates how many shares fit a defined risk budget for a long stock trade. It supports three methods: a fixed percentage of equity at risk, a stop distance derived from the Average True Range, and a Kelly criterion figure computed from win rate and average win and loss.
The script applies maximum position size and sector exposure limits, names the binding constraint, and writes JSON and Markdown reports. Whole shares are the default and fractional shares are an option. It needs no API key and no packages beyond the Python standard library.
What You Get
- A final share count with position value, dollar risk and percentage of account at risk
- A JSON report and a Markdown report named position_sizer_DATE_TIME
- A comparison table across risk percentages or ATR multipliers
- The name of the binding constraint when a position or sector limit applies
- Fractional share results floored to a chosen precision when you ask for them
Common Use Cases
- Working out how many shares to buy for a given entry and stop at one percent risk
- Sizing from ATR so the stop distance follows volatility
- Checking a Kelly budget from a measured win rate and win and loss sizes
- Testing whether a new position breaches a sector concentration limit
What Makes It Unique
It stays small and predictable. The calculator uses only the standard library, floors share counts so the risk budget is never exceeded, and reports which constraint is the strictest. Its guidance recommends half Kelly, a one percent default risk and an overall portfolio heat limit, and it reminds small-account users that fractional shares leave broker minimums, spreads, fees and margin rules in place.
Under The Hood
Claude runs one Python script, position_sizer.py, from the shell with command-line arguments. The script does the arithmetic locally, calls no external service and needs no key. It writes a JSON and a Markdown report into the output folder, named with a timestamp. Claude reads a methodology reference file for context on the chosen method. If you give only a ticker, Claude may look up a price with whatever tools are available to suggest entry and stop levels.