_ _
| | (_)
__ _ _ _ __ _ _ __ | |_ __ _ _ __ ___ _ __ ___ ___ _ _ __ ___
/ _` || | | | / _` || '_ \ | __|/ _` || '_ ` _ \ | '_ ` _ \ / __|| || '_ ` _ \
| (_| || |_| || (_| || | | || |_| (_| || | | | | || | | | | |\__ \| || | | | | |
\__, | \__,_| \__,_||_| |_| \__|\__,_||_| |_| |_||_| |_| |_||___/|_||_| |_| |_|
| |
|_|
A Python library for simulating and tuning Automated Market Maker (AMM) protocols
Explore the docs »
Getting Started
·
Report Bug
·
Request Feature
quantammsim is a Python library for modeling synthetic markets, enabling modelling of Balancer, CowAMM, Gyroscope and QuantAMM protocols. It provides tools for:
- Automated Market Making (AMM) simulation
- Arbitrage opportunity detection
- Historical data backtesting
quantammsim uses JAX for accelerated computation. The library focuses on dynamic AMMs that can adapt their behavior based on market conditions, with particular emphasis on Temporal Function Market Making (TFMM) pools. For more details on the theoretical foundations, see our research.
- Multiple AMM implementations:
- Balancer Protocol
- CowAMM Protocol
- Gyroscope
- QuantAMM Protocol (TFMM)
- Pre-canned textbook strategies:
- Momentum
- Anti-Momentum
- Power Channel
- Mean Reversion Channel
- Minimum Variance
- And implement custom strategies
- Include the effects of fees, gas costs, and of a provided sequence of transactions.
- JAX-accelerated computations
- Comprehensive visualization tools (currently via hosted frontend)
- Python 3.8+
- JAX
- NumPy
- Pandas
It is recommended to install quantammsim in a virtual environment:
Using venv:
# Create and activate virtual environment
python -m venv venv
# On Windows:
.\venv\Scripts\activate
# On macOS/Linux:
source venv/bin/activateAlternatively, using Conda:
conda create -n qsim python=3.10
conda activate qsimInstall package:
git clone https://github.com/QuantAMMProtocol/quantammsim.git
cd quantammsim
pip install -e .To download data files for simulation and testing:
python scripts/download_data.py <tickers>For example:
python scripts/download_data.py BTC ETH USDCFor detailed installation instructions, see our documentation.
from quantammsim.runners.jax_runners import do_run_on_historic_data
import jax.numpy as jnp
# Define experiment parameters
run_fingerprint = {
'tokens': ['BTC', 'USDC'],
'rule': 'balancer',
'initial_pool_value': 1000000.0
}
# Initialise pool parameters, equal weights. Equivalent to a Uniswap v2 pool;
params = {
"initial_weights": jnp.array([0.5, 0.5]),
}
# Run simulation
result = do_run_on_historic_data(run_fingerprint, params, verbose=True)Full documentation is available at quantammsim.readthedocs.io, including:
- Tutorials
- API Reference
- User Guide
- Examples
Contributions are welcome! Please feel free to submit a Pull Request.
See LICENSE for more information.