持倉規模計算是算術,不是憑感覺
Position sizing is arithmetic, not vibes
Trader Skill Pack 團隊推出免費的 Position Sizer Claude skill,按入場價、止蝕價及風險預算計算持倉規模,並在最低手數超出預算時發出警告。工具以純 Python 編寫,只用標準程式庫,可離線運作,不會下單或連接經紀商,也不使用 API key。作者提醒,計算持倉規模不能判斷交易構想是否可行,亦不能令用戶獲利。
Most trade plans I see fail before the entry is even discussed. Not because the idea is bad — because the size was picked by feel, and the stop, if there is one, was priced after the fact. Position sizing is the one part of trading that is pure arithmetic. It deserves to be done like arithmetic.
The only formula
Position size answers one question: if my stop is hit, exactly how much do I lose?
risk per unit = |entry − stop| × contract value per unit
size = risk budget ÷ risk per unit, rounded DOWN
The contract value is where people slip. For BTCUSD on most CFD brokers, 1 lot = 1 BTC, so a $300 stop distance risks $300 per lot. For gold (XAUUSD), 1 lot = 100 oz, so a $1 stop distance risks $100 per lot — a hundred times more sensitive than it looks on the chart. Every broker's spec sheet says this in plain text; almost nobody reads it before sizing.
Two rules do the heavy lifting:
- Round down, always. Rounding to nearest quietly overspends your budget half the time. A size that risks $5.40 against a $5 budget is not "about $5" — it is a broken rule with extra steps.
- The minimum lot can break you before the market does. This is the trap for small accounts, and it is the one nobody posts about.
The minimum-lot trap, with real numbers
Worked example one — BTC, entry $100,000, stop $99,700 (a $300 stop distance), max loss $3:
→ 0.01 lots, risk exactly $3.00.
Clean. The math fits the minimum lot exactly.
Worked example two — gold, entry $4,000, stop $3,992 (an $8 stop distance), max loss $5. The honest size is 0.00625 lots. The smallest size the broker allows is 0.01 lots — which risks $8, not $5. There is no compliant size for this plan. Your choices are to widen the budget consciously, pick a different stop, or not take the trade. What you cannot honestly do is click 0.01 and call it a $5 risk.
Most sizing tools round politely and stay quiet here. The one I built prints this instead:
MIN-LOT WARNING — NO COMPLIANT SIZE EXISTS FOR THIS PLAN
Minimum lot 0.01 risks $8.00 — MORE than your $5.00 cap.
Loud, specific, and before entry — which is the only time it helps.
Why a tool, and why inside Claude
I kept re-deriving this by hand and occasionally getting it wrong in exactly the ways above, so I turned the checklist into a small tool: a Claude skill file plus a plain-Python program (standard library only, no installs, works offline). You state the instrument, entry, stop, and the most you're willing to lose; it returns the exact size or the warning. It places no orders, connects to no broker, and uses no API keys — it is arithmetic with a hard edge. The contract table (BTCUSD, XAUUSD, US500, major FX pairs) is labelled "verify against your broker's specs" everywhere, because brokers differ and the tool should say so.
Honest limits: sizing math says nothing about whether a trade idea is good. It will not make anyone profitable. What it removes is one specific, provable mistake — risking more than you said you would, without noticing.
Try it
The Position Sizer is free, in full — not a crippled demo:
https://baldwinson3.gumroad.com/l/position-sizer-free
It's one of four discipline skills in the Trader Skill Pack (a risk gate that blocks any plan with no stop, an exit planner, and a journal grader that flags stacking):
https://baldwinson3.gumroad.com/l/trader-skill-pack
I'd genuinely value criticism on the minimum-lot behavior and the contract table — what instruments or edge cases would you want covered?
— The Trader Skill Pack team. We build Claude skills for trading discipline. Educational tool, not financial advice.
來源:DEV Community · dev.to