-
Notifications
You must be signed in to change notification settings - Fork 23
Execution Service
The execution routing engine is the automated order routing and algorithmic execution component of the Emporia Trading Platform. It receives order domain events, evaluates routing strategies (DMA, SMART, VWAP), decomposes parent orders into child slices, and interfaces with market execution venues (exchange matching engines and FIX gateways).
โน๏ธ This is no longer a separate service. It ran as
execution-serviceon port8087and was merged intoorder-management-service, in the same wayorder-command-servicewas folded in before it. The three Kafka topics that carried orders between the two processes are gone; dispatch is now a direct in-process call throughShardedOrderDispatcher, sharded by order id so per-order ordering is preserved without a broker. See No Blocking DB on the Hot Path for why the hot path avoids network and database round trips.
-
Package:
com.emporia.execution, insideorder-management-service -
HTTP Port: shares the OMS port
8086(no port of its own) -
Database Boundary: Stateless (Stores checkpoint snapshots in
ExchangeCoreCheckpointStoreand recovers active strategy state dynamically). -
Primary Roles:
- Algorithmic order routing (
DMA,SMART,VWAP). - Best execution under National Best Bid and Offer (NBBO) rules via
BestVenueSelector.java. - Intraday VWAP volume-weighted time-slicing via
VwapSchedule.java. - Execution venue gateway integration (
ExchangeCoreExecutionVenueGateway,FixExecutionVenueGateway). - Handing execution commands (
FILL,REJECT,CANCEL) toExecutionCommandHandlerby direct call.
- Algorithmic order routing (
flowchart TD
subgraph InboundEvents ["Order Domain Input (same JVM)"]
DISP["ShardedOrderDispatcher<br/>sharded by order id"] -->|OrderDomainEvent| EEC["ExecutionEventConsumer"]
end
subgraph StrategyRouter ["Routing & Strategy Engine"]
EEC --> SelectDestination{"Order Destination?"}
SelectDestination -->|DMA| GatewayRouter["ExecutionVenueGateway"]
SelectDestination -->|SMART| SmartEngine["BestVenueSelector (SOR)"]
SelectDestination -->|VWAP| VwapEngine["VwapSchedule Algorithmic Slicer"]
end
subgraph Venues ["Execution Venues"]
GatewayRouter --> ExchangeCore["ExchangeCoreExecutionVenueGateway (Disruptor RingBuffer)"]
GatewayRouter --> FixGateway["FixExecutionVenueGateway (FIX 4.2/4.4 Protocol)"]
GatewayRouter --> SimGateway["SimulatedExecutionVenueGateway"]
end
subgraph AlgorithmicSlices ["Parent-Child Algorithmic Orders"]
SmartEngine -->|Child slice, direct call| OCH["OrderCommandHandler"]
VwapEngine -->|Scheduled slice, direct call| OCH
end
subgraph OutboundExecutions ["Execution Outcome"]
ExchangeCore -->|ExecutionCommand, direct call| ECH["ExecutionCommandHandler"]
FixGateway -->|ExecutionCommand, direct call| ECH
SimGateway -->|ExecutionCommand, direct call| ECH
end
- Mechanics: Bypasses algorithmic slicing and routes the order directly to the designated venue gateway.
-
Venue Gateways:
-
ExchangeCoreExecutionVenueGateway: Ultra-low latency interface to in-memory LMAX Disruptor matching engine (exchange-core). -
FixExecutionVenueGateway: Institutional FIX protocol (FIX 4.2/4.4) gateway. -
SimulatedExecutionVenueGateway: In-memory venue simulator for testing.
-
-
Engine:
BestVenueSelector.java -
Mechanics:
- Evaluates real-time Level-1 quotes across all listings for the instrument.
- Applies NBBO Best Execution rules: routes BUY orders to the lowest Ask price and SELL orders to the highest Bid price.
- If a single venue does not have sufficient depth, it splits the parent order into multiple child slice orders and submits them back through
OrderCommandHandler.
-
Engine:
VwapSchedule.java -
Mechanics:
- Decomposes large parent orders into historical volume-weighted time buckets (
buckets,durationMinutes,participationRate). - Uses
TaskSchedulerto periodically release child orders throughOrderCommandHandleracross the specified trading window.
- Decomposes large parent orders into historical volume-weighted time buckets (
On application startup (ApplicationReadyEvent), ExecutionEventConsumer.recover() runs automatically:
- Calls
TradingDataClientto fetch all un-cleared direct orders and active strategy states fromorder-management. - Resubmits direct orders to venue gateways.
- Reschedules active SMART and VWAP strategy runtimes seamlessly without dropping active child order slices across service restarts.
- Trading Terminology Glossary
- Order Lifecycle & Validation
- Order Routing & SOR
- Market Data & Pricing
- Portfolio & Risk Management
- Architecture & Order Flow
- Microservices Overview
- Exchange-Core Integration
- Design Patterns Catalog
- Testing & Verification
- No Blocking DB on Hot Path
- WAL Crash Recovery
- Deployment & Operations
- Static Data Service
- Market Data Service
- Order Management Service (OMS)
- Execution Routing
- Portfolio Service
- Repository: emporia
- Tech Stack: Java 21 | Spring Boot 4.0.7 | React 19 | LMAX Disruptor | Aeron | gRPC
- Coverage: 91.95% JaCoCo