position_size
Calculate how many lots to buy from your entry price, stop loss, and risk amount. See the position value, actual risk after flooring, round-trip commissions, break-even price, and 1R/2R/3R targets.
Instructions
How many lots to buy, given what you are willing to lose. Pure arithmetic — it reads no account, checks no buying power, and places nothing.
Give entry_price, stop_price (which must be BELOW the entry — IDX retail has no short selling), and EITHER risk_idr OR account_idr with risk_pct. Not both: they can disagree.
Lots are floored, never rounded up, so the risk is at most the number you gave. Returns the position value, what is actually at risk after flooring, the round-trip commission, the break-even price with commission included, and 1R/2R/3R targets on the tick grid.
It CHECKS that entry and stop sit on the IDX price grid — an off-grid limit is rejected by the exchange rather than rounded — and, if you pass ara and arb from price_bands, that neither is outside today's auto-rejection band.
Commission defaults to the published retail rate (0.15% / 0.25%) and feeSource says so; pass fee_buy_pct and fee_sell_pct, or read them from trading_info, for this account's.
This is a plan, not a permission. Use order_preview for the real checks — buying power, tradability, and the caps in the trading policy.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| ara | No | Today's ceiling, from price_bands. | |
| arb | No | Today's floor, from price_bands. | |
| max_lots | No | Never suggest more lots than this. | |
| risk_idr | No | Rupiah you are willing to lose. Or use account_idr + risk_pct. | |
| risk_pct | No | Percent of the account to risk, e.g. 1. | |
| stop_price | Yes | Where you would get out. Must be below entry_price. | |
| account_idr | No | Account value, with risk_pct. | |
| entry_price | Yes | Limit price you would buy at, in IDR. | |
| fee_buy_pct | No | Buy commission percent. Default 0.15. | |
| fee_sell_pct | No | Sell commission percent. Default 0.25. |