{adamcoding}
Part I
02
Chapter 2

The Market as a System

Let's build the mental model properly, in terms you already have.

If you had to write the spec

A market is a distributed system with a single strongly-consistent component and a large number of adversarial, self-interested clients.

The consistent component is the matching engine. It holds the order book, applies a deterministic matching algorithm (usually price-time priority), and produces an authoritative sequence of trades. It is the only source of truth in the entire system.

Everything else - your broker's UI, your data feed, the chart on your screen, the price in your strategy's variable - is a cache with unbounded staleness. This is not a metaphor. The price you're looking at is a message that was true at the moment it left the exchange, and by the time you act on it, the state has moved on.

The clients are every other participant: market makers, funds, algorithms, retail, institutions rebalancing pensions. They do not cooperate. They are actively modelling each other's behaviour and adjusting to it.

Price is not a number

The single most common beginner error is thinking of price as a scalar. It isn't. At any moment there are at least two prices, and really a whole structure:

        ORDER BOOK - BTCUSD

        SELLERS (asks)
        67,412.50   ████ 2.1
        67,411.00   ██ 0.8
        67,410.50   █████████ 4.6
        67,410.00   ███ 1.2      ← best ask (you buy here)
        ─────────────────────────  spread = 1.00
        67,409.00   ██████ 3.0   ← best bid (you sell here)
        67,408.50   ██ 0.9
        67,407.00   ███████ 3.8
        SELLERS (bids)

Two sorted heaps, essentially - bids descending, asks ascending - with the matching engine popping from both ends when they cross.

Three consequences follow immediately, and they matter more than most of the indicator theory you'll ever read:

You always buy at the ask and sell at the bid. The spread is a cost you pay on every round trip, before commission. It is invisible on your chart, which typically plots only the last traded price or the mid.

Depth is finite. If you want to buy 10 BTC and only 1.2 are offered at 67,410, you take that, then the 4.6 at 67,410.50, and so on. Your average fill is worse than the price you saw. This is slippage, and it is not random noise - it is a deterministic function of your size against the book, and it gets worse exactly when you most want to trade.

The book is not static. It updates thousands of times per second on liquid instruments, and the liquidity you can see is not necessarily liquidity you can take. Some of it will vanish as you reach for it.

Your backtest, unless you have built it very carefully, models none of this.

The candle is a lossy compression

The OHLCV bar you build strategies on is an aggregation that discards the sequence. A single 1-hour candle with a high above your target and a low below your stop is compatible with both orderings - target-then-stop and stop-then-target - and your backtester has to guess.

This is the same class of problem as a race condition: the aggregate state is consistent with multiple interleavings, and you cannot recover which one happened from the aggregate alone. In concurrency you'd solve this with a happens-before relationship. In backtesting, you solve it by dropping to a finer timeframe - or you accept that a portion of your backtested P&L is an assumption rather than a measurement.

The volume figure has a similar problem: it tells you how much traded, not whether it was aggressive buying or aggressive selling. That information exists (trade-side data, order flow), but not in a candle.

Non-stationarity, or: the workload adapts

Here is the property that has no analogue in your professional experience.

When you profile a service and find a hot path, optimising it works, and it keeps working. The workload doesn't know you profiled it.

Markets do. Not through intent, but through mechanism: if a pattern is profitable and detectable, participants trade it, and trading it removes it. Buying pressure on a signal moves the price to where the signal no longer pays. The act of exploiting an edge consumes it.

The practical consequences are severe:

  • Strategy performance decays. Not always, not uniformly, but as a rule you should assume decay and monitor for it.
  • Parameters that were optimal are not permanently optimal. Refitting has to be part of the operational plan (Part II, Chapter 9).
  • The more obvious the edge, the faster it decays. Anything with a name and a Wikipedia page has been arbitraged hard.
  • Historical data becomes decreasingly relevant as you go back, but you need long history for statistical power. This tension has no clean resolution and you will feel it constantly.

Zero-sum, negative-sum, and positive-sum

Worth being precise, because the framing determines what you're looking for.

Derivatives are zero-sum before costs, negative-sum after. Every futures contract, every CFD, every perpetual swap has a long and a short. One gains exactly what the other loses. Add commission, spread, and funding, and the sum across all participants is negative. For you to make money, an identifiable someone must lose it.

Equities are positive-sum over long horizons. Companies generate earnings; the index drifts upward. Buy-and-hold participates in that drift without needing anyone to lose. Active equity trading, however, is zero-sum relative to the index before costs - the average active dollar earns the market return by definition, minus fees.

This is why "who is on the other side and why are they losing?" is the question that separates a strategy from a story. Legitimate answers exist:

  • Forced sellers. Margin liquidations, index rebalances, redemption-driven selling. They must trade now, at any price. You can be the one who doesn't have to.
  • Risk transfer. Someone wants insurance against a crash and will pay a premium. You can sell it, and you will occasionally be destroyed by it - that's why the premium exists.
  • Behavioural bias. Systematic, documented, persistent errors. They persist because they're wired in, not because nobody noticed.
  • Structural constraints. Mandates, regulations, and capacity limits that prevent large players from taking a trade that's available to you.

"The 13 EMA crossed the 21 EMA" is not on this list. It isn't a mechanism, it's a description of two averages. That doesn't automatically mean a moving-average strategy has no edge - trend following has a plausible behavioural mechanism behind it - but the crossover isn't the edge. The mechanism is, and the crossover is a crude sensor for it.

Efficiency is a gradient

The Efficient Market Hypothesis is usually taught as a binary and is more useful as a gradient. Markets are efficient roughly in proportion to how much capital is hunting for inefficiency in them.

Highly efficient: large-cap equities, major FX pairs, index futures, on liquid timeframes. Thousands of well-capitalised professionals. Assume you have no edge here unless you can articulate a very specific one.

Less efficient: small caps, illiquid instruments, unusual assets, small-capacity niches, newer markets, anything where the total profit available is too small to be worth a fund's time.

Notice that the second list is defined almost entirely by capacity. That's not accidental. It's the structural reason retail edges exist at all, and it points at where you should be looking: not at better indicators on liquid instruments, but at places where the money available is too small to attract the people who would take it from you.