Inside a trading system
What really happens after you choose a stock and tap Buy? Follow an order through a brokerage, risk checks, routers, market makers or exchanges, clearing, T+1 settlement, custody, and the systems that reconcile every dollar and share.
01 · Mental model
Four systems, one trade
A brokerage app is the visible edge of a regulated transaction network. Separate these four jobs and the ecosystem becomes much easier to reason about.
Reference data identifies the security. Market-data feeds provide bids, offers, trades, status, and sometimes full order-book depth.
The broker authenticates the customer, checks buying power and restrictions, records the instruction, and decides where it may be sent.
An exchange, alternative trading system, wholesaler, or market maker matches or executes the order against another willing buyer or seller.
Clearing calculates obligations and reduces counterparty risk. Settlement moves securities and money; custody updates the customer’s books and records.
02 · Market language
What the numbers mean
A quote is not a promise that unlimited shares are available. It is a snapshot of displayed willingness to trade, with size, timing, venue, and market conditions attached.
Highest displayed price buyers currently offer.
Lowest displayed price sellers currently offer.
Best bid and offer
The best protected displayed prices across relevant U.S. venues, consolidated into a national view.
Volume
Shares or contracts executed during a period. A 100-share trade adds 100 to reported share volume, not 200.
Liquidity
The ability to trade size quickly with limited price impact. Spread, depth, resiliency, and activity are clues.
Market cap
Share price multiplied by shares outstanding. It measures equity value, not daily trading volume.
Why can the price move when I buy?
Displayed volume vs. total interest
03 · Interactive trace
You tapped Buy
Step through a simplified U.S. retail stock order. Some stages happen in parallel or are provided by a clearing firm behind the customer-facing broker.
Customer order trace
Example: buy 10 shares of XYZ with a limit price.
Symbol, buy or sell, quantity or notional, order type, limit or stop price, time in force, session, and optional tax-lot instructions.
Valid symbol and increments? Required price supplied? Supported session? The client can help, but the server remains authoritative.
The API verifies the session and account, applies rate limits, and uses a client order ID or idempotency key to prevent accidental duplicates.
Buying power, position, settled funds, margin, short locate, options approval, concentration, restricted securities, trading halt, and regulatory controls.
The order-management system assigns a durable broker order ID, journals the event, reserves cash or shares, and moves the order to an accepted state.
Based on price, displayed size, execution quality, speed, fees or rebates, venue health, customer instruction, and broker obligations.
A market maker may fill as principal, or an exchange/ATS matching engine pairs the order with resting interest. One order can receive several partial fills.
Fill quantity, price, venue, time, liquidity flags, and trade identifiers flow back. Positions and buying power update, followed by a customer confirmation.
Trade records are compared. NSCC generally becomes the central counterparty for eligible transactions and calculates each member’s net obligations.
On settlement date, DTC book-entry movements and funds settlement complete delivery-versus-payment. Broker and custodian ledgers reconcile the result.
04 · State machine
An order is not simply “open”
Order state is event-driven. The customer app, broker OMS, router, clearing system, and venue may each maintain related but distinct state.
05 · Matching
Inside an order book
A continuous limit-order book commonly prioritizes better prices first and earlier orders at the same price next. Exact venue rules and specialized order types can be more complex.
Displayed XYZ book
| Side | Price | Shares | Depth |
|---|---|---|---|
| Ask | $100.08 | 900 | |
| Ask | $100.05 | 500 | |
| Ask | $100.02 | 400 | |
| Spread: $0.04 | |||
| Bid | $99.98 | 600 | |
| Bid | $99.95 | 1,000 | |
| Bid | $99.90 | 1,600 | |
Send a buy order
This simulation walks the visible asks from lowest price upward. It ignores hidden liquidity, fees, price improvement, routing, and quote changes.
The order can trade with the best displayed offer.
Marketable limit
A buy limit at or above the current ask can execute immediately, but never above its limit.
Resting limit
A buy below available offers can join a book and wait, expire, cancel, or execute if sellers reach it.
Price-time priority
Better price comes first; at one price, older displayed interest often has priority under venue rules.
06 · Components
The brokerage system map
Some brokers own this whole stack. Others are introducing brokers that use a carrying or clearing broker for custody, execution, books and records, or settlement.
Identity & accounts
Onboarding, KYC/CIP, tax status, agreements, account type, permissions, authentication, and trusted devices.
Portfolio service
Positions, cash, buying power, realized and unrealized P&L, tax lots, performance, and statements.
Order API gateway
Schema validation, authorization, rate limiting, idempotency, client order IDs, and stable external contracts.
Order management
Authoritative lifecycle, parent/child orders, amendments, cancels, execution allocation, event journal, and audit trail.
Pre-trade risk
Buying power, credit, fat-finger limits, position limits, margin, locates, restricted lists, and market status.
Execution management
Smart routing, venue adapters, FIX sessions, algorithmic schedules, execution reports, and transaction costs.
Market data
Exchange and vendor feeds, normalization, symbol mapping, NBBO, candles, corporate actions, and entitlements.
Reference data
Identifiers, listings, tick sizes, sessions, currencies, multipliers, options series, calendars, and security status.
Double-entry ledger
Immutable postings for cash, securities, fees, accruals, holds, settlements, dividends, and corrections.
Clearing adapter
Trade capture, confirmations, allocations, NSCC/DTC or clearing-firm files, fails, breaks, and settlement status.
Corporate actions
Dividends, splits, mergers, tenders, rights, voting, cost-basis adjustments, and due-bill processing.
Compliance & surveillance
Books and records, communications, suitability/appropriateness, suspicious activity, best execution, and reporting.
Reconciliation
Compare internal orders, fills, cash, positions, fees, and external statements; investigate every unexplained break.
Observability
Latency, rejects, stale data, route health, fill rates, queue lag, ledger imbalance, settlement fails, and incident tooling.
Documents & reporting
Trade confirmations, account statements, tax documents, disclosures, routing reports, and customer notifications.
07 · Execution
Where can the order go?
The customer’s broker chooses or follows instructions for an execution destination. The best displayed price matters, but so do size, speed, likelihood, price improvement, venue health, and total execution quality.
Exchange
A registered venue with rules, a matching engine, displayed or non-displayed orders, market data, and participant connectivity.
Wholesaler / market maker
A dealer may execute a retail order as principal, sometimes at a price better than the displayed national quote.
Alternative trading system
A non-exchange trading venue, often called a dark pool when interest is not broadly displayed before execution.
Internalization
A broker-dealer fills customer flow internally or against affiliated interest rather than sending it to an exchange.
What a smart order router evaluates
Market state
Protected quotes, depth, recent fills, volatility, auction phase, halts, locked or crossed markets, and odd-lot information.
Execution quality
Price improvement, speed, fill probability, partial-fill behavior, adverse selection, and historical performance by symbol and size.
Economics & obligations
Access fees, rebates, payment for order flow, customer instructions, regulatory duties, venue rules, and broker conflict management.
Payment for order flow
Why one order becomes many “child” orders
08 · Post-trade
From fill to settled ownership
Post-trade infrastructure turns millions of bilateral executions into manageable obligations. Netting greatly reduces the number and value of movements that members must settle.
Trade created
Buyer, seller, security, quantity, price, time, and venue are recorded. Execution reports update customer-facing state.
Compare and net
Eligible trades flow to NSCC. Through novation and central-counterparty processes, member obligations are netted and risk-managed.
Prepare delivery
Firms fund obligations, resolve breaks, manage securities availability, and receive settlement instructions and net positions.
Deliver and pay
DTC book-entry securities movements and funds settlement complete obligations. Ledgers, custody, and customer records reconcile.
Clearing
NSCC compares and clears eligible trades, calculates net obligations, provides central-counterparty services, and manages member risk.
Depository & settlement
DTC holds securities in fungible book-entry form for participants and processes securities movements and settlement activity.
Broker / custodian books
The customer commonly holds a beneficial interest in “street name”; the broker’s records identify the customer’s position.
What if settlement fails?
09 · Ecosystem
Everyone around the trade
The customer rarely interacts directly with most of these parties, but the system depends on their contracts, connectivity, rules, capital, and records.
Investor or trader
Supplies the economic intent and bears the account’s gains, losses, fees, taxes, and strategy risk.
Introducing broker
Owns the customer experience and relationship while possibly outsourcing custody and clearing.
Clearing / carrying broker
May custody assets, maintain books and records, execute, issue confirmations, clear, and settle.
Execution venue
Exchange or ATS where orders interact under venue rules and a matching process.
Market maker
Dealer standing ready to buy or sell, manage inventory, quote, and supply liquidity.
Clearing agency
NSCC, DTC, OCC, FICC, or other infrastructure depending on product and transaction.
Custodian & bank
Safeguards assets, moves money, provides settlement banking, and services institutional accounts.
Issuer & transfer agent
The company creates securities; transfer agents maintain issuer ownership records and process issuer actions.
Data providers
Exchanges, securities information processors, and vendors distribute quotes, trades, reference data, and analytics.
Regulators & SROs
SEC, FINRA, exchanges, state regulators, and others establish and enforce applicable requirements.
Securities lenders
Provide borrow inventory for short selling, market making, settlement, and financing.
Asset managers
Funds, pensions, advisers, and institutions place larger orders, often through institutional workflows and custodians.
10 · Instructions
Different ways to ask
An order type encodes a tradeoff among price protection, execution certainty, timing, visibility, and control. Support and exact behavior vary by broker and venue.
Market order
Prioritizes immediate execution, not a specific price. It can sweep multiple price levels and behave poorly in thin or fast markets.
Limit order
A buy cannot execute above its limit; a sell cannot execute below it. Price is controlled, but execution is not guaranteed.
Stop order
Activates after a stop condition and commonly becomes a market order. The eventual execution can differ sharply from the stop price.
Stop-limit
Activates into a limit order. It controls the worst permitted price but may remain unfilled during a gap.
Trailing stop
The stop follows favorable price movement by an amount or percentage, then stops moving when price reverses.
Auction orders
Market-on-close, limit-on-close, and opening instructions seek participation in a venue’s opening or closing auction.
Time in force and execution conditions
Day
Expires if not completed during the broker-defined trading day or session.
GTC
Good ’til canceled, subject to broker expiration policy and corporate-action handling.
IOC
Execute immediately to the extent possible; cancel the remainder.
FOK
Fill the entire quantity immediately or cancel it, when supported.
Post only
Do not remove displayed liquidity; reject or reprice if it would immediately execute, per rules.
All or none
Do not execute partially, though immediacy may not be required.
Extended hours
Eligible for premarket or after-hours sessions with typically different liquidity and risk.
Not held
Gives a broker discretion over time and price, typically in institutional workflows.
11 · Products
“Trading” is many markets
Different products have different units, venues, valuation, leverage, clearing, settlement, market hours, risks, and backend data models.
Stocks
Equity ownership in companies. Exchange-listed shares trade across fragmented venues; corporate actions and voting matter.
ETFs
Exchange-traded pooled portfolios. Authorized participants can create and redeem large blocks, helping connect price to underlying value.
Options
Contracts with strike, expiration, call/put, multiplier, exercise, assignment, complex margin, and OCC clearing.
Bonds
Debt instruments with coupons, maturity, yield, accrued interest, credit risk, and often dealer-based trading.
Mutual funds
Typically transact once daily at a calculated NAV rather than continuously in an exchange order book.
Futures
Standardized derivatives traded on futures exchanges, marked to market with margin and central clearing.
FX
Currency pairs trade in a global dealer and venue network with spot, forward, swap, and futures structures.
Cryptoassets
Venue, custody, regulation, settlement, market-data quality, and asset rights differ significantly from securities markets.
Commodities
Exposure often comes through futures, options, funds, or physical markets with delivery and storage considerations.
12 · Approaches
Types of trading and investing
These labels describe holding period, decision process, or execution method. They are not mutually exclusive and do not imply profitability.
Long-term investing
Own assets for years based on expected cash flows, diversification, goals, or broad-market exposure.
Position trading
Hold for weeks to months around fundamental, macro, thematic, or technical views.
Swing trading
Seek multi-day or multi-week price movements, commonly using technical and catalyst signals.
Day trading
Open and close positions within a day. Execution cost, leverage, speed, discipline, and loss control dominate.
Scalping
Many short-duration trades seeking small edges. Sensitive to spread, fees, queue position, and latency.
Market making
Quote both sides, earn spread or incentives, and manage inventory and adverse-selection risk.
Arbitrage
Trade related prices that appear inconsistent, while managing timing, funding, basis, model, and execution risk.
Systematic / quant
Rules or models generate signals, size positions, execute, and monitor portfolios with controlled automation.
Event-driven
Trade around earnings, mergers, restructurings, index changes, economic data, or other discrete events.
Pairs / relative value
Long one exposure and short another to express a relationship rather than an outright market direction.
Trend following
Seek persistence in price direction using systematic entry, sizing, and exit rules across assets or horizons.
Hedging
Use offsetting positions to reduce a specific risk; the goal may be protection rather than standalone profit.
13 · Controls
Why an order may be restricted
The app cannot simply forward every request. Account agreements, product rules, broker policies, regulations, venue state, risk, and operational conditions shape what is accepted.
Cash availability
Purchases require sufficient cash or margin capacity. Cash accounts also have rules around paying for trades and use of sale proceeds.
Margin
Borrowed funds increase exposure. Initial and maintenance requirements can change; a broker may liquidate positions when equity is insufficient.
Short selling
The broker generally needs a reasonable basis to believe shares can be borrowed, marks the sale short, and manages borrow and close-out obligations.
Options permissions
Strategies can require approval tiers, disclosures, financial information, margin, and controls for exercise and assignment risk.
Concentration & volatility
Brokers can impose house margin, quantity, notional, price-band, or concentration limits beyond regulatory minimums.
Restricted securities
Halts, sanctions, corporate actions, low-priced securities, unsupported listings, insider controls, or broker policy can block trading.
Market access controls
Automated pre-trade checks prevent orders exceeding thresholds, duplicating unexpectedly, or entering erroneous prices and sizes.
Frequent intraday activity
Account type, margin status, broker policy, and evolving FINRA requirements can affect frequent same-day trading. Current broker disclosures matter.
AML and fraud
Account takeover, manipulation, suspicious funding, identity mismatch, and unusual transfer behavior can trigger reviews or holds.
Buying power is not one number
Risk checks must be fast and correct
14 · Market states
The market changes modes
Trading systems must understand sessions, auctions, halts, price bands, corporate actions, and exceptional conditions rather than assuming a single continuous market.
Premarket
Usually thinner liquidity, wider spreads, different venue participation, and broker-specific eligibility.
Opening auction
Aggregates interest to establish an opening price, with imbalance messages and auction-specific instructions.
Continuous session
Orders interact continuously under venue matching rules during regular market hours.
Price bands & pauses
Limit Up-Limit Down mechanisms and other controls can prevent trades outside permitted bands or pause a symbol.
Trading halt
News, regulatory, operational, or volatility events can stop trading. Orders may be rejected, queued, or handled under specific rules.
Closing auction
Concentrates liquidity to determine an official close used by funds, indexes, benchmarks, and valuation processes.
15 · Data & operations
Correctness beats a pretty screen
Trading systems combine nanosecond market events with multi-day financial obligations. Durable event history, accounting discipline, clocks, and reconciliation are foundational.
Real-time streams
Quotes, trades, orders, executions, positions, risk, route health, and alerts move through low-latency event systems.
Immutable journal
Every state transition carries identity, sequence, time, source, and payload so history can be reconstructed.
Financial ledger
Balanced postings represent money and securities. Derived screens should never become the source of accounting truth.
Reconciliation
Internal records are compared with venues, clearing firms, banks, depositories, and custodians every day.
Surveillance
Detect manipulation patterns, suspicious trading, insider concerns, account abuse, and policy violations.
Best-execution review
Measure routes and outcomes using price, improvement, speed, likelihood, size, and comparable alternatives.
Business continuity
Backup sites, recovery objectives, kill switches, degraded modes, communication plans, and rehearsed incident playbooks.
Data governance
Entitlements, lineage, retention, privacy, clock synchronization, schema controls, and reproducible calculations.
Typical failures and responses
Stale quote feed
Mark data stale, switch source, restrict risky order types, and never present old prices as current without warning.
Unknown venue state
Stop new routing, reconcile sequence numbers, query status, and avoid replaying orders without deduplication.
Late execution report
Preserve uncertain state, handle cancel/fill races, request drop-copy truth, and reconcile customer and venue records.
Ledger mismatch
Block unsafe withdrawals or trading as needed, identify the break, post controlled corrections, and retain an audit trail.
Clearing file missing
Use operational alerts and expected-file controls, contact counterparties, reconstruct from trusted records, and manage deadlines.
Runaway algorithm
Enforce rate, notional, loss, and position limits; cancel open orders; trigger a kill switch; investigate before restart.
16 · Organization
Who builds the platform?
Team names vary, but ownership usually follows the customer lifecycle, trading path, financial records, and regulatory responsibilities.
17 · Vocabulary
The short dictionary
Core terms used throughout market structure and brokerage technology.
- Ask / offer
- Price at which a seller is willing to sell.
- Bid
- Price at which a buyer is willing to buy.
- Clearing
- Confirming, netting, risk-managing, and preparing trades for settlement.
- Custody
- Safekeeping and servicing financial assets and related records.
- Depth
- Displayed order quantity available at multiple price levels.
- Execution
- A completed match or dealer fill at a price and quantity.
- FIX
- Financial Information eXchange, a widely used electronic trading protocol.
- Liquidity
- Ability to trade with low delay, cost, and price impact.
- Margin
- Collateral and borrowing framework supporting leveraged positions.
- Market impact
- Price movement caused by executing or revealing an order.
- NBBO
- National Best Bid and Offer across protected displayed quotations.
- Netting
- Offsetting obligations to reduce required settlement movements.
- OMS
- Order management system: authoritative order lifecycle and records.
- Settlement
- Final transfer of securities and payment between obligated parties.
- Slippage
- Difference between expected or reference price and actual execution.
- Spread
- Difference between best bid and best ask.
- T+1
- Settlement on the next business day after trade date.
- Volume
- Quantity of shares or contracts executed during a period.
18 · Read next
Primary U.S. sources
Rules and market structure evolve. These regulator, SRO, infrastructure, and exchange sources support the factual portions of this guide and are the right place to verify current requirements.