Saltar al contenido
Vitali Giggy
Volver a Proyectos

105

market-sim

Año
2026
Estado
Terminado

VeredictoLos patrones salen del puro ruido

Esta página solo está disponible en inglés.

Pregunta

¿Son reales los patrones de los gráficos? Construir un mercado en el que todos los operadores lanzan una moneda y ver si siguen apareciendo soportes, resistencias y canales.

Por qué importa

Technical analysts draw support lines, resistance lines, channels and cup-and-handles, and argue they carry meaning: crowd psychology, a predictive edge. Before trading any pattern, it is worth knowing whether pure randomness draws the same picture. This project is that gut-check, sitting underneath the Golden Cross and RSI backtests in the Lab.

Datos

No market data goes into the core experiment: every trade is generated. It is a Python recreation of the experiment in the YouTube video "I made a Market Simulation to see if Patterns are Real" (youtube.com/watch?v=oWheof70O9g). The static chart is 50,000 simulation steps with seed 42; the same seed always reproduces the same market.

For comparison, a second test computes the same statistics on real Ford and Apple daily closes and on pure Gaussian noise, a control with no fat tails and no clustering.

Método

A continuous double-auction matching engine with a resting limit-order book, covered by unit tests so fills are exactly right. Every agent is a coin-flipper: buy or sell with equal odds, at a random size from 1 to 5, with no trend-following, no memory and no view on value. The one knob is the share of orders that are market orders (they move price) versus limit orders (they rest in the book); about 0.5 keeps price moving while the book stays two-sided.

The null is the design itself: if the patterns appear here, they need no intelligence to exist. The trade tape is turned into candles, and a depth heatmap shows where resting orders sit over time. A second script checks two "stylized facts" of real returns, fat tails and volatility clustering, against Ford, Apple and the Gaussian control.

Resultado

The patterns show up, every time. The coin-flip market prints trends, ranges and levels a technician would draw, and the depth heatmap shows why: bright bands of resting liquidity sit exactly where price stalls and bounces. When price drifts up and comes back down, it runs into buy orders left at the old levels; that leftover liquidity absorbs selling and pushes it back up.

The stylized-facts chart is more mixed, and worth saying so. The simulated returns have fat tails like Ford's and Apple's, unlike the Gaussian control. Volatility clustering starts strong but fades toward zero within a few lags, while in the real stocks it stays clearly positive across all 30 lags shown. The simulation reproduces the patterns, not every property of a real market.

Gráfico de velas de un mercado hecho solo de operadores aleatorios, semilla 42, con un mapa de profundidad debajo. El precio forma tendencias y se frena en niveles que coinciden con bandas de órdenes en reposo: los patrones salen del libro de órdenes, no de nadie que prediga.
Dos paneles que comparan la simulación con Ford, Apple y ruido gaussiano. Izquierda: autocorrelación de los rendimientos absolutos; la simulación empieza más alta pero cae hacia cero más rápido que las acciones reales. Derecha: la simulación tiene colas gruesas como las acciones reales, a diferencia del control gaussiano.

Veredicto

Chart patterns appear even with coin-flipping traders, because the order book remembers resting orders. They are real in the sense that they genuinely appear, but not because anyone is predicting anything. Seeing a pattern on a chart is therefore not evidence of an edge; it is what a book with memory produces on its own.

Qué probaría después

Add a plain random-walk candle generator as a contrast, to show that even without an order book, randomness looks like a chart. Then build a proper pattern detector for trend channels and triangles, to measure how often named patterns appear in pure noise versus real data, instead of judging it by eye.

Código