If you buy or sell stocks, it’s handy to test your strategy before you put real money at risk. Researchers devised a fresh approach to simulating market behavior.

What's new: Andrea Coletta and colleagues at Sapienza University of Rome used a Conditional Generative Adversarial Network (cGAN) to model a market’s responses to an automated trader’s actions.

Key insight: Previous approaches tested a simulated trader in a virtual market populated by other simulated traders. However, real-world markets tend to be too complex to be modeled by interactions among individual agents. Instead of simulating market participants, a cGAN can model aggregated sales and purchases in each slice of time.

Conditional GAN basics: Given a random input, a typical GAN learns to produce realistic output through competition between a discriminator that judges whether output is synthetic or real and a generator that aims to fool the discriminator. A cGAN works the same way but adds an input — in this case, details about individual buy and sell orders and the overall market — that conditions both the generator’s output and the discriminator’s judgment.

How it works: The authors built a simulated stock exchange based on the Agent-Based Interactive Discrete Event Simulation (ABIDES) framework to match buy and sell orders. They trained a cGAN to generate such orders based on two days of market data for Apple and Tesla stocks. Then they added orders by an independent trader.

  • The authors simulated the stock market as a whole by connecting these components in a feedback loop. The first time through the loop, the exchange received historical buy and sell orders; subsequent times, it received orders from the agent and/or the cGAN.
  • The exchange paired offers with purchases. Then it sent details for each order (price, volume, buy or sell, and time since the previous trade) and the market as a whole (best price, highest volume, average price, and time when the details were calculated) to the cGAN.
  • Given the details provided by the exchange, the cGAN generated a new order along with a wait time. After waiting, it passed the order to the exchange, which triggered the cGAN to generate another order.
  • For a half-hour within a period of several hours, an independent agent sent its own purchases to the exchange. In each of 30 minutes, it observed the trading volume and issued a buy order based on its observation. The authors set the volume: 1, 10, or 25 percent of the observed volume.

Results: The authors checked statistical similarity between historical and cGAN orders in terms of price, volume, direction (buy or sell), and frequency distributions. In particular, they looked at Tesla shares on May 2 and May 3, 2019, and plotted the distributions. The real and synthetic distributions matched fairly closely. When they ran the simulation using historical orders plus cGAN orders, the price rose slightly during the 30 minutes when the agent would have been active. Given the orders generated by the cGAN and the agent, the price rose by an order of magnitude more and returned to normal shortly after the agent stopped trading, demonstrating the simulation’s response to the agent’s activity.

Why it matters: GANs are usually associated with image generation. This paper adds to a growing body of research showing that they can successfully generate data outside of perceptual domains.

We're thinking: Supervised learning tends to apply when a specific output y can be predicted from a given input x. In applications where y is a complex data type that’s also inherently stochastic — such as a sequence of market trades or a future weather map — we might try to model y using a stochastic process rather than attempt to learn one correct answer. cGANs appear to be emerging as a promising approach.

Share

Subscribe to The Batch

Stay updated with weekly AI News and Insights delivered to your inbox