On Friday, an initial public offering by Lenexa, Kansas-based exchange operator BATS Global Markets — which had taken more than a year of careful preparation — came undone within seconds. The question now is: When will BATS try again?

What should have been a triumphant moment for CEO Joe Ratterman, 45, quickly turned into a nightmare. At 10:45am, one of the Lenexa, Kanas-based exchange operator’s 32 matching engines encountered a glitch in the computer code related to the launch of trading in the company’s own stock, which had priced at $16.00 a share the day before, March 22. When the stock opened at $15.25 on March 23, BATS appeared to have started trading successfully. But the software bug immediately began to interfere with the exchange’s messaging system, preventing prices from being continuously updated — and wreaking havoc with BATS’ new issuance.

Unrelated stock symbols, from A through BFZZZ, were also affected. Apple’s stock, AAPL, was caught up in the confusion when a single trade for 100 shares on a BATS venue caused the price to drop more than 9 percent to $542.80, setting off a circuit breaker that suspended all trading in the stock nationwide for five minutes. Ratterman, who was watching the crisis unfold over the shoulders of his trade desk managers, was stunned. “I think a lot of stomachs sank,” he says. “I know mine did.”

Within ten seconds of detecting the problem,  BATS’ software engineers had sprung into action, Ratterman says, halting trading of BATS’ shares and scrambling to isolate the coding error in the system. But the damage was done. Although the team pinned down and patched the software glitch in two-and-a-half hours, company executives — who had initially announced that trading in BATS shares would resume at 1:15pm — decided to pull the IPO after consulting with its underwriters, led by Morgan Stanley. All erroneous trade executions for the day were broken. BATS’ IPO, which had been designed to put NYSE Euronext and Nasdaq OMX on notice that their powerful duopoly in company listings faced a new challenger, had failed.

Although BATS’ core trading business is unlikely to be affected by its botched IPO, its public market malfunction could not have come at a worse time given regulators’ heightened sensitivity to technical issues in electronic trading. No one has yet forgotten the carnage wrought by the “ flash crash” on May 6, 2010, which hewed nearly 1,000 points from the Dow Jones Industrial Average in minutes. Although the fallout from BATS’ coding error was well-contained, the inability of the company to identify the problem prior to inaugurating trading in its own shares — despite months of rigourous testing — may attract regulators’ interest. On the day itself, Ratterman says, his team reached out to the Securities and Exchange Commission within minutes to alert them to the fact that BATS was experiencing a technical issue affecting its primary market.