Local Market Simulator

Stock Market Lab

A local interactive market sandbox inspired by your Canva notes on liquidity, order-book imbalance, spoofing, and flash-crash dynamics.

Hover the highlighted terms to see short explanations of the market concepts on the page.

Order Book Liquidity Feedback Behavior Injection

Controls

Market Setup

Order Injection

Manipulation / Stress

Session

The simulator runs locally in your browser. Use aggressive orders to move price, passive orders to deepen liquidity, spoofing to distort perceived imbalance, and the sell program to stress the market into a flash-crash regime.

Live Market

Offline. Log in to join the shared market room.

Offline
Account Guest
Equity --
Rank --

In live mode, your orders and spoof actions are sent to a shared Cloudflare-backed market room. Other users connected to the same room see the same tape and leaderboard update in real time.

Manual trade popup

Open Manual Trade beside the market chart when you want to place real orders or paid spoof orders. This keeps the tape visible while you work.

Model note

The live equations are shown in the Model Inspector below.

This version uses a stochastic order-flow process with liquidity feedback and no anchor-price mean reversion.

Market Tape

Mid 100.00
Spread The spread is the gap between the best bid and the best ask. Wider spread usually means it is more expensive to trade immediately and the market is less comfortable providing liquidity. 0.30
Liquidity Liquidity measures how much trading pressure the market can absorb without large price jumps. High liquidity damps price impact. Low liquidity makes the same order flow move price much more. 1.15
Volatility 0.00
Market pinned while you use Spoof Lab

Colored overlays connect your actions to the tape: green marks buy-side interventions, red marks sell-side interventions, and amber windows show active spoofing periods.

Overall Market View

Window: latest 160 ticks

The overview chart keeps the full market path. Drag the highlighted window or use mouse wheel on the main chart to zoom into a specific time range.

Displayed Imbalance Displayed imbalance compares visible bid depth and visible ask depth. A strong imbalance can pull other traders into the same direction, even when some of that visible depth is fake or temporary.

Balanced book

Market Regime

Stable quoting

Your Position

Flat

PnL: 0.00

Demand and Supply Shift View

Interactive econ-style view

This view turns the live order book into a simple classroom picture: demand slopes down, supply slopes up, and visible pressure shifts one side left or right. The blue points show the old and new intersection so students can see how bid and ask pressure change both price and quantity.

Nonlinear Spoof / Cancellation Lab

Ask spoof

This simplified lab follows the nonlinear equations from your slide. Adjust only the core parameters and watch how cancellation efficiency, fill probability, and market push change immediately.

Parameters

Preset Formula Families

Exponential baseline loaded

Choose one ready-made formula family instead of editing tokens by hand. Some presets are intentionally flawed, so you can compare how the same parameters behave under a better or worse modeling choice.

Algorithm presets

Exponential: starts gently, then ramps up faster as the spoof order drifts closer to the touch.

Core sliders
Market state
Math

Click a token in a formula, then choose Append, Insert Before, Replace, Insert After, or Delete Selected.

Hazard formula

Size update formula

Market impact formula

Tip: click any bubble already inside a formula to remove it. This keeps the editor visual and avoids typing mistakes.

Equation View

Decay equation

Closed-form fraction

Cancel efficiency 0%
Fill probability 0%
Remaining size \(S(T)\) 0
Imbalance push 0.00
Market push 0.00
Impact effectiveness 0

Readout

Move the sliders to see how the nonlinear fraction changes cancellation efficiency and how much visible pressure is left for the market to react to.

Order Book The order book lists visible buy orders and sell orders at nearby prices. It shows where traders are willing to provide liquidity, and it helps explain why price may move smoothly or gap under stress.

Tick 0
Ask size Price Bid size

Asks sit above the mid price. Bids sit below it. The closest rows to the middle trade first.

State Snapshot

Net flow This is the latest signed order flow used in the update. Positive means buy pressure dominated the last step; negative means sell pressure dominated. There is no target price pulling the market back.
0.0
Top bid depth
0
Top ask depth
0
Spoof state
None

Event Log

Model Inspector

Live equations

Order Arrival Intensities

Equation

\[ \lambda_t^b=\mathrm{clip}\left(\lambda_0+\alpha_b\max(I_t,0)+0.25L_t,\ 0.2,\ 18\right),\qquad \lambda_t^a=\mathrm{clip}\left(\lambda_0+\alpha_a\max(-I_t,0)+0.25L_t,\ 0.2,\ 18\right) \]

