Phase C · Information Systems Architecture
AIB Trading Service API
Version: 1.0
Status: Draft
Last Updated: 2026-06-08
Overview
aib-trading owns order lifecycle, pre-trade compliance gates, trade execution, settlement management, and best execution tracking.
Primary Tables: order_, trade, settlement, emir_trade_report, approved_instrument, position, best_execution_policy
Calls: aib-compliance (mandate validation), aib-reporting (EMIR)
Called By: aib-operations (position updates)
SLA Targets
| Metric | Target | Notes |
|---|---|---|
| Pre-Trade Gate | P95: 50ms | Real-time suitability + mandate check |
| Order Creation | P95: 100ms | MiFID II Art. 25 compliance gate |
| Trade Execution Confirmation | P95: 200ms | Broker callback → DB record |
| Settlement Instruction | P95: 500ms | T+0 EOD to CSD |
| Throughput (orders) | 5,000 req/sec | Peak trading hours |
| Availability | 99.99% | Execution failure = liability |
OpenAPI 3.0 Specification
openapi: 3.0.3
info:
title: AIB Trading Service API
version: 1.0.0
description: Order management, pre-trade compliance, trade execution, settlement, best execution
contact:
name: AIB Architecture
servers:
- url: https://api.aib.internal/trading/v1
description: Production
paths:
/orders:
post:
summary: Place order with pre-trade compliance checks
operationId: createOrder
requestBody:
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/OrderCreateRequest'
responses:
'201':
description: Order created and pre-trade checks passed
content:
application/json:
schema:
$ref: '#/components/schemas/OrderResponse'
'400':
description: Pre-trade check failed (suitability, mandate, best execution)
content:
application/json:
schema:
$ref: '#/components/schemas/PreTradeErrorResponse'
tags:
- Orders
x-sla:
p95_latency_ms: 100
timeout_ms: 500
get:
summary: List orders for a client
operationId: listOrders
parameters:
- name: account_id
in: query
required: true
schema:
type: string
format: uuid
- name: status
in: query
schema:
type: string
enum: [pending, submitted, executed, rejected, canceled]
- name: limit
in: query
schema:
type: integer
default: 100
responses:
'200':
description: List of orders
content:
application/json:
schema:
type: array
items:
$ref: '#/components/schemas/OrderResponse'
tags:
- Orders
x-sla:
p95_latency_ms: 150
/orders/{order_id}:
get:
summary: Retrieve order details with pre-trade check results
operationId: getOrder
parameters:
- name: order_id
in: path
required: true
schema:
type: string
format: uuid
responses:
'200':
description: Order details
content:
application/json:
schema:
$ref: '#/components/schemas/OrderResponse'
tags:
- Orders
x-sla:
p95_latency_ms: 50
patch:
summary: Update order status (cancel, suspend)
operationId: updateOrder
parameters:
- name: order_id
in: path
required: true
schema:
type: string
format: uuid
requestBody:
content:
application/json:
schema:
type: object
properties:
status:
type: string
enum: [canceled]
responses:
'200':
description: Order updated
content:
application/json:
schema:
$ref: '#/components/schemas/OrderResponse'
tags:
- Orders
x-sla:
p95_latency_ms: 100
/orders/{order_id}/execute:
post:
summary: Execute order (internal routing to broker)
operationId: executeOrder
parameters:
- name: order_id
in: path
required: true
schema:
type: string
format: uuid
requestBody:
content:
application/json:
schema:
type: object
properties:
broker_id:
type: string
description: Selected broker (best execution)
responses:
'202':
description: Order submitted to broker
'400':
description: Order cannot be executed (status != pending)
tags:
- Execution
x-sla:
p95_latency_ms: 200
/trades:
post:
summary: Record executed trade (callback from broker)
operationId: createTrade
requestBody:
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/TradeCreateRequest'
responses:
'201':
description: Trade recorded
content:
application/json:
schema:
$ref: '#/components/schemas/TradeResponse'
'400':
description: Invalid order_id or trade data
tags:
- Trades
x-sla:
p95_latency_ms: 150
get:
summary: List trades
operationId: listTrades
parameters:
- name: account_id
in: query
schema:
type: string
format: uuid
- name: from_date
in: query
schema:
type: string
format: date
- name: to_date
in: query
schema:
type: string
format: date
responses:
'200':
description: List of trades
content:
application/json:
schema:
type: array
items:
$ref: '#/components/schemas/TradeResponse'
tags:
- Trades
x-sla:
p95_latency_ms: 200
/trades/{trade_id}:
get:
summary: Retrieve trade details
operationId: getTrade
parameters:
- name: trade_id
in: path
required: true
schema:
type: string
format: uuid
responses:
'200':
description: Trade details
content:
application/json:
schema:
$ref: '#/components/schemas/TradeResponse'
tags:
- Trades
x-sla:
p95_latency_ms: 50
/settlements:
post:
summary: Create settlement instruction (T+2 from trade_date)
operationId: createSettlement
requestBody:
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/SettlementCreateRequest'
responses:
'201':
description: Settlement scheduled
content:
application/json:
schema:
$ref: '#/components/schemas/SettlementResponse'
tags:
- Settlement
x-sla:
p95_latency_ms: 100
get:
summary: List settlements with status
operationId: listSettlements
parameters:
- name: status
in: query
schema:
type: string
enum: [scheduled, matched, failed, buy_in_pending]
- name: intended_sd_from
in: query
schema:
type: string
format: date
responses:
'200':
description: List of settlements
content:
application/json:
schema:
type: array
items:
$ref: '#/components/schemas/SettlementResponse'
tags:
- Settlement
x-sla:
p95_latency_ms: 150
/settlements/{settlement_id}:
get:
summary: Retrieve settlement details with T+n escalation status
operationId: getSettlement
parameters:
- name: settlement_id
in: path
required: true
schema:
type: string
format: uuid
responses:
'200':
description: Settlement details
content:
application/json:
schema:
$ref: '#/components/schemas/SettlementResponse'
tags:
- Settlement
x-sla:
p95_latency_ms: 50
patch:
summary: Update settlement status (mark matched, initiate buy-in)
operationId: updateSettlement
parameters:
- name: settlement_id
in: path
required: true
schema:
type: string
format: uuid
requestBody:
content:
application/json:
schema:
type: object
properties:
status:
type: string
enum: [matched, buy_in_pending, escalated_to_fma]
responses:
'200':
description: Settlement updated
'400':
description: Invalid status transition
tags:
- Settlement
x-sla:
p95_latency_ms: 150
/positions:
get:
summary: Retrieve current positions for account
operationId: listPositions
parameters:
- name: account_id
in: query
required: true
schema:
type: string
format: uuid
responses:
'200':
description: Current positions
content:
application/json:
schema:
type: array
items:
$ref: '#/components/schemas/PositionResponse'
tags:
- Positions
x-sla:
p95_latency_ms: 100
/best-execution-policy:
get:
summary: Retrieve current best execution policy
operationId: getBestExecutionPolicy
parameters:
- name: version_date
in: query
schema:
type: string
format: date
responses:
'200':
description: Best execution policy
content:
application/json:
schema:
$ref: '#/components/schemas/BestExecutionPolicyResponse'
tags:
- Best Execution
x-sla:
p95_latency_ms: 50
post:
summary: Publish new best execution policy (compliance)
operationId: createBestExecutionPolicy
requestBody:
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/BestExecutionPolicyCreateRequest'
responses:
'201':
description: Policy published
content:
application/json:
schema:
$ref: '#/components/schemas/BestExecutionPolicyResponse'
tags:
- Best Execution
x-sla:
p95_latency_ms: 200
components:
schemas:
OrderCreateRequest:
type: object
required:
- account_id
- isin
- quantity
- direction
properties:
account_id:
type: string
format: uuid
isin:
type: string
pattern: '^[A-Z]{2}[A-Z0-9]{9}[0-9]$'
quantity:
type: integer
minimum: 1
direction:
type: string
enum: [buy, sell]
limit_price:
type: number
nullable: true
OrderResponse:
type: object
properties:
order_id:
type: string
format: uuid
account_id:
type: string
format: uuid
mandate_id:
type: string
format: uuid
isin:
type: string
quantity:
type: integer
direction:
type: string
status:
type: string
enum: [pending, submitted, executed, rejected, canceled]
pre_trade_check:
type: object
properties:
suitability_check:
type: string
enum: [passed, failed]
suitability_reason:
type: string
nullable: true
mandate_compliance_check:
type: string
enum: [passed, failed]
mandate_reason:
type: string
nullable: true
approved_instrument_check:
type: string
enum: [passed, failed]
best_execution_check:
type: string
enum: [passed, failed]
created_at:
type: string
format: date-time
PreTradeErrorResponse:
type: object
properties:
error_code:
type: string
enum: [SUITABILITY_FAILED, MANDATE_EXCEEDED, INSTRUMENT_NOT_APPROVED, BEST_EXECUTION_FAILED]
error_message:
type: string
details:
type: object
TradeCreateRequest:
type: object
required:
- order_id
- executed_price
- executed_quantity
properties:
order_id:
type: string
format: uuid
executed_price:
type: number
executed_quantity:
type: integer
trade_date:
type: string
format: date
broker_reference:
type: string
TradeResponse:
type: object
properties:
trade_id:
type: string
format: uuid
order_id:
type: string
format: uuid
executed_price:
type: number
executed_quantity:
type: integer
trade_date:
type: string
format: date
intended_sd:
type: string
format: date
description: T+2 settlement date
settlement_id:
type: string
format: uuid
emir_trade_report_id:
type: string
format: uuid
nullable: true
created_at:
type: string
format: date-time
SettlementCreateRequest:
type: object
required:
- trade_id
properties:
trade_id:
type: string
format: uuid
SettlementResponse:
type: object
properties:
settlement_id:
type: string
format: uuid
trade_id:
type: string
format: uuid
status:
type: string
enum: [scheduled, matched, failed, buy_in_pending, escalated_to_fma]
intended_sd:
type: string
format: date
fail_days:
type: integer
description: Days settlement has failed (0 = on-time, 3+ = escalate)
t3_escalation_required:
type: boolean
description: CSDR Art. 7 escalation trigger
buy_in_assessed:
type: boolean
csdr_penalty_applicable:
type: boolean
scheduled_at:
type: string
format: date-time
matched_at:
type: string
format: date-time
nullable: true
PositionResponse:
type: object
properties:
position_id:
type: string
format: uuid
account_id:
type: string
format: uuid
isin:
type: string
quantity:
type: integer
cost_basis_chf:
type: number
current_market_price:
type: number
unrealized_pl_chf:
type: number
settlement_date:
type: string
format: date
updated_at:
type: string
format: date-time
BestExecutionPolicyResponse:
type: object
properties:
policy_id:
type: string
format: uuid
effective_date:
type: string
format: date
version:
type: integer
approved_brokers:
type: array
items:
type: object
properties:
broker_id:
type: string
broker_name:
type: string
execution_quality_score:
type: number
execution_venues:
type: array
items:
type: object
properties:
venue_mic:
type: string
priority:
type: integer
BestExecutionPolicyCreateRequest:
type: object
required:
- approved_brokers
- execution_venues
properties:
approved_brokers:
type: array
items:
type: string
execution_venues:
type: array
items:
type: stringIntegration Points
Calls to Other Services
aib-compliance(GET/clients/{client_id}?check_kyc_status=true): Pre-trade suitability validationaib-reporting(POST/emir-trades): EMIR reporting for derivatives
Called By
- None (source service)
Event Publishing
order.created→ pre-trade checkstrade.executed→ settlement creation + EMIR reportingsettlement.matched→ position updatesettlement.failed→ T+3 escalation + ops alert
Pre-Trade Compliance Gate (4-Check Logic)
ORDER SUBMISSION
↓
[CHECK 1] Suitability Assessment valid?
├─ Pass → next check
└─ Fail (expired) → REJECT (status=400)
↓
[CHECK 2] Mandate limit compliance?
├─ ISIN in approved_instrument list?
├─ Position weight within mandate.max_weight_pct?
├─ Pass → next check
└─ Fail → REJECT (status=400)
↓
[CHECK 3] Best Execution venue selected?
├─ Broker in best_execution_policy?
├─ Pass → next check
└─ Fail → REJECT (status=400)
↓
[CHECK 4] No pending MAR sanctions flags?
├─ MAR surveillance flag.status = 'clear'?
├─ Pass → CREATE order
└─ Fail → REJECT (status=400)
↓
ORDER CREATED (status=pending)Settlement Discipline (CSDR Art. 5, 7)
| Day | Status | Action |
|---|---|---|
| T+0 | Order executed | Trade record created |
| T+0 EOD | Trade → Settlement instruction | T+2 settlement date calculated via settlement_calendar |
| T+2 | Settlement date | Await CSD matching |
| T+2 EOD (success) | Settlement matched | settlement.status = 'matched' |
| T+2 EOD (failure) | Settlement failed | settlement.fail_days=1, ops alert |
| T+3 EOD | 1 day overdue | settlement.fail_days=2, CCO notification |
| T+4 EOD | 2 days overdue | settlement.fail_days=3, settlement.t3_escalation_required=true, buy-in assessment |
| T+30 | Unresolved | settlement.status='escalated_to_fma', FMA report filed |
Regulatory Compliance
| Regulation | Requirement | Implementation |
|---|---|---|
| MiFID II Art. 25 | Pre-trade suitability gate | 4-check logic in order creation |
| MiFID II Art. 27 | Best execution policy | /best-execution-policy endpoint + RTS 28 reporting |
| CSDR Art. 5 | T+2 settlement discipline | Settlement instruction T+2 scheduling |
| CSDR Art. 7 | Settlement failure escalation | 3-day fail trigger + buy-in + penalty accrual |
| EMIR Art. 9 | Trade reporting (derivatives) | UTI assignment + ARM reporting within T+1 |
References
Referenced by
- agentAgent — Market Risk Manager (agent:aib-market-risk)
- agentAgent — Trade Operations Manager (COO line) (agent:aib-tradeops-coo)
- agentAgent — Trade Operations Manager (Ops line) (agent:aib-tradeops-ops)
- refAPI-to-Process Cross-Reference
- refPhase 1–3 Verification Checklist
- refRegulatory Framework × Artifact Mapping
- ServiceAIB Compliance Service API
- ServiceAIB Reporting Service API
- ServiceAIB Risk Service API
- ProcessPROC-004: Order Pre-Trade Compliance Gate (Refresh)
- ProcessPROC-005: Trading → Settlement with Waiver Paths
- ScreenSCR-TRD — Trading & Settlement Screens
- DocAIB Cloud Infrastructure Research — Best-in-Class Secure Cloud for a Liechtenstein/EEA Private Bank
- DocAIB Data Ownership Matrix (RACI)
- DocAIB Non-Functional Requirements & SLO Register
- DocAIB Solution Building Block (SBB) Catalog
- GovernanceAIB Security Threat Model (STRIDE)
- GovernanceAIB TIBER-EU Threat-Led Penetration Testing Program