MarS is a financial market simulation engine developed by Microsoft that leverages generative foundation models to create realistic market dynamics. Written in Python and supporting versions 3.11 and 3.12, the project was accepted to ICLR 2025 and represents a significant advancement in computational finance research. The repository provides core code and tools for an order agent system designed to simulate market behavior with high fidelity to real-world financial markets.
The primary purpose of MarS is to generate synthetic market data and simulate trading scenarios by modeling order generation through a foundation model-based approach. The system evaluates its realism against eleven key market characteristics known as stylized facts, which are empirical patterns consistently observed across different financial markets. According to the repository's analysis, the simulated data successfully reproduces nine out of eleven stylized facts identified by Cont (2001), including absence of autocorrelations, heavy tails, aggregational Gaussianity, intermittency, volatility clustering, conditional heavy tails, slow decay of autocorrelation in absolute returns, volume-volatility correlation, and asymmetry in timescales. The two absent facts, gain-loss asymmetry and leverage effect, have also been noted as missing in modern US markets, suggesting the simulation captures contemporary market behavior accurately.
The repository's architecture centers on several key components. The OrderModel handles order generation, OrderState manages market state representation and updates, and OrderAgent generates orders as a background process. The system uses Ray Serve to deploy the order model as a scalable, production-ready service. The codebase includes multiple practical examples: a Stylized Facts Report that evaluates the eleven market characteristics, a Simulation as Forecasting example for future prediction, a Market Impact Analysis tool for studying market impacts, and an Interactive Demo built with Streamlit for user-friendly exploration.
Installation is provided through two primary methods: VS Code Dev Containers, which offer a fully configured development environment, and Docker, which is strongly recommended due to specific system dependencies and CUDA requirements. The project requires downloading prerequisites including converters, validation samples, and stylized facts data, currently available through OneDrive while the associated Hugging Face model undergoes final review.
For production deployment, MarS requires real order-level historical data to accurately simulate market behavior, substantial computational resources (the research simulations typically run 128 trajectories per state using 128 GPUs), and an optimized inference pipeline. The repository acknowledges that the current implementation prioritizes validating the model's scalability and controllable order generation capabilities rather than production optimization. Several performance enhancement strategies are documented, including replacing Ray-based batch inference with systems like vLLM, exploring efficient model architectures such as Mamba or MoE, implementing model compression techniques, optimizing KV-cache handling, and enabling multi-token prediction.
The project maintains active community engagement through WeChat and Discord channels and welcomes pull requests. The codebase is licensed under MIT and includes comprehensive documentation. While the demos provide interactive parameter exploration and visualization, the underlying scripts offer flexibility for integration into custom workflows and data pipelines, allowing researchers and practitioners to adapt the simulation engine to their specific requirements.