How Knight Capital Lost $440M in 45 Minutes
60sThe dramatic story of a massive financial loss in a short time frame hooks viewers with a shocking real-world consequence.
βΆ Play Clip"The title promises a story about the most expensive software bug, and the video delivers exactly that with a detailed, engaging narrativeβno fluff or misleading content."
The video recounts the story of Knight Capital, a major market maker that lost $440 million in 45 minutes due to a software bug in 2012. It explains how a reused feature flag and a deployment error led to the activation of an old test function, causing massive financial damage and the company's eventual acquisition.
Knight Capital was responsible for 10% of all US stock trading and processed $20 billion daily.
SMARS was an order router that split large orders into smaller ones to fill at best prices.
The NYSE created the Retail Liquidity Program to compete with firms like Knight, forcing them to implement it.
Engineers reused an old feature flag from 2003 that triggered PowerPeg, a test function for aggressive buying.
Only 7 of 8 servers received the update, so when the flag was flipped, the 8th server ran the old PowerPeg code.
In 45 minutes, Knight executed 4 million trades across 154 stocks, losing $440 million and seeing its stock drop 75%.
What was Knight Capital's role in the stock market?
Knight Capital was a market maker responsible for 10% of all stock trading in the US, processing $20 billion in trades daily.
00:44
What was SMARS and what did it do?
SMARS was an order router that broke large orders into smaller ones to fill them across the market at the best prices.
01:28
What was the Retail Liquidity Program?
The Retail Liquidity Program was created by the NYSE to get orders back with slightly better prices, competing with firms like Knight.
01:42
How did the PowerPeg function get activated?
Engineers reused an old feature flag from 2003 that triggered a test function called PowerPeg, which bought aggressively at market prices.
02:18
Why did only one server run the old code?
Only 7 of 8 servers received the update, so when the flag was flipped, the 8th server ran the old PowerPeg code.
03:15
What were the financial consequences for Knight Capital?
Knight Capital lost $440 million and its stock dropped 75% in two days, leading to its acquisition four months later.
04:17
Knight Capital's Market Dominance
Establishes the scale of the company, making the subsequent loss more impactful.
00:44The Reused Feature Flag
Highlights a common software engineering mistakeβreusing old code without proper reviewβthat led to the disaster.
02:18The Deployment Error
Shows how a manual deployment process can lead to inconsistencies, a lesson still relevant today.
03:15The Aftermath
Quantifies the damage and the ultimate fate of the company, reinforcing the severity of the bug.
04:17[00:00] It seems like every week now we're seeing security incidents happening that would have made mainstream news just a few years ago. The big ones lately have been the North Korean hackers who Trojan whores taffed the JavaScript ecosystem, the OpenAI model that committed a felony to get answers to a
[00:14] benchmark, and that Time Anthropic accidentally open-sourced cloud code at 4am via an NPM source map. But sometimes it's good to remember that even before AI, software has always been held together with duct tape and the poverty of open-source maintainers. And there's no better
[00:29] example of this than the damage one company managed to do to itself 14 years ago this month with organic human retardedness. In about 45 minutes on a random Wednesday, Knight Capital, who at one time was responsible for 10% of all stock trading happening in the United States,
[00:44] lost $440 million and four months later was sold for parts. In today's video, we'll look into what caused the most expensive software bug in history and learn how to lose $10 million in a minute with this one weird trick. It is August 27th, 2026, and you're watching The Code Report. In 2012,
[01:00] while the rest of us were planking on gas station roofs and awaiting the Mayan apocalypse, Knight Capital was quietly operating as the biggest market maker on Wall Street as it processed $20 billion in trades every day. If you remember back to the GameStop Robin Hood saga from a few
[01:14] years ago Knight Capital was basically the citadel of its time Whenever an ape like you or me would buy a stock from a brokerage like E the brokerage didn actually execute the trade themselves Instead they often pass it off to Knight who would fill the order and pocket the spread
[01:28] At its core was a system called SMARS, which was an order router that took large orders and chopped them up into smaller orders to fill them across the market at the best prices. It was fast, reliable, and more importantly, it printed money for over a decade.
[01:42] Then, in the summer of 2012, the New York Stock Exchange decided it was sick of watching firms like Knight skim off all the retail orders before they ever reached the actual exchange. So it created something called the Retail Liquidity Program, which was essentially its own version of Knight's business model designed to get orders back with slightly better prices.
[02:00] The SEC approved it in June with a go-live date of August 1st. And because Knight was ironically also one of the exchange's biggest customers, they were forced to implement it. So that's what they started to do, and like any large financial institution responsible for the livelihood of hardworking blue-collared Americans, they did it with dignity and grace.
[02:18] Just kidding, they did it in the most lazy way possible. At the time, deep in the SMARS codebase was an old feature flag that hadn't been used since 2003, but it was never deleted. Flipping the flag would trigger a test function called PowerPeg which would execute a bunch of buy orders so Knight could watch how a stock price would respond And since the whole point was to push prices around it was designed to buy aggressively at the current market price with zero concern for getting a good deal But when the engineers in 2012 needed to switch on the new retail liquidity program
[02:48] rather than create a feature flag, they just reused the old PowerPeg one and swapped out the logic behind it. And they would have gotten away with it if this code was only running on a single server, or if they had any DevOps on the team, or if it hadn't been for those meddling
[03:00] kids and their dog, but I assume none of those were true. Back then, their deployment strategy took inspiration from the Pony Express, in that they'd have a guy manually copy code changes to their 8 servers across several days. Unfortunately, while deploying the retail liquidity change,
[03:15] they hit one of the two hardest problems in computer science, and only 7 out of the 8 servers got the update. Then, on August 1st, 2012, when Knight flipped the feature flag, 7 of their servers processed orders correctly, while the 8th one woke up PowerPeg from its 9-year hibernation,
[03:29] and it got to work on its degen strategy of buying high and selling low. Knight immediately noticed something was up, but as you can imagine, someone who gets themselves into the situation is unlikely to have a good way of getting themselves out of it.
[03:41] So they panicked, assumed the problem was in their new code, and rolled back the seven healthy servers, which meant now all eight were running PowerPeg. And to be honest, that feels like a suitable name for what the market was doing to them. In the 45 minutes it took them to figure out the issue and flip the feature flag back they had executed 4 million trades across 154 stocks and were now the proud owner of a new billion position There was even a random penny stock
[04:05] called Wizard Software Corporation that went from $3 to $14 for no reason at all. When the dust settled, Knight was down over $440 million and its stock had dropped 75% in two days.
[04:17] Four months later, it was acquired by its competitor, Gitko, and in 2017, another financial services firm called Virtue absorb what was left. The good news though, is that we definitely learned our lesson in the software industry, and nothing bad ever happened again. And that's why you need to know about
[04:31] HyperAgent, the sponsor of today's video. Maintaining a popular open source date library is mostly just three people drowning in a thousand GitHub issues about daylight savings. So my co-maintainers and I hired a team of agents to keep it alive. When a new issue comes in,
[04:45] one agent labels it and reproduces the bug, then hands it off to another that hunts down the fix and opens a draft pull request. They work around the clock, across every time zone we're asleep in, and only ping a human when it's time to actually approve a merge.
[04:58] Every maintainer shares the same agents, so once you teach them how your project works, nobody has to teach them twice. And with support for DeepSeek and the top openweight model, even the AI maintaining your open source project can stay open source.
[05:11] Try it out and grab your free credits at the link below. This has been The Code Report. Thanks for watching, and I will see you in the next one.
β‘ Saved you 0h 05m reading this? Transcribe any YouTube video for free β no signup needed.