A Python library for prediction-market replay, paper fills, and strategy evidence checks. The core uses the standard library and targets Python 3.10 or later.
PMQS models execution delay, spread, fees, and displayed liquidity. It rejects defined input errors, including backdated orders and crossed books. These checks address specific failure modes. They cannot certify arbitrary data or strategy code against every form of leakage.
python explore.pyThe menu explains the evidence gate and runs synthetic examples without credentials or network access. To install the package and run the backtest directly:
python -m pip install -e ".[dev]"
python examples/run_fixture_backtest.py
python -m pytest -qThe built-in strategy fails the evidence gate. That is the expected fixture result.
| Module | Behavior |
|---|---|
pmqs.orderbook |
YES and NO bid ladders, derived asks, and stream validation |
pmqs.fees |
Configurable fee rates and rounding rules |
pmqs.fills |
Taker paper fills with spread crossing and a liquidity haircut |
pmqs.replay |
Delayed execution against a later book snapshot |
pmqs.ledger |
Cash, positions, settlement, and realized results by market |
pmqs.markout |
Price movement after fills and closing-line value |
pmqs.validate |
Minimum sample, profit, confidence-interval, and closing-line checks |
pmqs.capture |
REST capture to JSONL and a fixture mode |
pmqs.fixtures |
Deterministic synthetic events |
The default gate requires all four conditions:
- At least 30 settled markets.
- Positive results after fees.
- A positive lower bootstrap confidence bound, with resampling by market.
- Positive mean closing-line value.
Markets form the resampling unit because fills within a market can share outcomes. Dependence across markets and selection bias still require separate analysis. Passing the gate marks a research candidate. It does not establish a durable or executable edge.
The optional capture dependency supports signing read requests with your own credentials. Use data that you have permission to collect and retain. Keep keys outside the repository.
python -m pip install -e ".[capture]"
python -m pmqs.capture --helpFee schedules and venue behavior can change. Configure them for the period represented by your data. PMQS does not place live orders and does not include a profitable strategy.
The playbook and dated posts describe research methods and earlier project plans. Private companion projects are outside this release.
MIT. See LICENSE.