StockEx Trading Dashboard

Complete User & Technical Guide v1.0

Table of Contents

1. Introduction

StockEx is a comprehensive real-time trading simulation platform inspired by Euronext OPTIQ. It provides a complete electronic trading ecosystem including order entry, matching engine, market data distribution, and live visualization.

Key Features:
Access URLs:
Dashboard: http://localhost:5005
Frontend (Order Entry): http://localhost:5000
FIX Gateway: localhost:5001
Matcher API: http://localhost:6000
Trading Dashboard

StockEx Trading Dashboard - Real-time Market View

2. System Architecture

┌─────────────────┐ ┌─────────────────┐ ┌─────────────────┐ │ FIX UI Client │ │ FIX UI Client │ │ Frontend │ │ (Port 5002) │ │ (Port 5003) │ │ (Port 5000) │ └────────┬────────┘ └────────┬────────┘ └────────┬────────┘ │ │ │ │ FIX 4.4 │ FIX 4.4 │ HTTP ▼ ▼ ▼ ┌────────────────────────────────────────────────────────────────┐ │ FIX OEG (Port 5001) │ │ QuickFIX Order Entry Gateway │ └────────────────────────────────┬───────────────────────────────┘ │ ▼ Kafka [orders] ┌────────────────────────────────────────────────────────────────┐ │ Apache Kafka (Port 9092) │ │ Topics: orders, trades, snapshots │ └───────┬────────────────────┬───────────────────────┬───────────┘ │ │ │ ▼ ▼ ▼ ┌───────────────┐ ┌───────────────┐ ┌───────────────┐ │ Matcher │ │ MD Feeder │ │ Dashboard │ │ (Port 6000) │ │ (MDF) │ │ (Port 5005) │ │ │ │ │ │ │ │ Order Book │ │ Price Sim │ │ Web UI + SSE │ │ Trade Match │ │ BBO Publish │ │ Real-time │ └───────────────┘ └───────────────┘ └───────────────┘

3. Module Descriptions

Zookeeper

Port 2181

Apache Zookeeper provides distributed coordination for the Kafka cluster. It manages broker metadata, topic configurations, and cluster membership.

FunctionKafka cluster coordination
TechnologyConfluent Zookeeper 7.5.0
DependenciesNone

Kafka Message Broker

Port 9092 Port 29092 (host)

Apache Kafka serves as the central message backbone for the entire system. All order flow, trade executions, and market data are distributed through Kafka topics.

FunctionMessage streaming and event distribution
TechnologyConfluent Kafka 7.5.0
Topicsorders, trades, snapshots
DependenciesZookeeper

FIX Order Entry Gateway (FIX OEG)

Port 5001

The FIX OEG is a QuickFIX/Python acceptor that receives orders via FIX 4.4 protocol from institutional clients. It validates incoming messages, normalizes them to JSON format, and publishes to the Kafka orders topic.

FunctionFIX protocol order reception and normalization
TechnologyQuickFIX/Python
ProtocolFIX 4.4
Message TypesNewOrderSingle (D), OrderCancelRequest (F), OrderCancelReplaceRequest (G)
OutputKafka orders topic

FIX UI Clients

Port 5002 (Client 1) Port 5003 (Client 2)

Web-based FIX initiator clients that connect to the FIX OEG. They provide a user interface for submitting orders via FIX protocol, simulating institutional trading terminals.

FunctionFIX order submission interface
TechnologyQuickFIX/Python + Flask
FeaturesNew Order, Cancel, Amend
ConnectionFIX 4.4 to FIX OEG

Matcher (Order Matching Engine)

Port 6000

The core matching engine that maintains order books for all securities. It consumes orders from Kafka, attempts to match them using price-time priority, and publishes resulting trades. Provides REST API for order book and trade queries.

FunctionOrder matching, trade execution, order book management
TechnologyPython/Flask with SQLite persistence
AlgorithmPrice-Time Priority (FIFO)
InputKafka orders topic
OutputKafka trades topic
API Endpoints/orderbook/<symbol>, /trades, /health

Market Data Feeder (MDF)

Internal

Simulates market data by generating random orders and publishing Best Bid/Offer (BBO) snapshots. Creates realistic market activity with configurable order rates and price movements.

FunctionMarket simulation and BBO publishing
TechnologyPython
OutputKafka orders and snapshots topics
Order Mix90% passive (book building), 10% aggressive (trades)
RateConfigurable (default: 8 orders/minute)

Dashboard

Port 5005

Real-time web dashboard providing comprehensive market visualization. Uses Server-Sent Events (SSE) for live streaming updates without page refresh. Displays orders, trades, market snapshots, order book depth, and trading statistics.

FunctionReal-time market visualization and order management
TechnologyPython/Flask + JavaScript
StreamingServer-Sent Events (SSE)
InputKafka topics + Matcher REST API
FeaturesOrders, Trades, BBO, Order Book, Charts, Statistics

