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.

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

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

Custom Spoof Formula Builder

Preset model active

Keep the sliders above for the core parameters, then build your own spoof formula by dragging bubbles. Click a formula card first, then drag or tap tokens below. The live preview is rendered in LaTeX before you run it.

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.

Looks calm

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

A much bigger sell program was already pressing on the market. Then real buyers stepped back. In a thin market, the next trade can move price much more than usual. That is why the fall looked sudden and jagged, not smooth.

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
Chart of the Dow Jones Industrial Average during the May 6, 2010 Flash Crash

Price path

The drop as a picture

This chart is useful when you want to pause and ask students where the move stops looking like ordinary volatility and starts looking like a cascade.

Open Wikimedia chart source
News photo used in coverage of the trader arrested over the Flash Crash case

Public story

How the event entered the broader news cycle

This is useful when you want to shift from the market mechanism itself to how the case was later framed in public reporting.

Open Guardian report

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.
  • 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.
  • 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