Skip to main content

pretium

determinism licence: MIT OR Apache-2.0 python 3.11+

A market simulator you can run a strategy against. Rust core, Python API.

Give it a seed and a list of companies. It runs a market forward: prices, a limit order book, fills, and an economy that moves each day. Your orders match against real depth, so your trades move the price.

Real market data cannot tell you what happens if you trade differently, or what caused a move. This can, because it computed every price.

Install

pip install pretium

Wheels for Linux, macOS and Windows on CPython 3.11+. No dependencies. The same engine is a Rust crate: cargo add pretium.

The API can still change before 1.0. A published result cannot: new coefficients ship as a new preset, so a run you cited last month replays this month.

First run

import pretium as pt

universe = pt.Universe.random(40, seed=111)

spec = pt.StrategySpec.momentum(lookback_days=1.0, top_k=5)
scores = pt.evaluate({"mine": spec}, seed=7, universe=universe, days=10)

scores["mine"].return_pct            # what it made
scores["mine"].impact_bps            # what its own footprint cost
scores["mine"].strategy_fingerprint  # sha256, cite this

That is one market draw. It tells you as much about the seed as about the strategy. pt.rank runs many seeds and compares them with a paired sign test.

What you get

engine.truth() why each price moved: nine factors that sum to the move, to 1e-16
counterfactual TCA the same seed with your orders and without them
pt.rank many seeds, paired sign tests
RunManifest version, preset, seed, universe, macro, scenario. reproduce() stops on a mismatch
MCP server eleven read-only tools for a coding agent
more a Gymnasium environment, Arrow output, checkpoints, SEC EDGAR data, a browser build

No historical dataset carries the labels truth() gives you. Real data shows you that a stock fell. It never shows you that 60% of the fall was order flow.

To drive it from an agent:

pip install "pretium[mcp]"
claude mcp add pretium -- pretium-mcp

Strategies, universes and scenarios are data, so a tool argument cannot reach code. Each result carries its own caveats. See the MCP page.

How real it is

pt.facts.measure() scores fourteen statistics against real-market bands. The default preset, pt-v14, holds all fourteen at one year and at two years. It holds all fourteen on a roster it never saw, and thirteen on new seeds.

Five of the fourteen were calibration targets, and the bands both tuned the model and graded it. So this is a stated envelope, not a test against market data that was held back.

Five limits are measured and written down:

limit what it means
horizon one year is certified. Two and five years are measured, not certified
volatility memory it decays too fast
scenario size the response has the right sign, but one run cannot size it
macro crises an inflation crisis or a policy crisis needs a scenario to drive it
roster certification used a sector-balanced roster, which no real index is

pt.envelope.check() refuses a question that falls outside a limit, and the realism envelope says what each one forbids.

Good results here do not predict real returns. The prices come from a known model, so a strategy shaped like that model looks excellent and teaches you nothing. A strategy that fails here tells you more. There is one venue, no latency, and no counterparty that adapts to you.

Same seed, same market

Each release builds five targets, runs one fixed simulation in each, and compares digests. A disagreement stops the release. The crate ships its own exp, log, sin and cos, so the platform libm cannot change a result.

pt-v14 became the default on 2026-08-28. Name your preset and your run replays exactly. Every preset from pt-v1 on is still selectable.

eng = pt.Engine(seed=42, universe=u, model="pt-v10")

Examples

Ten examples/ in reading order, run by the test suite:

00-a-year-in-one-market Start here: one company, one year, two crises, one chart
01-first-simulation Universe, engine, order book, determinism
02-evaluating-a-strategy Specs, baselines, ranking across seeds
03-why-did-the-price-move The nine factors that sum to every move
04-how-realistic-is-this The realism panel and the limits
05-training-an-agent The Gymnasium environment, and what size costs
06-execution-and-impact TCA and the counterfactual run
07-research-workflow.py A whole study in one file. It runs in about five seconds
08-claude-agent.py An LLM agent trading the market through the harness
09-a-pandemic-shaped-market A real 2020-21 macro path, and which fields transmit

More

Full docs: simoncoombes.github.io/pretium.

To contribute, see CONTRIBUTING.md and RELEASING.md. One rule shapes the rest: a change to the simulated trajectory is a breaking change, whatever its size.

To cite the software, see CITATION.cff. To cite a result, use its RunManifest.

Licence: MIT OR Apache-2.0, at your option. See LICENSE-MIT and LICENSE-APACHE.

Metadata

Release files for pretium 0.4.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pretium 0.4.3
File Size Uploaded
pretium-0.4.3.tar.gz 524.6 kB Details

Built distributions (wheels)

