Brokeret LogoDocs
Plugins / Hedge Account/API

API

API reference for the Hedge Account plugin.

Authentication

All endpoints require authentication via one of:

  • Header: X-API-Key: <your_api_key>
  • Header: Authorization: Bearer <your_api_key>

The default API key is default. Change it via the API_Key plugin parameter in MT5 Administrator.

Base URL

http://<server_ip>:<API_Port>/api/

Default port: 8445

GET/api/status

Returns plugin status and summary statistics.

{
  "plugin": "Brokeret Hedge Account",
  "version": "1.00",
  "license_active": true,
  "mappings_total": 3,
  "stats": {
    "total_deals": 1250,
    "hedged_opens": 580,
    "hedged_closes": 570,
    "skipped": 100,
    "errors": 0,
    "total_volume_hedged": 45.50
  }
}

GET/api/mappings

Returns all configured hedge mappings.

{
  "mappings": [
    {
      "mapping_id": 1,
      "source_group_mask": "retail\\*",
      "hedge_login": 5001,
      "reverse": false,
      "enabled": true,
      "hedge_mode": "mirror",
      "volume_multiplier": 1.0,
      "symbol_filter": "*",
      "min_volume": 0.0,
      "priority": 0
    }
  ],
  "total": 1
}

POST/api/mappings

Create a new hedge mapping.

Request Body

{
  "source_group_mask": "retail\\usd\\*",
  "hedge_login": 5001,
  "reverse": false,
  "hedge_mode": "mirror",
  "volume_multiplier": 1.0,
  "symbol_filter": "*",
  "min_volume": 0.01,
  "priority": 10
}

Required fields: source_group_mask, hedge_login

Optional fields with defaults:

FieldDefault
reversefalse
enabledtrue
hedge_mode"mirror"
volume_multiplier1.0
symbol_filter"*"
min_volume0.0
priority0

Response (201)

{
  "success": true,
  "mapping_id": 1,
  "total": 1
}

PUT/api/mappings/{id}

Update an existing mapping. Only include the fields you want to change.

Request Body

{
  "enabled": false,
  "volume_multiplier": 0.5
}

Updatable fields: enabled, reverse, volume_multiplier, hedge_mode, min_volume, priority

Response (200)

{
  "success": true,
  "mapping_id": 1
}

DELETE/api/mappings/{id}

Remove a mapping.

{
  "success": true
}

GET/api/log

Returns recent hedge actions from the ring buffer (last 200 entries, newest first).

Query parameters:

  • ?login=<login> — Filter by source or hedge login

Response

{
  "log": [
    {
      "deal_id": 123456,
      "source_login": 1001,
      "hedge_login": 5001,
      "source_position_id": 789,
      "hedge_position_id": 790,
      "symbol": "EURUSD",
      "action": "buy",
      "entry": "open",
      "source_volume": 10000,
      "hedge_volume": 10000,
      "reverse": false,
      "hedge_mode": "mirror",
      "timestamp": 1740556800,
      "mapping_id": 1
    }
  ],
  "count": 1
}

GET/api/stats

Returns daily statistics (auto-resets at midnight UTC).

{
  "date": 20260226,
  "total_deals": 1250,
  "hedged_opens": 580,
  "hedged_closes": 570,
  "skipped": 100,
  "errors": 0,
  "total_volume_hedged": 45.50
}

Error Responses

All errors return JSON:

{
  "error": "description of the error"
}
StatusMeaning
400Bad request (missing or invalid fields)
401Unauthorized (invalid API key)
404Not found (mapping or endpoint)
405Method not allowed
500Internal server error