How the market data works

Every chart on this site, from the day trading simulator to the daily challenge and the game, is synthetic: prices are generated in your browser by a statistical model. No real ticker, exchange data or historical chart is shown. This page explains how the prices are made, how trades are calculated, and how we checked that the result behaves like a real market.

Why synthetic data

How prices are generated

Each candle is a five-minute bar with open, high, low, close and volume. The model combines four pieces that describe well-known properties of real intraday returns:

  1. Volatility clustering (GARCH(1,1)). Volatility depends on recent moves, so calm stretches and wild stretches come in clusters, as they do in real markets.
  2. Fat tails. Price shocks are drawn from a Student-t distribution with 5 degrees of freedom instead of a normal curve, so occasional large candles happen more often than a bell curve would predict.
  3. Intraday U-shape. Volatility is higher near the open and the close of each 78-bar trading day and lower around midday.
  4. Trend regimes. The market switches at random between gently rising, gently falling and directionless phases that last 15 to 59 bars.

Highs and lows add random wicks scaled to the current volatility; volume grows with the size of each move. A full trading day is 78 bars, so a 180-bar session crosses into the next day twice, and volatility jumps at each new open. The model uses a seeded random number generator, so the same seed always produces the same market.

How we checked it

We generated 300 sessions of 390 bars each and measured them against stylized facts of intraday stock returns that are widely described in market research. The right-hand column is the target we aimed for, not a measurement from a specific dataset:

Property Synthetic result Target (widely reported for 5-minute stock returns)
Kurtosis of returns 17.4 Fat tails, well above 3 (normal)
Autocorrelation of returns, lag 1 0.015 Close to 0
Autocorrelation of absolute returns, lag 1 / lag 10 0.20 / 0.13 Positive and slowly decaying
Volatility at open and close vs midday 2.07× Clearly higher at open and close
Median absolute move per day 1.29% (95th percentile 4.0%) Typical range for liquid stocks

We also tested simple rules on the guessing game, built exactly like the game itself, over 200,000 rounds: always guessing up was right 49.7% of the time, repeating the last candle 51.1%, betting against the last candle 48.9% and following the 10-bar trend 52.9%. No simple rule we tried did much better than a coin flip. You can check every number yourself: the generator and the test script are printed in full below.

The model does not reproduce everything about real markets: there are no news events, gaps between days, order books, spreads or reactions to your own trades.

How trades and P&L are calculated

Because real trading has costs and the model has limits, results on this site are not a prediction of real trading results. See the disclaimer.

Reproduce the numbers

Save the two files below in one folder and run node stats.mjs (Node.js 18 or newer; it takes about 20 seconds). The seeds are fixed, so you get exactly the numbers on this page. market.js is the same generator the simulator and the game run in your browser.

market.js

// Synthetic intraday market v2: GARCH(1,1) volatility + Student-t shocks + regime drift
// + intraday U-shaped volatility (busy open/close, quiet lunch). Deterministic per seed.
(function(root){
function mulberry32(a){return function(){a|=0;a=a+0x6D2B79F5|0;let t=Math.imul(a^a>>>15,1|a);t=t+Math.imul(t^t>>>7,61|t)^t;return((t^t>>>14)>>>0)/4294967296}}
function gauss(r){let u=0,v=0;while(!u)u=r();while(!v)v=r();return Math.sqrt(-2*Math.log(u))*Math.cos(2*Math.PI*v)}
function studentT(r,nu){let c=0;for(let i=0;i<nu;i++){const z=gauss(r);c+=z*z}return gauss(r)/Math.sqrt(c/nu)*Math.sqrt((nu-2)/nu)}
// n bars of 5m (78 per 6.5h session). opts: {start}
function genBars(seed,n,opts){
  opts=opts||{};const r=mulberry32(seed>>>0);let p=opts.start||100;
  const base=0.0016,omega=base*base*0.04,alpha=0.08,beta=0.88; // alpha+beta<1, long-run var = base^2
  let h=base*base,eps=0,drift=0,left=0;const bars=[];
  for(let i=0;i<n;i++){
    if(left<=0){const k=r();drift=k<0.3?base*0.18:k<0.6?-base*0.18:0;left=15+Math.floor(r()*45)}
    left--;
    const tod=(i%78)/77,u=1+0.9*Math.pow(2*tod-1,2); // U-shape intraday
    h=omega+alpha*eps*eps+beta*h;
    const sd=Math.sqrt(h)*u/1.3;eps=sd*studentT(r,5);
    const ret=drift+eps,o=p,c=o*Math.exp(ret);
    const wick=sd*Math.abs(gauss(r))*0.7;
    const hi=Math.max(o,c)*Math.exp(wick*r()),lo=Math.min(o,c)*Math.exp(-wick*r());
    const v=Math.round((800+4000*Math.abs(ret)/base)*u*(0.6+0.8*r()));
    bars.push({o,h:hi,l:lo,c,v});p=c}
  return bars}
root.TPMarket={genBars,mulberry32};
})(typeof window!=='undefined'?window:globalThis);

