# Forex Calculator API
> Live foreign-exchange trading calculators computed from live ECB reference rates. The pip-value endpoint returns what one pip of a currency pair is worth, in the trader's account currency, for a given lot size. The position-size endpoint returns how many lots to trade to risk a fixed percentage of the account on a given stop-loss. The profit-loss endpoint returns the P&L of a trade from its entry, exit and direction. The margin endpoint returns the margin a position requires at a given leverage. All conversion to the account currency uses live exchange rates. Computed live, nothing stored. Distinct from raw FX-rate feeds — this turns rates into the pip values, position sizes, margins and P&L a trader acts on.

## Authentication
All requests require your oanor API key in the `x-oanor-key` header. Get one at https://www.oanor.com/developer/keys.

```bash
curl -H "x-oanor-key: oanor_live_…" "https://api.oanor.com/fxcalculator-api/..."
```

## Pricing
- **Free** (Free) — 4,000 calls/Mo, 3 req/s
- **Starter** ($5/Mo) — 95,000 calls/Mo, 15 req/s
- **Pro** ($17/Mo) — 460,000 calls/Mo, 40 req/s
- **Scale** ($41/Mo) — 2,800,000 calls/Mo, 120 req/s

## Endpoints

### Pip Value

#### `GET /v1/pip-value` — Pip value in the account currency

**Parameters:**
- `pair` (query, required, string) — Currency pair Example: `EURUSD`
- `lot` (query, optional, string) — Lot size (1 = standard) Example: `1`
- `account` (query, optional, string) — Account currency Example: `USD`

**Example:**
```bash
curl -H "x-oanor-key: $KEY" \
  "https://api.oanor.com/fxcalculator-api/v1/pip-value?pair=EURUSD&lot=1&account=USD"
```

**Response:**
```json
{
    "data": {
        "pair": "EUR/USD",
        "units": 100000,
        "source": "ECB (Frankfurter)",
        "lot_size": 1,
        "pip_size": 0.0001,
        "pip_value": 10,
        "rates_date": "2026-06-10",
        "account_currency": "USD",
        "pip_value_per_standard_lot": 10
    },
    "meta": {
        "timestamp": "2026-06-10T22:56:38.355Z",
        "request_id": "015bd5ed-6d1a-42d8-b846-667f086a3670"
    },
    "status": "ok",
    "message": "Pip value computed",
    "success": true
}
```

### Position Size

#### `GET /v1/position-size` — Lots to risk a % of the account

**Parameters:**
- `balance` (query, required, string) — Account balance Example: `10000`
- `risk_pct` (query, required, string) — Risk percent Example: `1`
- `stop_loss_pips` (query, required, string) — Stop-loss in pips Example: `20`
- `pair` (query, optional, string) — Currency pair Example: `EURUSD`
- `account` (query, optional, string) — Account currency Example: `USD`

**Example:**
```bash
curl -H "x-oanor-key: $KEY" \
  "https://api.oanor.com/fxcalculator-api/v1/position-size?balance=10000&risk_pct=1&stop_loss_pips=20&pair=EURUSD&account=USD"
```

**Response:**
```json
{
    "data": {
        "lots": 0.5,
        "pair": "EUR/USD",
        "units": 50000,
        "source": "ECB (Frankfurter)",
        "balance": 10000,
        "risk_pct": 1,
        "rates_date": "2026-06-10",
        "risk_amount": 100,
        "stop_loss_pips": 20,
        "account_currency": "USD",
        "pip_value_per_standard_lot": 10
    },
    "meta": {
        "timestamp": "2026-06-10T22:56:38.453Z",
        "request_id": "f125902c-a05d-468b-ae1c-6e294a2a6cf7"
    },
    "status": "ok",
    "message": "Position size computed",
    "success": true
}
```

### Profit Loss

#### `GET /v1/profit-loss` — Trade profit/loss

**Parameters:**
- `pair` (query, required, string) — Currency pair Example: `EURUSD`
- `entry` (query, required, string) — Entry price Example: `1.0850`
- `exit` (query, required, string) — Exit price Example: `1.0900`
- `lot` (query, optional, string) — Lot size Example: `1`
- `direction` (query, optional, string) — buy or sell Example: `buy`
- `account` (query, optional, string) — Account currency Example: `USD`

