BUILD · M / W / F
The Quant Lab Series * Flash Crash Lab 2

One idea worth returning to.
The Swimming Pool
On March 10, 2026, I made a terrible decision: I turned on production.
To be fair, it did not feel terrible at the time. It felt magnificent. Outside my window, the Hong Kong skyline hummed with its usual relentless energy, and inside, illuminated by the steady glow of an iMac, sat something I had built out of thin air. Twelve days earlier, I had started with nothing more than a blank folder, two decades of rusting software intuition, an old trader’s instinct for market structure, and an AI coding agent named Codex. Now, against all reasonable expectations, I had a functioning quantitative trading lab.
Behind the glass lay seven years of tick-by-tick Bitcoin history, meticulously replayed and stress-tested. Ninety-seven simulated trades sat in the final research run, bound together by a deterministic strategy that boasted an extraordinary cumulative return of seventy-nine R. The sandbox was a graveyard of failed hypotheses, surviving parameters, execution logs, unit tests, annotated charts, and files named with increasing gravity. The system, affectionately dubbed The Alligator, had passed every statistical exam, Monte Carlo simulation, and sanity check I knew how to throw at it. So naturally, I decided it was time to let it hunt with real money.
This is roughly the exact logic employed by enthusiasts who construct elaborate sailboats inside suburban swimming pools. The sandbox had water. The boat floated. What could possibly go wrong?
The production build looked undeniably formidable. It was no longer just a script running in a terminal; it was an ecosystem. The Alligator had a scheduler, a background watchdog, an infrastructure heartbeat, structured logging pipelines, direct exchange connectivity, local position reconciliation, and automated risk parameters complete with stop-loss and take-profit management. It even featured a Telegram cockpit complete with TOTP-protected multi-factor authentication, allowing me to remotely inspect, arm, or execute a kill-switch on an autonomous crypto predator straight from my mobile phone.
I could type /status to inquire if the creature was breathing. I could send /kill to instantly prevent new entries. I could send /unkill to permit it to stalk the order books once more. I found this capability disproportionately entertaining. Twenty years after walking away from serious software engineering, I was strolling through the streets of Central carrying a pocket-sized remote control for an algorithmic reptile. My younger computer-science self would have been thoroughly mesmerized. My older executive self should probably have been deeply concerned.
At first, nothing dramatic happened, which turned out to be the most agonizing part of the process. The Alligator was a patient hunter by design. It did not trade on noise or churn contracts every hour. It waited for precise conditions: systemic weakness, overcrowded leverage, structural exhaustion, and an unequivocal breakdown. It could easily sit motionless for days at a time.
Thus, my initiation into live quantitative trading was not characterized by adrenaline-pumping action, but by the hypnotic monotony of monitoring system logs.
Green.
Green.
Green.
Still green.
No signal. No position. No drama. I had spent nearly two weeks engineering a complex machine whose primary operational talent appeared to be deliberate inaction. It was a triumph of digital restraint.
A Tiny Nocturnal Company
Then, inevitably, reality intervened. One afternoon, a vital segment of the incoming data stream silently ground to a halt. Open interest stopped updating. The strategy relied heavily on open interest data; leverage crowding was one of its mandatory confluence criteria. Without fresh open interest readings, the Alligator could still process price action and funding rates, but it had effectively lost its sense of smell.
The main process was still running. The signal engine was active. The background scheduler reported perfect health. Yet one of the core inputs feeding its judgment had quietly frozen. Production had introduced me to a subtle and pernicious class of software failure: nothing visibly crashes, no exceptions are raised, and no dramatic red alerts fill the screen. The machine simply becomes less true.
We descended into the plumbing, debugging endpoints, caching layers, data freshness timestamps, and underlying network latency. At one point, our regional VPN became a prime suspect. The iMac was in Hong Kong, the execution servers were routed elsewhere, an IP address had quietly shifted, and a third-party data provider began serving cached responses differently. I remember staring at the network trace and shaking my head. I had set out to study macro market cascades in Bitcoin; why was I now spending my afternoons debugging international network topology?
The Alligator was entirely unconcerned with my existential questions. It simply wanted fresh open interest figures. We patched the pipeline, restored data integrity, and watched the numbers move again. The creature resumed breathing, and I became slightly less naive.
Then the execution scheduler began exhibiting erratic behavior. A research script inside a sandbox is an obedient creature: you trigger it, it executes sequentially, and it terminates cleanly. Production software, by contrast, possesses a complex social life. It wakes itself up on clock cycles, communicates with foreign APIs, writes persistent state to local databases, polls external processes, handles dynamic restarts, and leaves subtle digital artifacts behind. Occasionally, at three o’clock in the morning, it decides that an adjacent background process has died when that process was merely taking a moment to catch its breath.
To fix this, we introduced a scheduler. Then we built a watchdog to monitor the scheduler. Then we realized the watchdog needed a dedicated heartbeat mechanism so it could distinguish between a dead scheduler and a quiet one. Then we spent hours tuning the heartbeat thresholds because an overenthusiastic watchdog is vastly more dangerous than the process it is assigned to monitor.
At a certain point, I realized I had inadvertently built a miniature digital corporate bureaucracy. The scheduler performed the work; the watchdog supervised the scheduler; the heartbeat proved the scheduler was working; Telegram reported status updates to upper management; and upper management was me, lying awake in the dark staring at an iPhone screen. It felt less like running a high-frequency trading desk and more like managing a tiny, nocturnal company staffed entirely by overly nervous microservices.
Yet through all of this, my capital remained completely untouched.
May 18
Until May 18.
On that afternoon, the Alligator finally picked up a scent. A genuine signal materialized—not a historical replay from a CSV file, nor a sandbox trial, but a live production setup in a volatile Bitcoin market. After weeks of silent monitoring, the multi-layered criteria aligned perfectly: regime confirmation, structural fragility, and price trigger. The jaws opened wide.
This was the moment. The very first fully autonomous trade entry.
The order was instantly rejected.
I stared at the console in disbelief. The Alligator had spent two months preparing for dinner, only to fail to put the fork in its mouth when the feast was served. The system had effectively blocked its own trade.
My initial reaction was to suspect standard technical friction: invalid API permissions, endpoint timeout, contract formatting errors, or perhaps a missing exchange parameter with a cryptic name like tdMode. Codex and I immediately began digging through the raw exchange logs, tracing the request payload line by line.
Then the mathematical reality surfaced. The strategy’s risk engine was configured to risk a fixed dollar amount, roughly $5,000 on the trade. That seemed perfectly reasonable on paper. However, what I had overlooked in the rush of transitioning from research to production was that risk budget and notional position size are fundamentally different entities.
The specific market geometry required a very tight initial stop-loss placement. A narrow stop-loss implies that to lose a fixed dollar amount if stopped out, the total underlying position size must be enormously large. A tight stop, combined with a fixed dollar risk, yields massive notional leverage.
I looked at the calculated order size, then at the exchange’s maximum allowable leverage limits, and then back at the bot. The algorithm had decided that my modest $5,000 risk budget justified the balance sheet of a small hedge fund.
Fortunately, someone had foreseen this exact scenario. Unfortunately for my immediate trading ambitions, that someone was me. Weeks earlier, an instinct for self-preservation had led me to hardcode an unyielding safety parameter into the execution layer: the system was explicitly forbidden from utilizing more than seventy percent of the exchange’s maximum position limit.
The order had not failed because the platform was broken. The order had failed because the safety governor had worked precisely as designed. Past Robin had stepped in to protect Present Robin from Present Robin’s own unchecked quantitative strategy. It was an amusing, albeit frustrating, realization.
We left the safety buffer entirely intact. There were no desperate overrides, no raising of leverage parameters, and no hasty configuration changes. The trade window passed, the market drifted onward, and the Alligator remained hungry.
The Position That Disagreed With Itself
A few days later, the market presented another opportunity. This time, the calculated position size fell comfortably within all risk parameters, and the order sliced through to the order book without friction. For the very first time, we had a live, active position: a real exchange, a real Bitcoin perpetual swap contract, real capital, an active stop-loss, and a set profit target.
I monitored the screen with a mixture of professional satisfaction and deep suspicion. The machine had finally crossed the boundary separating theoretical modeling from economic reality. For months, every trade had lived in the sterile, frictionless environment of historical charts and simulated fills. Now, a position existed out in the wild, subject to the real world.
Satisfied that the order parameters were settled, I went to sleep.
The following morning, I opened the dashboard to review the position, and a cold feeling immediately set in. Something was wrong. The local database indicated one state, while the exchange reported something entirely different. There are few experiences quite like realizing your autonomous trading script might not actually know what position it currently holds.
I opened the OKX exchange portal directly, pulled up the raw bot logs, cross-referenced the Telegram event stream, and began cross-checking timestamps. The physical position indeed existed on the exchange, but the local accounting module had become thoroughly confused by an unexpected execution state.
I manually intervened—closing open legs, canceling orphaned protective orders, and issuing a remote kill command to prevent further entries. Then Codex and I engaged in what was becoming our standard morning routine: digital forensics. What did the bot believe had happened? What had the exchange actually executed? When did the state drift occur? What was written to the local disk, and what had actually filled on the order book?
The theoretical elegance of the strategy was no longer relevant. The only question that mattered was whether two independent computer systems could maintain an absolute consensus on what I currently owned.
We rebuilt the state-reconciliation module from the ground up, enforcing synchronous state checks after every transaction. Yet production was not done teaching lessons. Soon after, it revealed an even subtler structural friction.
The Alligator was designed with the capability to generate multiple logical entries within a single trending move. In our backtesting environment, these entries were treated as entirely separate, distinct trades: Trade A had its own entry price and protective stop, while Trade B had its own independent logic, risk profile, and exit triggers. The strategy backtester tracked them individually; the trade journal cataloged them separately; conceptually, they were distinct entities.
The exchange, however, operated on a far simpler reality. The account was executing in net position mode. From the exchange’s perspective, two sequential short orders in the same contract were not two separate philosophical events. They were simply one single, consolidated short position with an aggregated size and a single blended average entry price.
We had engineered an elegant internal ontology. The exchange operated on basic arithmetic.
I remember looking at the screen and thinking: No, these are two entirely different trade ideas.
The exchange API effectively replied: That is charming. Now they are one.
We adapted once again, redesigning the execution architecture to continuously map multiple strategy-level logical positions onto a single consolidated exchange-level position. Local state could maintain three independent trade concepts while the exchange maintained one net position, and both representations had to remain continuously reconciled.
As the days turned into weeks, production systematically dismantled every comfortable assumption we had taken for granted in the sandbox. A stop order could exist in local memory but fail to register on the exchange due to rate limits; a position could fill before its accompanying protective orders were confirmed; a valid signal could be computed using a slightly delayed data point; a watchdog process could mistake temporary network silence for system failure; and an exchange could reject a mathematically sound order simply because contract sizes, margin modes, or step-size rounding rules didn’t care about the beauty of a backtest.
Layer by layer, reality forced its way into the system. Not by introducing complex new mathematical parameters, but by demanding operational rigor. We added preflight API checks, explicit order readbacks, fail-closed safety routines, defensive error handling, granular health states, and an immutable event ledger. The software grew less elegant on paper, but infinitely more resilient in practice. I stopped looking for exciting features and began taking profound comfort in quiet, boring status logs. Green became the most beautiful color in the world.
T008 Was Biting the Table
Yet as the system grew mechanically sound, a new realization began to emerge: not about the software, but about the nature of the trades themselves.
The Alligator would initiate a campaign. The initial entry was often sharp, catching the exact inflection point of a breakdown. But as price dropped lower, subsequent signal triggers would fire, adding additional positions to the stack. The backtest had validated this approach, showing that secondary entries historically added positive expected value. Mathematically, the logic was sound.
Visually and intuitively, however, watching it unfold live felt increasingly reckless.
One particular market campaign brought this issue into stark focus. The primary short entry caught a massive, clean downward expansion as an absolute textbook trade. A second short entered further down the move. A third signal triggered lower still. By the time a fourth short order was submitted near the very bottom of the move, it looked less like a calculated statistical edge and more like an algorithm that had forgotten the fundamental difference between systematically hunting a market and mindlessly chasing it.
I pulled up the execution chart, staring at the cluster of trade markers labeled T005, T006, T007, and T008.
I picked up a notepad and wrote down four lines:
T005 was the bite.
T006 was chewing.
T007 was chasing crumbs.
T008 was biting the table.
The phrasing was funny enough that it stuck, but the underlying lesson was serious. The initial entry had captured a genuine shift in market structure; the final entry was merely reacting to momentum that had already spent itself. The algorithm treated every valid signal trigger as an isolated, independent opportunity. My eyes, however, were seeing a single extended campaign, a movement that had already delivered its primary expansion, leaving behind an animal that was simply refusing to leave the table.
The Open Ocean
By late spring, the Alligator had been entirely transformed. It had begun its life as a clean, elegant set of equations inside a pristine research folder. Now, it bore the hard-won marks of live deployment.
A data pipeline had gone stale; a regional VPN had forced an investigation into geography; a scheduler had required a watchdog; the watchdog had required a heartbeat; my phone had acquired a remote kill-switch; an exchange had rejected our initial order; a seventy-percent safety rule had quietly saved us from our own leverage math; a live position had exposed a state synchronization bug; and an exchange had flattened our nuanced trade ideas into simple net position arithmetic.
The seven-year backtest had prepared me for none of this because backtests live safely in the past. Production lives entirely in the present, where every decision carries immediate consequences.
Late at night, another Bitcoin chart glowed against the dark room. The system was running quietly in the background, submitting heartbeats, polling APIs, and waiting for the next structural shift. The Alligator had finally stepped out of the swimming pool and into the open ocean. And for the first time since this project began, I realized that the primary engineering challenge was no longer teaching the machine when to bite.
The real challenge was teaching it when to stop eating.