calculate_position_size
Calculate how many units to trade based on your capital, risk percentage, entry price, and stop-loss to ensure losses stay within your risk tolerance.
Instructions
Calculates position size based on your capital, risk tolerance, entry price, and stop-loss. Determines how many units to buy or sell so that a stop-loss hit costs exactly risk_pct% of capital. Fully client-side — no API call is made. Example: 'How many BTC can I buy on BTC-CLP if I have 1,000,000 CLP, risk 2%, entry 80,000,000 CLP, stop at 78,000,000 CLP?'
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| market_id | Yes | Market ID (e.g. 'BTC-CLP', 'ETH-COP'). Used to derive the quote currency. | |
| capital | Yes | Total available capital in the quote currency (e.g. CLP for BTC-CLP). | |
| risk_pct | Yes | Percentage of capital to risk on this trade (0.1–10, e.g. 2 = 2%). | |
| entry_price | Yes | Planned entry price in quote currency. | |
| stop_loss_price | Yes | Stop-loss price in quote currency. Must be below entry for buys, above entry for sells. |