https://github.com/jialuechen/genmarket
Python Market Simulation Engine Built on top of Generative AI
https://github.com/jialuechen/genmarket
attention-mechanism diffusion-models event-driven execution market-making portfolio-optimization quant-finance transformer vae
Last synced: 6 months ago
JSON representation
Python Market Simulation Engine Built on top of Generative AI
- Host: GitHub
- URL: https://github.com/jialuechen/genmarket
- Owner: jialuechen
- Created: 2024-05-24T18:30:01.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2025-04-02T04:14:40.000Z (6 months ago)
- Last Synced: 2025-04-06T18:16:27.162Z (6 months ago)
- Topics: attention-mechanism, diffusion-models, event-driven, execution, market-making, portfolio-optimization, quant-finance, transformer, vae
- Language: Python
- Homepage: https://jialuechen.github.io/genmarket/
- Size: 4.04 MB
- Stars: 104
- Watchers: 5
- Forks: 9
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# GenMarket : Market Simulation by Generation
**GenMarket** is a modular, multi-layer generative market simulation framework designed to evaluate trading strategies and market impact under synthetic yet realistic conditions.
It combines macro regime generation, high-frequency order flow simulation, LOB microstructure modeling, and plug-in execution strategies (e.g. VWAP, TWAP), supporting both controlled experimentation and generative scenario construction.
---
## ๐ Features
- **Multi-layer simulation**
Top-down generation from macro regimes โ order flow โ limit order book (LOB).- **Scenario generation**
Uses VAE/Diffusion model stubs to create synthetic market conditions beyond historical replay.- **Order flow modeling**
Autoregressive event-level generator simulates realistic buy/sell order streams.- **LOB simulation engine**
Matches orders with queue logic and customizable liquidity depth.- **Built-in execution strategies**
Plug-and-play VWAP and TWAP strategies for benchmark testing.- **Market impact evaluation**
Measures execution price, slippage, and volume impact.- **Visualization**
Plot order flow, execution trajectory, and size dynamics.---
## ๐งฑ Installation
```bash
pip install --upgrade genmarket
```---
## ๐ Example Config (`configs/market_crash_scenario.json`)
```json
{
"regime": "volatile",
"volatility": 0.35,
"liquidity": "low",
"lob": {
"levels": 5,
"latency_ms": 10
},
"strategy": {
"type": "vwap",
"params": {
"target_volume": 100,
"time_horizon": 10
}
}
}
```---
## ๐งช Run a Simulation
```bash
python examples/run_simulation.py
``````python
from genmarket import GenMarket
from genmarket.plotting import plot_executions
import jsonwith open("configs/market_crash_scenario.json") as f:
config = json.load(f)gm = GenMarket(config)
metrics = gm.run()print("Simulation Metrics:")
for k, v in metrics.items():
print(f"{k}: {v}")# Visualize execution result
plot_executions(metrics.get("executions", []))
```---
## ๐งฉ Strategy Plugins
- `VWAPStrategy` โ Volume-weighted execution across time horizon
- `TWAPStrategy` โ Time-weighted slices across fixed intervalsYou can create your own strategies and add them under `genmarket/strategy_plugins/`.
---
## ๐ฌ Applications
- Strategy benchmarking under stress scenarios
- Execution cost modeling and market impact analysis
- Synthetic data generation for pre-trade analytics
- Reinforcement learning environment (future support)---
## ๐ Roadmap
- [ ] Integrate pretrained diffusion/VAE market generators
- [ ] Add LLM-driven natural language scenario parser
- [ ] Extend to multi-asset & cross-venue simulation
- [ ] Add dashboard interface for real-time simulation control---
## ๐ License
MIT License. See `LICENSE`.
---
## ๐ Citation
```
@misc{genmarket2025,
title = {GenMarket: A Multi-Layer Generative Market Simulation Framework},
author = {Jialue Chen},
year = {2025},
note = {https://github.com/jialuechen/genmarket}
}
```