Metadata-Version: 2.2
Name: fastmm-engine
Version: 0.8.0
Summary: Low-latency market-making engine: backtest and trade Python and C++ strategies
License: MIT
Project-URL: Homepage, https://github.com/ziyangliu-666/FastMM
Project-URL: Documentation, https://ziy.bio/FastMM/
Project-URL: Repository, https://github.com/ziyangliu-666/FastMM
Project-URL: Changelog, https://github.com/ziyangliu-666/FastMM/blob/main/CHANGELOG.md
Project-URL: Issues, https://github.com/ziyangliu-666/FastMM/issues
Requires-Python: >=3.10
Requires-Dist: numpy>=1.24
Provides-Extra: pandas
Requires-Dist: pandas>=2.0; extra == "pandas"
Provides-Extra: plot
Requires-Dist: matplotlib>=3.7; extra == "plot"
Provides-Extra: hot
Requires-Dist: numba<0.68,>=0.61; extra == "hot"
Requires-Dist: llvmlite<0.50,>=0.44; extra == "hot"
Requires-Dist: pandas>=2.0; extra == "hot"
Provides-Extra: live
Requires-Dist: fastmm-engine-live==0.8.0; extra == "live"
Provides-Extra: dev
Requires-Dist: pytest>=7; extra == "dev"
Requires-Dist: pandas>=2.0; extra == "dev"
Requires-Dist: pybind11-stubgen; extra == "dev"
Description-Content-Type: text/markdown

# FastMM

[![CI](https://github.com/ziyangliu-666/FastMM/actions/workflows/ci.yml/badge.svg)](https://github.com/ziyangliu-666/FastMM/actions/workflows/ci.yml)
[![Docs](https://github.com/ziyangliu-666/FastMM/actions/workflows/docs.yml/badge.svg)](https://ziy.bio/FastMM/)
[![PyPI](https://img.shields.io/pypi/v/fastmm-engine)](https://pypi.org/project/fastmm-engine/)
[![License](https://img.shields.io/badge/license-MIT-blue)](LICENSE)

FastMM is a low-latency market-making engine. Read the [documentation](https://ziy.bio/FastMM/).

https://github.com/user-attachments/assets/dcd130c5-28fe-482f-a757-d0fc6550c5b9

## Features

- **Strategies in C++ or Python.** Python hooks marked `@fastmm.hot` compile to machine code with Numba.
- **One strategy file for backtest and live.** Replays are deterministic, and the simulated exchange models queue position.
- **Account pools.** Several sub-accounts trade behind one venue, and orders spread across them.
- **Gateway.** One `fastmm-gateway` holds the exchange connections; several strategy processes attach to it and can stop or restart without dropping them.
- **Live control.** `fastmm-ctl` changes a running session's parameters without a restart.
- **A/B tests.** Parameter sets run side by side, split by instrument, by time block or both, and are compared on markouts and net with paired intervals.
- **Low-latency tuning.** Core pinning, busy polling, and AF_XDP or DPDK receive for UDP multicast feeds. Order entry runs on the kernel TCP stack, which OpenOnload or XLIO can replace through `LD_PRELOAD`.

## Quickstart

The package on PyPI is `fastmm-engine`, imported as `fastmm`; `pip install fastmm` installs a different project.

```bash
python3 -m venv .venv && . .venv/bin/activate
pip install "fastmm-engine[hot]"
fastmm init my-mm && cd my-mm
python backtest.py
```

This runs a strategy on a simulated market, with no account and no API keys (Linux x86-64, Python 3.10+). On Debian and Ubuntu, `sudo apt install python3-venv` first; on macOS or Windows, [run it in Docker](https://ziy.bio/FastMM/getting-started/install/#without-building-it). The [quick start](https://ziy.bio/FastMM/getting-started/quickstart/) continues to a live session against the local simulated exchange; C++ strategies start from the [C++ quick start](https://ziy.bio/FastMM/getting-started/cpp-quickstart/).

## A strategy

<!-- snippet: examples/python/strategies/touch_mm.py#example -->
```python
import fastmm
from fastmm import Param


class TouchMM(fastmm.Strategy):
    half_spread_bps = Param(0.01, min=0.0, doc="half spread, bps")
    quote_qty = Param(0.002, min=0.0, doc="size per side")

    @fastmm.hot  # compiled to machine code with Numba
    def on_book(self, ctx, book):
        if not book.valid:
            ctx.pull()
            return
        half = book.mid * self.half_spread_bps * 1e-4
        ctx.clear()
        ctx.bid(book.mid - half, self.quote_qty)
        ctx.ask(book.mid + half, self.quote_qty)
        ctx.keep_passive()
```

## Exchanges

Binance (spot and USDⓈ-M futures), OKX, Bybit, Gate, Hyperliquid, Lighter, Deribit, Gemini and Coinbase. A Nasdaq connector (TotalView-ITCH market data, OUCH 5.0 orders) trades only against the bundled simulator, `fastmm-sim-itch`.

> If you are running FastMM on Binance, try [bndesk](https://github.com/ziyangliu-666/bndesk), a real-time dashboard for your accounts.

## License

[MIT](LICENSE)
