As hedge fund manager Buford Scott sat at home, watching the TV in shock as it emerged Britain had voted to leave the European Union, his computer-based trading models were quietly boosting his business by 1.5 percent.
Scott's algorithm-driven fund, and others like it, beat hedge funds run by humans on Brexit night, not because the computers had correctly predicted the results of the June 23 referendum, but because they followed trends already in place.
Computer-driven funds placed bets on safe-haven assets like the yen and gold, which had performed well in the six months leading up to the vote, against riskier currencies like the Mexican peso - a play yielding a more than 7 percent return on June 24.
Hedge funds on average were down 0.18 percent on the day of June 24, while trend-following machine-based strategies gained 0.71 percent, according to data from industry tracker Hedge Fund Research (HFR).
Some of the biggest hedge funds' computer-run strategies - also known as systematic or quantitative - made huge gains in the aftermath of the vote for Brexit.
British systematic firm Winton Capital, which manages more than $30 billion, made a gain of 3.1 percent on June 24, while Greenwich, Connecticut-based AQR's $13.3 billion computer strategy returned 5.2 percent - about $700 million.
Polls had shown the Leave and Remain camps neck-and-neck before the referendum. But partly on the view that undecided voters tend to opt for the status quo, bookmakers and betting exchanges had largely predicted Remain would win comfortably. Most players in financial markets agreed.
"Almost no one was betting on the actual outcome of Brexit," said GAM portfolio manager Anthony Lawler in London, a hedge fund investor whose firm recently bought systematic investment manager Cantab Capital Partners, which made 4.1 percent in the year to June 27.
"Man chose to reduce risk given the unknown. Machines chose to be long safe-haven assets because that trend was already in place. Machines won."
This does not necessarily mean machines would tend to outperform during big global events - a Remain vote might well have seen humans come out top - or during unexpected twists. Machine models were down 2.42 percent in 2015 while hedge funds on average were down 1.12 percent, according to HFR.
But in this case machines fared better because, with no preconceived ideas about the result, they followed the same strategies as previously, strategies which a Leave vote happened to favour.
The few non-systematic hedge fund managers who did make money in the immediate referendum aftermath were highly contrarian, such as Crispin Odey, a Brexit backer who made 15 percent by betting his $10.2 billion fund's assets on a fall in financial markets and a surge in safe-haven gold.
Scott, the managing partner of Stelrox Capital, who was watching the referendum from his study in Wimbledon, south-west London, said his models had put on a small short sterling position, which brought some profit - the pound tumbled as much as 12 percent on June 24 to a 31-year low.
But it was his short positions on emerging currencies like the South African rand and Mexican peso, which also dived as investors fled to safety, and his longs on the low-risk dollar and yen, that brought the biggest return.
"The risk environment was obviously high ... we hope we design our models so that these big, unexpected events are catered for, and we do that by diversifying across scores of currency pairs." he said. "I was watching TV and had my computer screens up in the same room, so I could watch it all."
While Scott let his model run without interference, some fund managers intervened to tweak their machine strategies in the run-up to the vote, reducing the size of their trading positions to protect themselves from big adverse market swings.
Demand for trend-following computer strategies is growing, with such funds seeing inflows of $7.3 billion in investor money in the first six months of 2016, industry tracker Eurekahedge told Reuters. While there is no direct data comparison for the first half, the overall hedge fund industry saw outflows of $15.1 billion in the first quarter, according to HFR.
"Investors are turning to alternatives, including quantitative strategies," said Christopher Palazzolo, principal at AQR Capital Management Europe.