Stochastic Order Flow

Equation

\[ N_t^b\sim \mathrm{Pois}(\lambda_t^b),\qquad N_t^a\sim \mathrm{Pois}(\lambda_t^a) \] \[ Q_t=M_{\text{user}}+M_{\text{program}}+V_t^b-V_t^a \]

Liquidity and Spread

Equation

\[ L_t=\mathrm{clip}\left(L_0+0.12+\frac{B^{\mathrm{sup}}_t+A^{\mathrm{sup}}_t}{1600}+0.08\max(0,1-\nu_t)-0.82\nu_t-0.014|Q_t|-0.18\mathbf{1}_{\mathrm{program}},\,0.24,\,3.60\right) \] \[ \mathrm{spread}_t=\mathrm{clip}\left(0.05+\frac{0.09}{L_t}+0.42\nu_t+0.16|I_t|,\,0.05,\,3.40\right) \]

Displayed Depth

Equation

\[ B_t^{\mathrm{disp}}=B_t+S_t^b,\qquad A_t^{\mathrm{disp}}=A_t+S_t^a,\qquad I_t=\frac{B_t^{\mathrm{disp}}-A_t^{\mathrm{disp}}}{B_t^{\mathrm{disp}}+A_t^{\mathrm{disp}}} \]

Price Update

Equation

\[ P_{t+1}=P_t+\kappa\tanh\left(\frac{Q_t}{30L_t}\right)+\frac{0.62I_t}{0.32+L_t}+\frac{0.09\,\sigma z_P(1+0.4\nu_t)}{\sqrt{L_t+0.15}} \]

Control Wiring

What each control changes

Flash Crash Story

From your Canva notes

Story mode

The Flash Crash as a simple story you can talk through

Read this section like a short slide deck. It starts with a market that looks calm, follows why Navinder Singh Sarao appears in the story, then shows how a screen signal can grow into a market-wide fall.

1 Calm screen 2 Trader 3 Fake pressure 4 Fast reactions 5 Collapse 6 Lesson

The key message: a market can look steady on screen and still become fragile very quickly.

Slide 1

Before the fall, the screen still looked normal

There were buyers, sellers, and a moving price. Nothing on the screen said "collapse" yet. The hidden problem was that this calm depended on people staying willing to trade.

Trading-floor photo
Traders at the New York Stock Exchange during reporting on the Flash Crash
Looks calm, but fragile

Slide 2

Why Sarao appears in the story

He matters here because he reportedly spent years watching the price ladder closely, learning how people react to large visible orders, and later building ways to place, cancel, and replace those orders very quickly. That does not mean he was the whole crash. It means he is one important part of a bigger story about screens, speed, and human reaction.

Sarao photo story DOJ charges
Navinder Sarao outside Westminster Magistrates' Court

Slide 3

The move: show a big visible wall, then pull it away

The point is not to sell all that size. The point is to make the market feel selling pressure. The big order sits near the price, shapes what others see, and can be removed when the market gets too close.

pull away ->

Slide 4

Why the market listens

Fast traders and machines read the screen quickly. If they think more selling is coming, they may step back or sell too. That is how a picture on the screen can turn into a feedback loop.

screen signal
->
others react
->
real selling grows

Slide 5

Why the move turned into a crash

The market was already under stress: volatility was high, liquidity was fragile, and a very large sell program was hitting E-mini futures in a mechanical way. It kept selling with volume, but did not slow down enough for price impact. Then buyers stepped back, order-book depth fell, and the same size sell orders started causing much larger price drops than normal.

Crash explainer Crash chart source
Chart of the Dow Jones Industrial Average during the Flash Crash

Slide 6

The hard part: two things can both be true

Sarao's actions mattered. But the market was also already easy to destabilize. That is the complexity: one person can matter a lot without being the full explanation.

His part visible pressure
System part thin liquidity + fast reactions

Slide 7

After the drop, the price bounced but the lesson stayed

The market recovered part of the move, but trust did not come back as quickly. Afterward, more attention was given to sudden gaps, fake visible size, and pause rules.

Drop, then rebound

Cause chain

A simple way to narrate the whole event

If you need one clean explanation, use this chain: a visible signal changes behavior, behavior changes real trading, real trading scares liquidity away, and then price moves much faster.

