Skip to content

Cross-Platform Risk Monitoring in Real-Time

Aggregate risk exposure across MetaTrader 4, MetaTrader 5, cTrader, and B2Trader. Monitor margin levels, track open positions, and receive streaming alerts through a single API.

Get Started

The Challenge

Risk managers need a unified view of exposure across all trading platforms. Each platform reports margin, equity, and positions differently, making real-time aggregation complex.

The WebAPI Solution

WebAPI normalizes margin level data, position details, and account metrics into a consistent schema. The Realtime Service provides streaming updates for immediate risk monitoring.

Margin Level Monitoring

risk_monitor.tsTypeScript
// Monitor margin levels across all platforms in real-time
const accounts = await webapi.accountService.ReadBatchMarginLevel({
  items: [
    { platform: Platform.MT4, login: 10001 },
    { platform: Platform.MT5, login: 20001 },
    { platform: Platform.CTRADER, login: 30001 },
    { platform: Platform.B2TRADER, login: 40001 },
  ]
});

for (const acc of accounts.items) {
  if (acc.marginLevel < 150) {
    console.warn(`⚠️ Low margin: ${acc.login} at ${acc.marginLevel}%`);
    // Trigger risk alert
    await alertService.notify({
      level: 'WARNING',
      account: acc.login,
      platform: acc.platform,
      marginLevel: acc.marginLevel
    });
  }
}

Risk Dashboard

$2.4MTotal Exposure
847Open Positions
+$12,450Aggregate P&L
MT4412%Margin Level
MT5187%Margin Level
cTrader520%Margin Level
B2Trader98%Margin Level

Risk Metrics

Margin Level

(Equity / Margin) × 100%

Monitor across all platforms in real-time

Stop-Out Level

Configurable per group, typically 50-100%

WebAPI reports via GroupService

Free Margin

Equity - Margin

Available for new positions

Streaming Alerts Configuration

alerts_config.tsTypeScript
// Subscribe to account updates for margin monitoring
const stream = webapi.realtimeService.Subscribe({
  subject: Subject.ACCOUNTS,
  selectors: [Selector.UPDATE],
});

for await (const event of stream) {
  const account = event.account;
  if (account.marginLevel > 0 && account.marginLevel < threshold) {
    triggerAlert(account);
  }
}

Available Data Points

Data PointDescriptionUpdate Frequency
Margin LevelEquity/Margin ratioReal-time
Free MarginAvailable marginReal-time
EquityAccount equityReal-time
BalanceAccount balanceOn change
Open P&LUnrealized profit/lossReal-time
Open PositionsCount of open positionsOn change
Pending OrdersCount of pending ordersOn change
Used MarginMargin in useReal-time

Relevant API Services

Account Service

ReadMarginLevel, ReadBatchMarginLevel

Position Service

open positions across platforms

Realtime Service

streaming position and account updates

Order Service

pending order monitoring

Real-world example

Risk management systems can aggregate exposure from 1,000+ accounts across 4 platforms with sub-second latency.

Ready to build?

Monitor risk exposure across MT4, MT5, cTrader, and B2Trader from a single dashboard with real-time streaming.

Get Started