Forex Swap Calculator
calculate_swapOvernight swap (rollover) cost or credit of holding a Forex position, night by night including the triple day, from the swap rates a platform shows. Same calculation as the Forex Swap Calculator page at https://forexdemo.com/forex-swap-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
Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {
"long": "<long>",
"short": "<short>"
},
"name": "calculate_swap"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| long | Yes | Swap long (for buys), exactly as the platform shows it, in swapUnit. A charge has a minus sign, such as -9.17. | |
| pair | No | Currency pair, such as EUR/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). Required when neither currency of the pair is the account currency. | |
| side | No | buy (long) or sell (short). | buy |
| size | No | Trade size, counted in sizeUnit. | |
| price | No | Pair price. Needed for percent swaps, base-currency money swaps, and when the account currency is the pair's first currency. | |
| short | Yes | Swap short (for sells), exactly as the platform shows it, in swapUnit. | |
| nights | No | Nights the trade is held. | |
| balance | No | Optional account balance, for effective leverage. | |
| openDay | No | Day the trade is opened. | Monday |
| currency | No | The currency the trading account is held in. | USD |
| sizeUnit | No | lots (100,000 units each) or units. | lots |
| swapUnit | No | The unit the platform shows the swap in: points (MetaTrader), pips, percent a year, or money per standard lot per night. | points |
| precision | No | Only for points: fractional when prices have 5 decimals (3 for yen pairs), whole when they have 4 (2 for yen pairs). | fractional |
| tripleDay | No | The night that counts three days of interest. Usually Wednesday (Thursday for USD/CAD at some brokers). | Wednesday |
| yearBasis | No | Only for percent: the number of days in the broker's interest year. | 365 |
| amountCurrency | No | Only for money: the currency the swap amounts are in. | quote |