On the morning of 1 August 2012, Knight Capital's automated order router took 212 small customer orders and turned them into millions of orders sent to US stock markets. In about 45 minutes the firm had bought and sold more than 397 million shares it never meant to trade, and the US Securities and Exchange Commission later put the loss at over 460 million dollars. A new release reached seven of eight servers, and a configuration flag meant one thing to the new code and something very different to the old code left on the eighth.
Most of what is publicly known comes from the SEC's order of October 2013, which describes the mechanism in enough detail to serve as a post-mortem.
What happened, and when
Knight was a large US broker-dealer. According to the SEC, its trading made up roughly ten percent of all volume in US listed shares in 2011 and 2012. On 1 August 2012 the New York Stock Exchange was starting a new scheme called the Retail Liquidity Program (RLP), and Knight had updated its systems so that its customers could take part.

| When | What happened |
|---|---|
| 2003 | Knight stops using an order-handling feature called Power Peg. The code stays on the production servers. |
| 2005 | A function that Power Peg depended on is moved to a different place in the router. Power Peg is not retested. |
| From 27 July 2012 | New RLP code is rolled out to the router's servers in stages over several days. One of the eight servers never receives it. |
| 1 Aug 2012, about 8:01 a.m. ET | Pre-market orders reach the router. An internal system starts emailing staff error messages that mention Power Peg. 97 are sent before the market opens. |
| 1 Aug 2012, 9:30 a.m. ET | Markets open. Unintended orders from the eighth server pour into trading centres. |
| Over about 45 minutes | Staff try to find the cause. One attempted fix makes it worse. The orders are eventually stopped. |
| 2 Aug 2012 | Knight announces it has closed out the unwanted positions at a realised pre-tax loss of about 440 million dollars. |
| 16 Oct 2013 | The SEC issues its order, with a 12 million dollar penalty. |
By the time the orders stopped, the SEC counted 4 million executions in 154 stocks. Knight was left holding about 3.5 billion dollars of shares it had bought in 80 stocks, and owing about 3.15 billion dollars of shares it had sold in 74 others.
Two loss figures circulate: about 440 million dollars from Knight's statement the next day, and over 460 million from the SEC a year later. This post uses the SEC's.
How the order router worked
The system at the centre was called SMARS. It was a high-speed automated router. Other parts of Knight's platform handed it a "parent" order, for example a customer's request to buy some number of shares. SMARS then sent one or more smaller "child" orders to exchanges and other venues, depending on where shares were available.
The key invariant of any such router is simple: the child orders together must not exceed the parent. Something has to count how many shares have been filled so far and stop sending once the parent is complete.
SMARS ran on eight servers. An incoming parent order could be handled by any of them.
The root cause: a reused flag and code that should have been gone
Years earlier, SMARS had a feature called Power Peg. Knight stopped using it in 2003, but the code was never removed. It stayed on the production servers and could still be invoked. It was switched on by a flag carried on the order.
When Power Peg was in use, a counter tracked the cumulative shares filled against the parent order and told the Power Peg logic when to stop sending children. In 2005 Knight moved that counting function to an earlier point in the SMARS code so that other logic could use it. Nobody retested Power Peg afterwards, because nobody used it. From that point Power Peg was not merely dead code. It was broken dead code: if it ever ran, it would have no way of knowing an order was filled.
In 2012 the developers writing the RLP feature decided to reuse the old Power Peg flag. In the new release, the flag set to yes would mean "handle this as an RLP order". The same release deleted the Power Peg code. On a server with the new release, this was safe.
In outline, the two versions looked like this (an illustration of the logic the SEC describes, not Knight's actual code):
# Old release (still on server 8) # New release (servers 1 to 7)
if order.flag == YES: if order.flag == YES:
power_peg(order) # no fill check route_rlp(order) # stops when filled
The deployment was done by hand, by copying the new code to each server. A technician missed one of the eight. No second person checked the work, and Knight had no written procedure requiring that. So on the morning of 1 August seven servers understood the flag in the new way and one understood it in the 2003 way.
When RLP orders arrived with the flag set, the seven updated servers handled them correctly. Orders that landed on the eighth server woke up Power Peg. It began sending child orders, and because the fill counter had been moved out from under it, it kept sending them in rapid succession no matter how many executions came back. Another part of Knight's platform did know the parent orders were complete, but that information never reached SMARS.
Forty-five minutes: detection and response
There was a warning. From about 8:01 a.m., an hour and a half before the open, an internal system sent automated emails to a group of staff. They referred to SMARS and described the error as "Power Peg disabled". Ninety-seven of them went out before 9:30. The SEC notes that these emails were not designed as system alerts and that staff generally did not read them as they arrived. They were a log, not an alarm.
Once trading began, the unwanted positions piled up in an internal account. Senior staff could see the account growing in Knight's position monitoring tool, PMON, but the tool worked against them:
- It showed positions only after trades had executed. It had no power to block orders.
- It raised no automatic alerts. A person had to be watching.
- It did not display the limit for each account, so the viewer had to already know what was too much.
- It lagged under heavy volume, which is exactly when it mattered.
The account in question had a gross position limit of 2 million dollars. The positions ran into billions, because the limit was a number written down, not a control wired to the flow of orders.
Meanwhile the technology team was debugging in live production with no written incident procedure and no clear rule about when to disconnect the router from the market. At one point they suspected the new code and uninstalled it from the seven healthy servers. That put the old Power Peg code back in charge there too, and orders with the flag set now misbehaved on all eight machines.
Why the safeguards did not catch it
Knight did have controls. Its customer-facing interface, its order management system and its internal matching system all screened for erroneous orders. But those all sat upstream of SMARS. The parent orders were legitimate, so every check passed. The fault was generated inside the last component before the market, and nothing examined what came out of it.
The SEC's findings list the gaps:
- No output check on the router. Nothing compared the orders leaving SMARS with the orders that entered it.
- No automatic stop. Firm-wide capital thresholds were not linked to order entry, so breaching them halted nothing.
- A price check that did not apply. One control capped how far an order's limit price could sit from the market, at 9.5 percent. It did not cover orders received before the open and intended for the opening auction, which these were.
- No deployment procedure for SMARS. No written steps and no second reviewer.
- No policy for unused code. Nothing required dead code to be removed, or retested if code around it changed.
- Narrow lessons from earlier incidents. In October 2011 a different Knight system kept using test data after a disaster recovery drill and lost about 7.5 million dollars. Knight fixed that system and did not ask the general question about erroneous orders from any source.
What changed afterwards
Knight removed the faulty software from its systems and traded out of the positions by the next day. Its statement said its capital base had been severely affected and that it was seeking financing. On 1 July 2013 its parent company combined with GETCO to form KCG Holdings.
The SEC found that Knight had violated the market access rule, Rule 15c3-5, which requires brokers with direct market access to have risk controls reasonably designed to stop erroneous orders and orders beyond pre-set capital limits. Knight settled without admitting or denying the findings. It paid 12 million dollars and agreed to hire an independent consultant to review its software development lifecycle, its deployment of new code, its order router controls, the automatic pre-trade linking of capital thresholds to order entry, and its incident response procedures. The details of Knight's own internal remedial work are not public.
The computer science underneath
A deployment is a period of mixed versions. Unless you stop the world, there is always a window in which some servers run the old code and some the new. Any message, flag or schema that both can see must mean something safe to both. The lesson on shipping safely with rolling, blue-green and canary releases and feature flags covers this window and the automated checks that should gate each step. Knight's rollout was staged, but nothing verified that every server ended up on the same version.
Flags are part of your interface. A flag name is a contract between whoever sets it and every piece of code that reads it. Reusing one changes the contract while old readers may still exist. A new flag would have cost nothing, and the stale server would simply have ignored it.
Dead code is a liability, not a neutral. The idea behind YAGNI, discussed in DRY, KISS, YAGNI and the Law of Demeter, is that code you do not need still has a cost. Power Peg sat unused for nine years, and untested while the code around it was refactored.
Alert on symptoms, and make alerts actionable. Observability: logs, metrics and traces draws the line between recording that something happened and telling a human who must act. Ninety-seven emails that nobody is expected to read are records. A page that fires when a router sends more child shares than its parents asked for is an alert.
Limits must be enforced in the path, automatically. A circuit breaker trips without waiting for a person, and a rate limiter rejects traffic beyond a budget before it does harm. A cap on orders per parent, on order rate per symbol, or on total exposure, placed at the router's exit, would have bounded the damage to seconds.
What an interviewer could ask from this
During a rolling deploy, old and new versions run together. What can go wrong? Anything shared can be misread: flags, message formats, database columns. Make every change backward compatible for one release, add before you remove, and verify the fleet's version before enabling new behaviour.
Why is reusing a feature flag dangerous? Old code that still reads the flag will act on its old meaning. You cannot be sure all readers are gone unless you have verified every deployed instance.
How would you have detected the missed server? Automated deployment that reports each host's version, a post-deploy check that fails if hosts disagree, and a health dashboard that shows version per instance.
The team rolled back and it got worse. Why, and what is the lesson? The code went back but the flag stayed on, so seven more servers ran the old path. Rollback must restore code and configuration together, and should be rehearsed.
Where would you put a kill switch in an order router? At the exit, after all internal logic, checking invariants such as children not exceeding parent and exposure staying under a hard limit, with the power to halt sending.
Takeaways
- The failure needed three things together: a server missed in a manual deployment, a flag given a new meaning, and old code left in production. Removing any one would have prevented it.
- Checks at the entrance of a system say nothing about faults created inside it. Validate the output of the last component before the outside world.
- Dead code keeps a claim on your system. Delete it, and never repurpose the switch that used to start it.
- An alert nobody is expected to read is not an alert, and a limit nothing enforces is not a limit.












