Margin and Leverage Calculator
calculate_marginMargin needed to open a Forex or gold trade at a given leverage or margin percentage, and, with a balance, the free margin, margin level and the prices of the margin call and stop out. Same calculation as the Margin and Leverage Calculator page at https://forexdemo.com/forex-margin-calculator.html. Every input is optional unless marked required; left-out inputs use the page's defaults, which are listed in the reply.
Tool call template
This tool declares no required parameters. Add optional parameters from the input schema as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {},
"name": "calculate_margin"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| pair | No | Currency pair or gold (XAU/USD). EURUSD and eur-usd are accepted too. | EUR/USD |
| rate | No | Only needed when the account currency is not in the pair: the price of the market pair that converts it (for example the GBP/USD price for EUR/GBP in a USD account). Leave it out to use the example price. | |
| side | No | buy (long) or sell (short). | buy |
| size | No | Trade size, counted in sizeUnit. | |
| price | No | Pair price when the trade opens. Leave it out to use the example price. | |
| balance | No | Optional account balance, for free margin, margin level and margin call prices. | |
| currency | No | The currency the trading account is held in. | USD |
| leverage | No | Leverage, such as 30 or 1:30. | 50 |
| sizeUnit | No | How the size is given: standard (100,000 units), mini (10,000), micro (1,000), nano (100) lots, or units. | standard |
| marginMode | No | leverage: give leverage. percent: give the margin requirement as a percentage. | leverage |
| stopOutLevel | No | Stop out level in percent. | |
| marginPercent | No | Margin requirement in percent (marginMode percent). Give 2 for 2%. | |
| marginCallLevel | No | Margin call level in percent. |