stats.mjs

// Validate synthetic market vs stylized facts of real intraday returns.
import fs from 'node:fs';
import { fileURLToPath } from 'node:url';
eval(fs.readFileSync(fileURLToPath(new URL('./market.js', import.meta.url)), 'utf8'));
const { genBars, mulberry32 } = globalThis.TPMarket;
const mean = a => a.reduce((s, x) => s + x, 0) / a.length;
function acf(a, lag) { const m = mean(a); let n = 0, d = 0; for (let i = 0; i < a.length; i++) { d += (a[i] - m) ** 2; if (i >= lag) n += (a[i] - m) * (a[i - lag] - m); } return n / d; }
function kurt(a) { const m = mean(a), v = mean(a.map(x => (x - m) ** 2)); return mean(a.map(x => (x - m) ** 4)) / v / v; }
const S = 300, N = 390; // 300 sessions x 5 days of 5m bars
let rets = [], acf1 = [], acfAbs1 = [], acfAbs10 = [], dd = [], dayMove = [], open = [], mid = [];
for (let s = 1; s <= S; s++) {
  const b = genBars(s * 7919, N, { start: 100 });
  const r = b.map(x => Math.log(x.c / x.o)); rets.push(...r);
  acf1.push(acf(r, 1)); acfAbs1.push(acf(r.map(Math.abs), 1)); acfAbs10.push(acf(r.map(Math.abs), 10));
  let pk = b[0].o, m = 0; for (const x of b) { pk = Math.max(pk, x.c); m = Math.min(m, x.c / pk - 1); } dd.push(m);
  for (let d = 0; d < 5; d++) { const day = b.slice(d * 78, d * 78 + 78); dayMove.push(Math.abs(day[77].c / day[0].o - 1));
    day.forEach((x, i) => { const a = Math.abs(Math.log(x.c / x.o)); if (i < 6 || i > 71) open.push(a); else if (i > 30 && i < 48) mid.push(a); }); }
}
const pct = (a, q) => { const s = [...a].sort((x, y) => x - y); return s[Math.floor(q * (s.length - 1))]; };
const f = (x, d = 3) => x.toFixed(d);
console.log(JSON.stringify({
  sessions: S, bars_per_session: N,
  return_kurtosis: f(kurt(rets), 2) + '  (real 5m equity: fat tails, typically >5; normal=3)',
  acf_return_lag1: f(mean(acf1)) + '  (real: ~0, no easy predictability)',
  acf_absret_lag1: f(mean(acfAbs1)) + '  (real: clearly >0, volatility clustering)',
  acf_absret_lag10: f(mean(acfAbs10)) + '  (real: still >0, slow decay)',
  intraday_U_ratio_open_vs_lunch: f(mean(open) / mean(mid), 2) + '  (real: >1.5)',
  median_daily_abs_move_pct: f(pct(dayMove, 0.5) * 100, 2) + '%  (large-cap stock: ~0.7-1.5%)',
  p95_daily_abs_move_pct: f(pct(dayMove, 0.95) * 100, 2) + '%',
  median_5day_max_drawdown_pct: f(pct(dd, 0.5) * 100, 2) + '%',
}, null, 1));

// Guess-the-next-candle game: simple rules vs the hidden candle, built exactly like the next-candle game tool
// (random warm-up skip 0-77, 60 visible bars, candle 61 is the answer). Deterministic.
const GR = 200000, gr = mulberry32(20261126);
let up = 0, rep = 0, trend = 0, rev = 0;
for (let g = 0; g < GR; g++) {
  const skip = Math.floor(gr() * 78), b = genBars((gr() * 4294967295) >>> 0, skip + 61, { start: 20 + gr() * 180 }).slice(skip);
  const ans = b[60].c >= b[60].o, last = b[59].c >= b[59].o, tr = b[59].c >= b[50].o;
  if (ans) up++; if (last === ans) rep++; if (last !== ans) rev++; if (tr === ans) trend++;
}
const gp = x => (x / GR * 100).toFixed(1) + '%';
console.log(JSON.stringify({ game_rounds: GR, always_up: gp(up), repeat_last_candle: gp(rep), opposite_of_last_candle: gp(rev), follow_10_bar_trend: gp(trend) }, null, 1));