Skip to content

balancer/quantammsim

 
 

Repository files navigation

Python Documentation Code style: black JAX Documentation Status


                              _                                     _            
                             | |                                   (_)           
   __ _  _   _   __ _  _ __  | |_  __ _  _ __ ___   _ __ ___   ___  _  _ __ ___  
  / _` || | | | / _` || '_ \ | __|/ _` || '_ ` _ \ | '_ ` _ \ / __|| || '_ ` _ \ 
 | (_| || |_| || (_| || | | || |_| (_| || | | | | || | | | | |\__ \| || | | | | |
  \__, | \__,_| \__,_||_| |_| \__|\__,_||_| |_| |_||_| |_| |_||___/|_||_| |_| |_|
     | |                                                                         
     |_|                                                                         
  

quantammsim

A Python library for simulating and tuning Automated Market Maker (AMM) protocols
Explore the docs »

Getting Started · Report Bug · Request Feature

About

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.

Features

  • 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)

Installation

Requirements

  • Python 3.8+
  • JAX
  • NumPy
  • Pandas

Installation

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/activate

Alternatively, using Conda:

conda create -n qsim python=3.10
conda activate qsim

Install package:

git clone https://github.com/QuantAMMProtocol/quantammsim.git
cd quantammsim
pip install -e .

Optional Data Files

To download data files for simulation and testing:

python scripts/download_data.py <tickers>

For example:

python scripts/download_data.py BTC ETH USDC

For detailed installation instructions, see our documentation.

Quick Start

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)

Documentation

Full documentation is available at quantammsim.readthedocs.io, including:

  • Tutorials
  • API Reference
  • User Guide
  • Examples

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

License

See LICENSE for more information.

About

Simulator engine for modelling AMM pools using high-speed JAX code

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages

  • Python 99.7%
  • Other 0.3%