Skip to main content

Market Making RL - simulation, experiments, and CLI

Project description

Market Making RL Agent

PyPI Tests Python License

Why this is useful

  • End-to-end, deployable research stack: config-driven envs, MLflow tracking, CLI, REST API with async jobs, and DuckDB persistence
  • Microstructure features that matter: OU price dynamics with regime switching, probabilistic fills, fees/slippage, multi-asset correlation, depth-aware quoting, size decisions
  • Baselines and RL: Naive, Inventory-aware, Avellaneda–Stoikov, PPO; hyperparameter search with Optuna

60s Quickstart

pip install mmrl
mmrl backtest
mmrl evaluate  # Naive vs Rule-Based vs A–S vs PPO
mmrl analyze strategy_comparison.csv --plot  # analyze your returns file

From source:

pip install -r requirements.txt

Colab Notebooks

  • Quickstart

    Open In Colab

  • Grid Search + Heatmaps

    Open In Colab

  • RL vs Rule-Based

    Open In Colab

  • Multi-asset & Replay

    Open In Colab

Multi-asset

  • Configure under multi_asset in configs/inventory.yaml
  • Run:
python3 experiments/evaluate_multi_asset.py
python3 analysis/plot_multi_asset.py results/.../multi_asset_history.csv

API

  • Start stack:
docker compose up -d redis worker api mlflow
curl http://localhost:8000/health
curl http://localhost:8000/config/schema  # config JSON schema
  • Submit jobs:
curl -X POST http://localhost:8000/backtest -H 'Content-Type: application/json' -d '{"steps": 200}'
curl -X POST http://localhost:8000/grid -H 'Content-Type: application/json' -d '{"execution": {"alpha_grid": [1.0, 1.5]}}'
curl http://localhost:8000/trades/<run_id>?limit=100
curl http://localhost:8000/runs/<run_dir_name>/artifacts
curl -L -o run.zip http://localhost:8000/runs/<run_dir_name>/download

Hyperparameter Optimization

python3 experiments/hyperopt.py

Notable features

  • Multi-asset Gym wrapper with per-asset, per-level actions (offsets + sizes)
  • Depth-aware agent placing quotes at multiple levels with regime-conditioned parameters
  • DuckDB persistence of runs/metrics/trades and a /trades/{run_id} endpoint
  • MLflow logging of params, metrics, artifacts with run IDs written per run
  • CLI extras: mmrl fetch-data (CCXT sample), mmrl config-validate, mmrl config-schema

Roadmap

  • Postgres-backed storage and public demo deployment
  • Size-aware RL policy across multi-asset Gym env
  • Notebooks + Colab badges for quick experimentation

Packaging

  • Install from source or build wheel with python -m build (requires build).
  • Optional extras:
    • mmrl[api] for FastAPI stack
    • mmrl[rl] for Gymnasium/SB3

Data utilities

  • Fetch sample trades to Parquet:
python3 -m mmrl.cli fetch-data --exchange binance --symbol BTC/USDT --limit 1000 --out data/btcusdt.parquet

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

mmrl-0.1.1.tar.gz (36.2 kB view details)

Uploaded Source

Built Distribution

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

mmrl-0.1.1-py3-none-any.whl (43.4 kB view details)

Uploaded Python 3

File details

Details for the file mmrl-0.1.1.tar.gz.

File metadata

  • Download URL: mmrl-0.1.1.tar.gz
  • Upload date:
  • Size: 36.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.10.13

File hashes

Hashes for mmrl-0.1.1.tar.gz
Algorithm Hash digest
SHA256 d3ab2ace85e1b0d4b3b501378063173f69d92fbe3885af6be70a07476b1861d2
MD5 a733e9128b11d079badd7d249f58653a
BLAKE2b-256 529ef3cd6cdec94ecbc88e025303d817ccbd0a3d7abb5df56769552a51e5b203

See more details on using hashes here.

File details

Details for the file mmrl-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: mmrl-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 43.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.10.13

File hashes

Hashes for mmrl-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 36e57b7c1d812dcf25abbc06e9a831b252089edb524e4b3a663e93e22782788d
MD5 71437c7af36508b28cadfa609864fa2d
BLAKE2b-256 27595099aa24d6d0ba021de61c495ecd5630e88cf2dd3077f56d2b587b86330c

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