Large visible sell pressure appears
->
Other systems take it seriously
->
Real buyers step back
->
Price drops in bigger jumps

System stress

Why this was more than one trader or one order

If you want to expand the explanation, tell students that the crash was really a system that had already become easy to break. The spoof story matters, but it landed inside a market that was already weak, fast, and too tightly connected.

1. The market was already tired

Volatility was high and liquidity was fragile. That means the market still had prices on the screen, but not much real willingness to absorb a sudden wave of selling.

2. The sell program was too mechanical

A very large automated sell program kept selling E-mini futures quickly. It responded to trading volume, but did not adjust carefully enough for how much damage each extra sale was doing to price.

3. Fast traders did not really catch the fall

High-frequency firms did not calmly absorb the shock. Many rapidly passed risk among themselves, which made the tape look busy without truly adding stability.

4. Liquidity disappeared at the worst moment

Order-book depth fell sharply. Once visible liquidity disappeared, the same order size started pushing price much farther, so the drop suddenly felt much steeper than before.

5. The shock spread across markets

The move did not stay inside futures. Cross-market links quickly carried the stress into stocks and ETFs, so what began in one place became a wider market event.

6. Feedback loops made everything worse

Some algorithms and risk controls canceled orders or cut positions at the same time. Misleading screen signals such as spoofing were believed to have made the selling pressure look even worse.

Teaching takeaway

One sentence that keeps the explanation neutral

The cleanest neutral summary is this: the Flash Crash was not caused by one single factor. It was a systemic instability triggered by large sell orders, fragile liquidity, high-speed feedback, misleading signals, and structural weaknesses that all interacted at once.

fragile liquidity
large mechanical selling
fast reaction loops
cross-market spread
steeper price impact

Complexity

Why this story feels complicated

  • He understood how visible size on the screen could move other people.
  • He reportedly complained that this kind of screen pressure distorted the market, which makes his later use of similar tactics worth discussing.
  • The event becomes huge only because the market is already under stress, volatile, and low on real liquidity.
  • The same sell orders become much more dangerous once visible depth disappears.
  • High-speed trading, simultaneous risk controls, and linked markets can turn one shock into a system-wide event.
  • This is why the story is about both a person and a fragile system.

Sarao

Details about Sarao that are worth pausing on

  • He is often described as someone who studied the order book very closely rather than someone using a huge institutional setup.
  • He reportedly learned to watch how large orders appear, disappear, and influence other traders before they ever trade in full.
  • Accounts of the story say he later built tools to cancel and replace large visible orders quickly so they stayed influential but harder to hit.
  • In a neutral telling, spoofing should be presented as one aggravating signal inside a market that was already unstable, not as the whole explanation by itself.
  • That makes him useful in class not just as a person in the story, but as a way to ask how much of a market move comes from real trading and how much comes from what people think they are seeing.

Questions

Questions this case leaves open

  • When does a visible screen signal become a fair quote, and when does it become manipulation?
  • How much responsibility belongs to one trader, and how much belongs to a market structure that reacts too fast?
  • If many participants learn from the same distorted signal, should we focus more on the signal itself or on the reactions it triggers?
  • What kind of market is truly fair: one where everyone sees the same book, or one where nobody can create a misleading picture so easily?
Discussion article Later perspective

Demo guide

How to talk through it with the lab above

  • Lower Base liquidity so the market becomes easier to move.
  • Raise Crowd trend-following so others react more strongly.
  • Run the Sell Program to create real stress.
  • Add Spoof Ask and point at Displayed Imbalance, the main tape, and the Overall Market View.

Official source

DOJ charging announcement, April 21, 2015

Useful when you want the formal allegation language, including the description of layering, spoofing, and the claim that the conduct contributed to the Flash Crash.

Open DOJ press release

Official source

DOJ guilty plea announcement, November 9, 2016

Useful when you want the later legal outcome and a more concise summary of what the government said he admitted doing.

Open DOJ guilty plea release

News angle

Why some writers thought the case raised bigger market-structure questions

Useful when you want a more reflective discussion: not only what one trader did, but also why the market was so vulnerable to rapid feedback loops.

Open New Yorker discussion

Later perspective

Bloomberg on the later end of the case

Useful if you want to show students that the story did not end with the crash itself. It also helps frame how the event kept being reinterpreted years later.

Open Bloomberg article