A former Equifax executive is accused of unloading almost $1 million of stock options just before the company announced its huge data breach.

Jun Ying, a former chief information officer at Equifax, was charged Wednesday with insider trading.

He learned of the breach on Friday, August 25, 2017, the SEC said. That was two weeks before Equifax publicly announced that the personal information of more than 140 million Americans had been compromised.

At the time Ying learned of the breach, the stock market had already closed, according to an SEC complaint. On the following Monday, he searched online to figure out what happened to the stock of another credit bureau, Experian, after it was breached in 2015, the complaint said.

An hour later, Ying exercised and sold all his Equifax stock options, worth $950,000, according to the complaint. The SEC says he avoided $117,000 in losses that he would have incurred if had he held on to the stock until after Equifax (EFX) went public with the breach on September 7.

"Ying used confidential information to conclude that his company had suffered a massive data breach, and he dumped his stock before the news went public," said Richard Best, director of the SEC's Atlanta Regional Office, in a statement.

Separate criminal charges were also filed against Ying by federal prosecutors in Atlanta. Information on a lawyer for Ying was not immediately available. Federal prosecutors said he would be arraigned later this week.

Equifax said it reported Ying's trading activity to the government on September 15 and fired him a month later.

"We take corporate governance and compliance very seriously, and will not tolerate violations of our policies," interim CEO Paulino Do Rego Barros said in a statement.

The SEC said its investigation is ongoing.

The agency's statement of facts reads like a crime novel:

At 4:33 p.m. on August 25, Ying got an email about a mandatory conference call that would take place 12 minutes later. Ying didn't join the call, but he assigned a subordinate to listen, and the two texted each other during the meeting.

When Ying's subordinate said Ying would have to cancel his evening plans, Ying joined the call. He complained about the work, and his boss told him to call the company's global chief information officer.

At 5:26 p.m., Ying called the CIO. A minute later, he texted the same subordinate from earlier: "Sounds bad. We may be the the one breached ... Starting to put 2 and 2 together."

In September, the credit reporting agency disclosed the names of three other Equifax executives who sold shares of the credit bureau worth nearly $2 million shortly after the massive data breach was discovered.

Equifax Chief Financial Officer John Gamble sold shares worth nearly $950,000 on August 1. Joseph Loughran, Equifax's president for U.S. information solutions, sold shares worth about $685,000 on August 1 as well. And Rodolfo Ploder, president of workforce solutions, sold stock for just more than $250,000 on August 2.

The company found that none of those executives knew about the breach when they sold their stock.