Frontend (Manual Order Entry)

Port 5000

Simple web interface for manual order submission. Allows users to enter orders directly without FIX protocol, useful for testing and demonstration.

FunctionManual order entry interface
TechnologyPython/Flask
OutputKafka orders topic

Consumer (Debug)

Internal

Debug utility that consumes and logs messages from Kafka topics. Useful for monitoring message flow and troubleshooting.

Snapshot Viewer

Internal

Utility service that subscribes to the snapshots topic and logs BBO updates. Writes to log files for analysis.

4. Dashboard User Interface

4.1 Orders Panel

Displays real-time incoming orders with full management capabilities.

ColumnDescription
SymbolStock ticker (ALPHA, EXAE, PEIR, QUEST)
SideBUY (green) or SELL (red)
QtyOrder quantity in shares
PriceLimit price
SourceOrder origin (MDF, FIX, Manual)
TimeOrder timestamp
ActionsEdit / Cancel buttons

Row Selection: Click any row to select, then use header buttons for bulk actions.

4.2 Market Snapshot

Shows Best Bid/Offer (BBO) for all securities with real-time updates.

ColumnDescription
SymbolSecurity identifier
Best BidHighest buy price (green)
Best AskLowest sell price (red)
SpreadAsk - Bid difference
MidMidpoint: (Bid + Ask) / 2
UpdatedLast update timestamp

Ticker Tape: Scrolling bar at bottom displays recent trades with price direction (▲ green up, ▼ red down).

4.3 Trades Panel

Lists all executed trades with calculated values.

ColumnDescription
SymbolTraded security
QtyExecuted quantity
PriceExecution price
ValueTrade value (Qty × Price)
TimeExecution timestamp

4.4 Order Book

Displays full market depth for selected symbol.

4.5 Trade Chart

Visual representation of trade activity over time.

4.6 Trading Statistics

Aggregated metrics calculated from all trades.

MetricDescription
TradesNumber of executed trades
VolumeTotal shares traded
ValueTotal monetary value (Σ Qty × Price)
StartFirst trade price (opening)
LastMost recent trade price
VWAPVolume-Weighted Average Price

Bar Charts: Visual comparison showing Volume and Value per symbol side by side.

5. Data Flow & Messaging

5.1 Kafka Topics

TopicProducersConsumersContent
ordersFIX OEG, MDF, FrontendMatcher, DashboardNew orders, cancels, amends
tradesMatcherDashboard, ConsumerExecuted trades
snapshotsMDFDashboard, Snapshot ViewerBBO updates

5.2 Message Formats

Order Message

{ "symbol": "ALPHA", "side": "BUY", "price": 25.50, "quantity": 100, "cl_ord_id": "MDF-1234567890-1", "timestamp": 1234567890.123, "source": "MDF" }

Trade Message

{ "symbol": "ALPHA", "price": 25.50, "quantity": 100, "buy_order_id": "order-123", "sell_order_id": "order-456", "timestamp": 1234567890.123 }

Snapshot Message

{ "symbol": "ALPHA", "best_bid": 25.45, "best_ask": 25.55, "bid_size": 500, "ask_size": 300, "timestamp": 1234567890.123, "source": "MDF" }

6. Configuration

VariableDefaultDescription
KAFKA_BOOTSTRAPkafka:9092Kafka broker address
MATCHER_URLhttp://matcher:6000Matcher API endpoint
TICK_SIZE0.05Minimum price increment
ORDERS_PER_MIN8MDF order generation rate
SECURITIES_FILE/app/data/securities.txtSecurities configuration

6.1 Supported Securities

SymbolStart PriceDescription
ALPHA25.00Test Security A
EXAE42.00Test Security B
PEIR18.50Test Security C
QUEST12.75Test Security D

7. Quick Reference

7.1 Starting the System

docker compose up --build

7.2 Service URLs

ServiceURLPurpose
Dashboardhttp://localhost:5005Main trading view
Frontendhttp://localhost:5000Manual order entry
FIX Client 1http://localhost:5002FIX order submission
FIX Client 2http://localhost:5003FIX order submission
Matcher APIhttp://localhost:6000REST API

7.3 Dashboard Actions

ActionHow To
View order book depthSelect symbol from Order Book dropdown
Edit an orderClick Edit button on order row
Cancel an orderClick Cancel button on order row
Filter trade chartSelect symbol from Trade Chart dropdown
Pause ticker tapeHover mouse over the ticker
Select multiple ordersClick rows, use header Edit/Cancel buttons

7.4 Connection Status Indicators

StatusIndicatorMeaning
Live● GreenConnected to real-time stream
Connecting● YellowEstablishing connection
Disconnected● RedConnection lost, auto-reconnecting