Skip to main content

High-performance vectorized backtesting engine for AMM LP positions

Project description

ammBT - AMM Backtesting Engine

High-performance vectorized backtesting engine for AMM liquidity provider positions.

Inspired by vectorbt, ammBT enables testing thousands of LP strategies simultaneously using vectorized operations and Numba compilation.

Features

  • Multi-AMM Support: Uniswap v2 (CPAMM), Uniswap v3 (CLMM), Meteora (DLMM)
  • Vectorized Backtesting: Test thousands of strategy variants in seconds
  • Path-Dependent Simulation: Accurate swap-by-swap pool state simulation
  • Comprehensive Metrics: IL, fees, PnL, Sharpe ratio, capital efficiency
  • Interactive Visualization: Plotly-based charts and heatmaps

Architecture

ammBT uses a hybrid approach:

  • Sequential (Numba): Swap processing through time (path-dependent)
  • Vectorized (NumPy): Parallel strategy evaluation across parameter space

This allows testing N strategies with time complexity of O(swaps) instead of O(swaps × N).

Supported AMM Types

Uniswap v2 (CPAMM)

  • Constant product formula: x × y = k
  • Full-range liquidity
  • Fixed 0.3% fee

Uniswap v3 (CLMM)

  • Concentrated liquidity with tick ranges
  • Multiple fee tiers (0.05%, 0.3%, 1%)
  • Capital efficiency through range orders

Meteora DLMM

  • Bin-based liquidity distribution
  • Dynamic fees based on volatility
  • Solana-native implementation

Status

⚠️ Work in Progress - This project is under active development.

Installation (Development)

git clone <repo>
cd ammbt
pip install -r requirements.txt
pip install -e .
python test_install.py

Quick Start

import ammbt as amm

# Generate synthetic swap data
swaps = amm.generate_swaps(
    n_swaps=10000,
    volatility=0.02,
    drift=0.0
)

# Define strategy space
strategies = {
    'initial_capital': [10000, 50000, 100000],
    'rebalance_threshold': [0.0, 0.05, 0.10],
    'rebalance_frequency': [0, 100, 500],
}

# Run backtest
backtester = amm.LPBacktester(amm_type='v2')
results = backtester.run(swaps, strategies)

# Analyze
print(results.summary())
amm.plot_performance(results, strategy_idx=0).show()

See examples/uniswap_v2_demo.ipynb for full walkthrough.

Project Status

  • Architecture design
  • Uniswap v2 implementation (COMPLETE)
  • Uniswap v3 implementation (COMPLETE)
  • Meteora DLMM implementation
  • Data loaders for real swap data
  • Record system for event tracking

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ammbt-0.1.0.tar.gz (33.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

ammbt-0.1.0-py3-none-any.whl (40.7 kB view details)

Uploaded Python 3

File details

Details for the file ammbt-0.1.0.tar.gz.

File metadata

  • Download URL: ammbt-0.1.0.tar.gz
  • Upload date:
  • Size: 33.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.9

File hashes

Hashes for ammbt-0.1.0.tar.gz
Algorithm Hash digest
SHA256 8468e4cb7dd0e67d0a21327f2218a3b28572d1459d91bbc9c22774748468e2f9
MD5 364b86cbe0d93a20eb870be5c664bc4a
BLAKE2b-256 099b9a3697f1a4cddc928b393276621b10ae0ec54cf7db315bd5fc97a4813a4c

See more details on using hashes here.

File details

Details for the file ammbt-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: ammbt-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 40.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.9

File hashes

Hashes for ammbt-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 17f433b80e48cd9c43836638ee40f52c506cd51b9e53d374edf450225d5bc9c7
MD5 8080ffc9d9697a2b8c69115cdd3717cc
BLAKE2b-256 83d4a49d9fde365b1ba3526f33ea25f0767cba0a5069abb6539ca48d8513579a

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page