Bank of America Merrill Lynch (BofAML) has agreed to pay a fine of $42m to the State of New York to settle a probe regarding a “masking” scheme in electronic trading through which it misled clients about the handling of their orders.

The probe found the bank defrauding clients by telling them that their trades were carried internally, whereas in reality they were routed to outside firms including Citadel Securities, Knight Capital, D.E. Shaw, Two Sigma Securities, and Madoff Securities.

In order to avoid detection by clients, BofAML was found to alter post-trade reports, client invoices as well as other written documentation.

The investigation also revealed that the firm made their electronic trading services look safer and more sophisticated than they actually were.

The activities took place from 2008 to 2013 and covered 16 million trade orders. The resultant fine represents the largest ever state recovery related to electronic trading.

The firm also misled traders by telling them that retail traders accounted for 30% of the orders in its dark pool whereas in reality the figure was not more than 5%.

Apart from agreeing to the fine, the firm also admitted to breaching the Martin Act, New York’s securities law, and New York Executive Law § 63(12).

New York attorney general Eric Schneiderman said: “Bank of America Merrill Lynch went to astonishing lengths to defraud its own institutional clients about who was seeing and filling their orders, who was trading in its dark pool, and the capabilities of its electronic trading services.

“As Wall Street firms offer increasingly complex electronic trading services, they cannot use new technology to exploit their clients in service of their business relationships with large industry players, like Bank of America Merrill Lynch did here.”