Table of built distributions (wheels) for pretium 0.4.3
File
pretium-0.4.3-cp311-abi3-win_amd64.whl CPython 3.11 abi3 Windows x86-64 Details
pretium-0.4.3-cp311-abi3-manylinux_2_34_x86_64.whl CPython 3.11 abi3 Linux glibc 2.34+ x86-64 Details
pretium-0.4.3-cp311-abi3-manylinux_2_34_aarch64.whl CPython 3.11 abi3 Linux glibc 2.34+ ARM64 Details
pretium-0.4.3-cp311-abi3-macosx_11_0_arm64.whl CPython 3.11 abi3 macOS 11.0+ ARM64 Details
pretium-0.4.3-cp311-abi3-macosx_10_12_x86_64.whl CPython 3.11 abi3 macOS 10.12+ x86-64 Details

Total release size: 4.4 MB

Release files / pretium-0.4.3.tar.gz

Download URL pretium-0.4.3.tar.gz
Size 524.6 kB
Tags Source
SHA-256 checksum
How to use checksums
7fda3916764e700c95b3ef7b98757ea1104efb874615f296e2e0f5d99b82887e
BLAKE2b-256 checksum
How to use checksums
ffc22587dff0bd9641aedc2a8cbf855528aec9510280aa8cdfa5a55e25ccbb35
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Aug 28, 2026.

Transparency log

Release files / pretium-0.4.3-cp311-abi3-win_amd64.whl

Download URL pretium-0.4.3-cp311-abi3-win_amd64.whl
Size 719.2 kB
Tags CPython 3.11 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
34c254c879b6269038a5266f1c104e6c9ee050196213ca2cefc6e93cbb80f812
BLAKE2b-256 checksum
How to use checksums
d06b314e8bf1bfcf2ab6270c249310ce5684a921b3d5795b2c56ef6fbd5356b3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Aug 28, 2026.

Transparency log

Release files / pretium-0.4.3-cp311-abi3-manylinux_2_34_x86_64.whl

Download URL pretium-0.4.3-cp311-abi3-manylinux_2_34_x86_64.whl
Size 820.9 kB
Tags CPython 3.11 Linux glibc 2.34+ x86-64 abi3
SHA-256 checksum
How to use checksums
415e991acb8369a6a6e14ce38dff604cb4be549aa05675bcf3ea5d530e0c8be5
BLAKE2b-256 checksum
How to use checksums
8f88bf88f4217907f39647581dd34148bffac4761ba3f0f6c64f4d10d8c9f84f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Aug 28, 2026.

Transparency log

Release files / pretium-0.4.3-cp311-abi3-manylinux_2_34_aarch64.whl

Download URL pretium-0.4.3-cp311-abi3-manylinux_2_34_aarch64.whl
Size 804.5 kB
Tags CPython 3.11 Linux glibc 2.34+ ARM64 abi3
SHA-256 checksum
How to use checksums
fc7eb9f6d9574ef1f3e6d12ec06ee180555c84225e581b825ff35f88e0c9b9b9
BLAKE2b-256 checksum
How to use checksums
9ce34e7b591a4a667b6b29e8960bbd6c484fc78cdf9db061ad20e0a93671cbea
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Aug 28, 2026.

Transparency log

Release files / pretium-0.4.3-cp311-abi3-macosx_11_0_arm64.whl

Download URL pretium-0.4.3-cp311-abi3-macosx_11_0_arm64.whl
Size 770.2 kB
Tags CPython 3.11 abi3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
ef5fce7b07eb4e5fc111fa7fb4ca69d3b655c7e18417e5297faa25824ee80317
BLAKE2b-256 checksum
How to use checksums
1716dcb78c76034a8a91933b4d32cf2f10e9d345011cf91c59dc10967eb09dac
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Aug 28, 2026.

Transparency log

Release files / pretium-0.4.3-cp311-abi3-macosx_10_12_x86_64.whl

Download URL pretium-0.4.3-cp311-abi3-macosx_10_12_x86_64.whl
Size 795.2 kB
Tags CPython 3.11 abi3 macOS 10.12+ x86-64
SHA-256 checksum
How to use checksums
108316815dbacf51812153216e356039d99f21ad649d4a5c72e8cb2b4f6ba257
BLAKE2b-256 checksum
How to use checksums
720f494ead357ed4851f3cf1ba17e9ca256e1fa47d740d4b4154b6c2119181e7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Aug 28, 2026.

Transparency log

Release history Release notifications | RSS feed

0.5.2

2 release files

0.5.1

2 release files

0.5.0

2 release files

This release

0.4.3 This release

6 release files

0.4.2

6 release files

0.4.1

6 release files

0.4.0

6 release files

0.3.0

6 release files

0.2.0

6 release files

0.1.4

6 release files

0.1.3

6 release files

0.1.2

6 release files

0.1.1

6 release files

0.1.0

5 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page