**Example:**
```bash
curl -H "x-oanor-key: $KEY" \
  "https://api.oanor.com/fxcalculator-api/v1/profit-loss?pair=EURUSD&entry=1.0850&exit=1.0900&lot=1&direction=buy&account=USD"
```

**Response:**
```json
{
    "data": {
        "exit": 1.09,
        "pair": "EUR/USD",
        "pips": 50,
        "entry": 1.085,
        "source": "ECB (Frankfurter)",
        "lot_size": 1,
        "direction": "buy",
        "rates_date": "2026-06-10",
        "profit_loss": 500,
        "account_currency": "USD",
        "profit_loss_quote": 500
    },
    "meta": {
        "timestamp": "2026-06-10T22:56:38.571Z",
        "request_id": "30744f47-f893-494c-89ad-eb70176b62ed"
    },
    "status": "ok",
    "message": "Profit/loss computed",
    "success": true
}
```

### Margin

#### `GET /v1/margin` — Required margin at a leverage

**Parameters:**
- `pair` (query, required, string) — Currency pair Example: `EURUSD`
- `lot` (query, optional, string) — Lot size Example: `1`
- `leverage` (query, optional, string) — Leverage (e.g. 100) Example: `100`
- `account` (query, optional, string) — Account currency Example: `USD`

**Example:**
```bash
curl -H "x-oanor-key: $KEY" \
  "https://api.oanor.com/fxcalculator-api/v1/margin?pair=EURUSD&lot=1&leverage=100&account=USD"
```

**Response:**
```json
{
    "data": {
        "pair": "EUR/USD",
        "source": "ECB (Frankfurter)",
        "leverage": 100,
        "lot_size": 1,
        "rates_date": "2026-06-10",
        "required_margin": 1153.89,
        "account_currency": "USD",
        "notional_account": 115389.5
    },
    "meta": {
        "timestamp": "2026-06-10T22:56:38.681Z",
        "request_id": "1e4f16dc-3a68-4d95-88c5-9a430f3729b0"
    },
    "status": "ok",
    "message": "Margin computed",
    "success": true
}
```

### Meta

#### `GET /v1/meta` — Service metadata

**Example:**
```bash
curl -H "x-oanor-key: $KEY" \
  "https://api.oanor.com/fxcalculator-api/v1/meta"
```

**Response:**
```json
{
    "data": {
        "note": "Standard lot = 100,000 base units; pip = 0.0001 (0.01 for JPY pairs). Supports ECB major currencies.",
        "source": "ECB rates via Frankfurter (api.frankfurter.dev, live)",
        "service": "fxcalculator-api",
        "endpoints": {
            "GET /v1/meta": "This document.",
            "GET /v1/margin": "Required margin (pair=EURUSD, lot=1, leverage=100).",
            "GET /v1/pip-value": "Pip value in the account currency (pair=EURUSD, lot=1, account=USD).",
            "GET /v1/profit-loss": "Trade P&L (pair=EURUSD, entry=1.0850, exit=1.0900, lot=1, direction=buy).",
            "GET /v1/position-size": "Lots to risk a % of the account (balance=10000, risk_pct=1, stop_loss_pips=20, pair=EURUSD)."
        },
        "rates_date": "2026-06-10",
        "description": "Live foreign-exchange trading calculators computed from live ECB reference rates. The pip-value endpoint returns what one pip of a currency pair is worth, in the trader's account currency, for a given lot size; the position-size endpoint returns how many lots to trade to risk a fixed percentage of the account on a given stop-loss; the profit-loss endpoint returns the P&L of a trade from its entry, exit and direction; the margin endpoint returns the margin a position requires at a given leverage. All conversion to the account currency uses live rates. Computed live, nothing stored. Distinct from raw FX-rate feeds — this turns rates into the pip values, position sizes
…(truncated, see openapi.json for full schema)
```


---
Marketplace page: https://www.oanor.com/api/fxcalculator-api
OpenAPI spec: https://www.oanor.com/api/fxcalculator-api/openapi.json
