{"repo":"evan-kolberg/prediction-market-backtesting","free":true,"listed":false,"github":"https://github.com/evan-kolberg/prediction-market-backtesting","clone":"git clone https://github.com/evan-kolberg/prediction-market-backtesting.git","description":"An extension for Nautilus Trader","language":"Python","stars":1134,"topics":["algotrading","backtesting","backtesting-engine","backtesting-tools","backtesting-trading-strategies","polymarket"],"license":null,"category":"algotrading_backtester","readme_excerpt":"# prediction-market-backtesting\n\n![GitHub stars](https://img.shields.io/github/stars/evan-kolberg/prediction-market-backtesting?style=social)\n![GitHub forks](https://img.shields.io/github/forks/evan-kolberg/prediction-market-backtesting?style=social)\n![GitHub watchers](https://img.shields.io/github/watchers/evan-kolberg/prediction-market-backtesting?style=social)\n\n[![Licensing: Mixed](https://img.shields.io/badge/licensing-MIT%20%2B%20LGPL--3.0--or--later-blue.svg)](NOTICE)\n[![Ruff](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/charliermarsh/ruff/main/assets/badge/v2.json)](https://github.com/astral-sh/ruff)\n[![uv](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/uv/main/assets/badge/v0.json)](https://github.com/astral-sh/uv)\n![Python](https://img.shields.io/badge/python-3.12%2B-3776AB?logo=python&logoColor=white)\n![Rust](https://img.shields.io/badge/rust-1.93.1-CE422B?logo=rust&logoColor=white)\n![Rust Edition](https://img.shields.io/badge/edition-2024-CE422B?logo=rust&logoColor=white)\n![NautilusTrader](https://img.shields.io/badge/NautilusTrader-1.226.0-1E3A5F)\n![GitHub last commit](https://img.shields.io/github/last-commit/evan-kolberg/prediction-market-backtesting)\n![GitHub commit activity](https://img.shields.io/github/commit-activity/m/evan-kolberg/prediction-market-backtesting)\n![GitHub code size](https://img.shields.io/github/languages/code-size/evan-kolberg/prediction-market-backtesting)\n![GitHub top language](https://img.shields.io/github/languages/top/evan-kolberg/prediction-market-backtesting)\n![GitHub open issues](https://img.shields.io/github/issues/evan-kolberg/prediction-market-backtesting)\n![GitHub contributors](https://img.shields.io/github/contributors/evan-kolberg/prediction-market-backtesting)\n![GitHub pull requests](https://img.shields.io/github/issues-pr/evan-kolberg/prediction-market-backtesting)\n![GitHub closed issues](https://img.shields.io/github/issues-closed/evan-kolberg/prediction-market-backtesting)\n![GitHub closed pull requests](https://img.shields.io/github/issues-pr-closed/evan-kolberg/prediction-market-backtesting)\n\n**New in Version 4.1-alpha:**\n- Live sandbox plumbing for Polymarket BTC 5min markets\n- Example runner showing how to use live BTC 5min hooks\n- (strategy & model *now* included)\n- open sourced some /private files (felt like it)\n\n**New in Version 4:**\n- Nautilus 1.226.0\n- Rust-native data conversion\n- Faster staged data loading\n- Improved materialized caches\n- Unified cache/local/archive/API message bus\n\n**New in Version 3:**\n- Telonex vendor support\n- Local Telonex download script\n- Many bug fixes & accuracy improvements\n- Book replay order book deltas with trade ticks\n\n**New in Version 2:**\n- Nautilus via PyPI in lieu of a subtree\n- Better backtest runner classes via EXPERIMENT objects\n- IPython notebook support (.ipynb files)\n- Joint portfolio multi replay runners\n- Growing support for statistical optimizers\n- New aggregate charts\n- Massive improvements charting gen speed\n- an attempt at a Tree-structured Parzen Estimator via Optuna\n\nLooking for the old version? That was renamed to [Version 1](https://github.com/evan-kolberg/prediction-market-backtesting/tree/v1)\n\nBacktesting framework for prediction market strategies on\n[Polymarket](https://polymarket.com), built on top of\n[NautilusTrader](https://github.com/nautechsystems/nautilus_trader) with custom\nexchange adapters. [Limitless.exchange](https://limitless.exchange) and\n[Opinion.trade](https://opinion.trade) are planned next; [Kalshi](https://kalshi.com) support depends on access to L2 historical book data. Current Kalshi components are research and fee-modeling plumbing, not a public runnable backtest path. Plotting inspired by [minitrade](https://github.com/dodid/minitrade). This repo is still in active development.\n\n\nFantastic single & multi-market charting. Featuring: equity (total & individual markets), profit / loss ticks, P&L periodic bars, market allocation, YES price (with green buy and red sell fills), drawdown, sharpe (with above/below shading), cash / equity, monthly returns, and cumulative brier advantage.\n![Charting preview](https://raw.githubusercontent.com/evan-kolberg/prediction-market-backtesting/main/docs/assets/charting-preview.jpeg)\n\n**If you find any bugs, unexpected behavior, or missing simulation features, PLEASE post an [issue](https://github.com/evan-kolberg/prediction-market-backtesting/issues/new) or [discussion](https://github.com/evan-kolberg/prediction-market-backtesting/discussions/new/choose).**\n\nDetailed guides have been filed away in the [docs index](https://evan-kolberg.github.io/prediction-market-backtesting/) for better organization and long-term sustainability.\n\n## Table of Contents\n\n- [Docs Index](https://evan-kolberg.github.io/prediction-market-backtesting/)\n  - [Start Here](https://evan-kolberg.github.io/prediction-market-backtesting/#start-here)\n  - [Core Framework](https://evan-kolberg.github.io/prediction-market-backtesting/#core-framework)\n  - [Advanced / Experiments](https://evan-kolberg.github.io/prediction-market-backtesting/#advanced-experiments)\n  - [Project](https://evan-kolberg.github.io/prediction-market-backtesting/#project)\n  - [Acknowledgements](https://evan-kolberg.github.io/prediction-market-backtesting/#acknowledgements)\n- [Setup](https://evan-kolberg.github.io/prediction-market-backtesting/setup/)\n  - [Prerequisites](https://evan-kolberg.github.io/prediction-market-backtesting/setup/#prerequisites)\n  - [Install](https://evan-kolberg.github.io/prediction-market-backtesting/setup/#install)\n  - [First Run](https://evan-kolberg.github.io/prediction-market-backtesting/setup/#first-run)\n  - [Timing And Cache Defaults](https://evan-kolberg.github.io/prediction-market-backtesting/setup/#timing-and-cache-defaults)\n  - [Extension Architecture](https://evan-kolberg.github.io/prediction-market-backtesting/setup/#extension-architecture)\n- [Backtests And Runners](https://evan-kolberg.github.io/prediction-market-backtesting/backtests/)\n  - [Repo Layout](https://evan-kolberg.github.io/prediction-market-backtesting/backtests/#repo-layout)\n  - [Archived Private Research](https://evan-kolberg.github.io/prediction-market-backtesting/backtests/#archived-private-research)\n  - [Runner Contract](https://evan-kolberg.github.io/prediction-market-backtesting/backtests/#runner-contract)\n  - [HTML And Report Modes](https://evan-kolberg.github.io/prediction-market-backtesting/backtests/#html-and-report-modes)\n  - [Optimization Runners](https://evan-kolberg.github.io/prediction-market-backtesting/backtests/#optimization-runners)\n  - [Designing Good Runner Files](https://evan-kolberg.github.io/prediction-market-backtesting/backtests/#designing-good-runner-files)\n  - [Multi-Market Strategy Configs](https://evan-kolberg.github.io/prediction-market-backtesting/backtests/#multi-market-strategy-configs)\n  - [Running Backtests](https://evan-kolberg.github.io/prediction-market-backtesting/backtests/#running-backtests)\n  - [Notebook Runners](https://evan-kolberg.github.io/prediction-market-backtesting/backtests/#notebook-runners)\n  - [Editing Runner Inputs](https://evan-kolberg.github.io/prediction-market-backtesting/backtests/#editing-runner-inputs)\n  - [Data Vendor Notes](https://evan-kolberg.github.io/prediction-market-backtesting/backtests/#data-vendor-notes)\n    - [Native Vendors](https://evan-kolberg.github.io/prediction-market-backtesting/backtests/#native-vendors)\n    - [PMXT](https://evan-kolberg.github.io/prediction-market-backtesting/backtests/#pmxt)\n    - [Telonex](https://evan-kolberg.github.io/prediction-market-backtesting/backtests/#telonex)\n- [Sandbox And Live Runners](https://evan-kolberg.github.io/prediction-market-backtesting/live/)\n  - [Current Scope](https://evan-kolberg.github.io/prediction-market-backtesting/live/#current-scope)\n  - [Directory Contract](https://evan-kolberg.github.io/prediction-market-backtesting/live/#directory-contract)\n  - [Sandbox Runner Contract](https://evan-kolberg.github.io/prediction-market-backtesting/live/#sandbox-runner-contract)\n  - [Shared Live Helpers](https://evan-kolberg.github.io/prediction-market-backtesting/live/#shared-live-helpers)\n  - [BTC 5m Sandbox Plumbing](https://evan-kolberg.github.io/prediction-market-backtesting/live/#btc-5m-sandbox-plumbing)\n  - [Example BTC Snapshot Runner](https://evan-kolberg.github.io/prediction-market-backtesting/live/#example-btc-snapshot-runner)\n  - [Archived Strategy Boundary](https://evan-kolberg.github.io/prediction-market-backtesting/live/#archived-strategy-boundary)\n  - [Model And Parameter Placement](https://evan-kolberg.github.io/prediction-market-backtesting/live/#model-and-parameter-placement)\n  - [Running Sandbox](https://evan-kolberg.github.io/prediction-market-backtesting/live/#running-sandbox)\n  - [Public Polymarket Data](https://evan-kolberg.github.io/prediction-market-backtesting/live/#public-polymarket-data)\n  - [Path To Live Polymarket Trading](https://evan-kolberg.github.io/prediction-market-backtesting/live/#path-to-live-polymarket-trading)\n- [Data Loading](https://evan-kolberg.github.io/prediction-market-backtesting/data-loading/)\n  - [Mental Model](https://evan-kolberg.github.io/prediction-market-backtesting/data-loading/#mental-model)\n  - [Staged Loading](https://evan-kolberg.github.io/prediction-market-backtesting/data-loading/#staged-loading)\n  - [PMXT Flow](https://evan-kolberg.github.io/prediction-market-backtesting/data-loading/#pmxt-flow)\n  - [Telonex Flow](https://evan-kolberg.github.io/prediction-market-backtesting/data-loading/#telonex-flow)\n  - [Caching](https://evan-kolberg.github.io/prediction-market-backtesting/data-loading/#caching)\n  - [Downloading Local Data](https://evan-kolberg.github.io/prediction-market-backtesting/data-loading/#downloading-local-data)\n  - [Progress And Timing](https://evan-kolberg.github.io/prediction-market-backtesting/data-loading/#progress-and-timing)\n  - [Failure Semantics](htt","default_branch":"v4.1-alpha","files":254,"tree":[".env.example",".gitattributes",".github/workflows/ci.yml",".github/workflows/docs.yml",".gitignore",".ruff.toml",".vscode/settings.json","AGENTS.md","CODEBASE_UML.md","COPYING","COPYING.LESSER","Cargo.lock","Cargo.toml","LICENSE","LICENSE-MIT","Makefile","NOTICE","README.md","backtests/__init__.py","backtests/_beffer45_trade_data.py","backtests/_script_helpers.py","backtests/generic_optimizer_research.ipynb","backtests/generic_tpe_research.ipynb","backtests/pmxt_book_joint_portfolio_runner.ipynb","backtests/polymarket_beffer45_trade_replay_telonex.ipynb","backtests/polymarket_beffer45_trade_replay_telonex.py","backtests/polymarket_book_ema_crossover.py","backtests/polymarket_book_ema_optimizer.py","backtests/polymarket_book_joint_portfolio_runner.py","backtests/polymarket_btc_5m_late_favorite_taker_hold.py","backtests/polymarket_btc_5m_pair_arbitrage.py","backtests/polymarket_pmxt_book_100_replay_runner.py","backtests/polymarket_telonex_book_100_replay_runner.py","backtests/polymarket_telonex_book_joint_portfolio_runner.py","backtests/private/.gitignore","backtests/private/__init__.py","backtests/private/telonex_binance_btc_download.py","backtests/private/telonex_btc_5m_late_favorite_chunked_forward_validate.py","backtests/private/telonex_btc_5m_microprice_imbalance_chunked_forward_validate.py","backtests/private/telonex_btc_5m_pair_arbitrage_chunked_forward_validate.py","backtests/private/telonex_btc_5m_passive_pair_accumulation_search.py","backtests/private/telonex_btc_5m_passive_pair_chunked_forward_validate.py","backtests/private/telonex_btc_5m_passive_pair_forward_validate.py","backtests/private/telonex_btc_5m_polymarket_download.py","backtests/private/telonex_btc_5m_snapshot_model_research.py","backtests/private/telonex_btc_5m_snapshot_model_runner_validate.py","backtests/private/telonex_btc_5m_snapshot_model_walkforward.py","backtests/private/telonex_general_market_value_rebound_search.py","backtests/private/telonex_resolved_sports_research.py","backtests/sitecustomize.py","backtests/telonex_book_joint_portfolio_runner.ipynb","crates/core/Cargo.toml","crates/core/src/events.rs","crates/core/src/lib.rs","crates/core/src/merge.rs","crates/core/src/pmxt.rs","crates/core/src/telonex.rs","crates/core/src/time.rs","crates/core/src/trades.rs","crates/core/src/windows.rs","crates/python/Cargo.toml","crates/python/pyproject.toml","crates/python/src/lib.rs","docs/account-ledger-replay.md","docs/backtests.md","docs/data-loading.md","docs/data-vendors.md","docs/execution-modeling.md","docs/index.md","docs/license.md","docs/live.md","docs/plotting.md","docs/project-status.md","docs/research.md","docs/setup.md","docs/stylesheets/overrides.css","docs/testing.md","docs/vendor-fetch-sources.md","docs_overrides/components/sidebar_item.html","docs_overrides/templates/sidebar.html","internal/v4-rust-data-loading-plan.md","live/.gitignore","live/btc_eth_sol_snapshot_model_sandbox.py","live/btc_snapshot_model_sandbox.py","live/models/btc_snapshot_model_s150_ev_guarded_cached_432_summary.json","live/models/btc_snapshot_model_s199_cost101_daily_stop120_profile.json","live/models/btc_snapshot_model_s204_btc_l2_full_mar1_may9.json","live/models/btc_snapshot_model_s223_btc_eth_sol_l2_full_feb12_may9.json","live/models/btc_snapshot_model_s226_btc_only_l2_full_feb12_may9.json","live/models/btc_snapshot_model_s231_btc_eth_sol_xrp_l2_full_feb12_may9.json","main.py","mermaid.md","mkdocs.yml","prediction_market_extensions/__init__.py","prediction_market_extensions/_native.py","prediction_market_extensions/_runtime_log.py","prediction_market_extensions/adapters/__init__.py","prediction_market_extensions/adapters/kalshi/__init__.py","prediction_market_extensions/adapters/kalshi/config.py","prediction_market_extensions/adapters/kalshi/data.py","prediction_market_extensions/adapters/kalshi/factories.py","prediction_market_extensions/adapters/kalshi/fee_model.py","prediction_market_extensions/adapters/kalshi/loaders.py","prediction_market_extensions/adapters/kalshi/market_selection.py","prediction_market_extensions/adapters/kalshi/providers.py","prediction_market_extensions/adapters/kalshi/research.py","prediction_market_extensions/adapters/polymarket/__init__.py","prediction_market_extensions/adapters/polymarket/execution.py","prediction_market_extensions/adapters/polymarket/fee_model.py","prediction_market_extensions/adapters/polymarket/gamma_markets.py","prediction_market_extensions/adapters/polymarket/loaders.py","prediction_market_extensions/adapters/polymarket/market_selection.py","prediction_market_extensions/adapters/polymarket/parsing.py","prediction_market_extensions/adapters/polymarket/pmxt.py","prediction_market_extensions/adapters/polymarket/research.py","prediction_market_extensions/adapters/prediction_market/__init__.py","prediction_market_extensions/adapters/prediction_market/backtest_utils.py","prediction_market_extensions/adapters/prediction_market/fill_model.py","prediction_market_extensions/adapters/prediction_market/info_sanitization.py","prediction_market_extensions/adapters/prediction_market/order_tags.py","prediction_market_extensions/adapters/prediction_market/replay.py","prediction_market_extensions/adapters/prediction_market/research.py","prediction_market_extensions/analysis/__init__.py","prediction_market_extensions/analysis/config.py","prediction_market_extensions/analysis/legacy_backtesting/__init__.py","prediction_market_extensions/analysis/legacy_backtesting/models.py","prediction_market_extensions/analysis/legacy_backtesting/plotting.py","prediction_market_extensions/analysis/legacy_backtesting/progress.py","prediction_market_extensions/analysis/legacy_plot_adapter.py","prediction_market_extensions/analysis/tearsheet.py","prediction_market_extensions/backtesting/__init__.py","prediction_market_extensions/backtesting/_artifact_paths.py","prediction_market_extensions/backtesting/_backtest_runtime.py","prediction_market_extensions/backtesting/_execution_config.py","prediction_market_extensions/backtesting/_experiments.py","prediction_market_extensions/backtesting/_isolated_replay_runner.py","prediction_market_extensions/backtesting/_market_data_config.py","prediction_market_extensions/backtesting/_market_data_support.py","prediction_market_extensions/backtesting/_notebook_runner.py","prediction_market_extensions/backtesting/_notebook_support.py","prediction_market_extensions/backtesting/_optimizer.py","prediction_market_extensions/backtesting/_prediction_market_backtest.py","prediction_market_extensions/backtesting/_prediction_market_runner.py","prediction_market_extensions/backtesting/_replay_specs.py","prediction_market_extensions/backtesting/_result_policies.py","prediction_market_extensions/backtesting/_strategy_configs.py","prediction_market_extensions/backtesting/_timing_harness.py","prediction_market_extensions/backtesting/_timing_test.py","prediction_market_extensions/backtesting/data_sources/__init__.py","prediction_market_extensions/backtesting/data_sources/_common.py","prediction_market_extensions/backtesting/data_sources/data_types.py","prediction_market_extensions/backtesting/data_sources/kalshi_native.py","prediction_market_extensions/backtesting/data_sources/platforms.py","prediction_market_extensions/backtesting/data_sources/pmxt.py","prediction_market_extensions/backtesting/data_sources/polymarket_native.py","prediction_market_extensions/backtesting/data_sources/registry.py","prediction_market_extensions/backtesting/data_sources/replay_adapters.py","prediction_market_extensions/backtesting/data_sources/telonex.py","prediction_market_extensions/backtesting/data_sources/vendors.py","prediction_market_extensions/backtesting/optimizers/__init__.py","prediction_market_extensions/backtesting/prediction_market/__init__.py","prediction_market_extensions/backtesting/prediction_market/artifacts.py","prediction_market_extensions/backtesting/prediction_market/reporting.py","prediction_market_extensions/live/__init__.py","prediction_market_extensions/live/btc_5m.py","prediction_market_extensions/live/btc_features.py","prediction_market_extensions/live/sandbox.py","prediction_market_extensions/live/settlement.py","pyrightconfig.json","scripts/__init__.py","scripts/_cache_clear_guard.py","scripts/_pmxt_raw_download.py","scripts/_profile_telonex.py","scripts/_script_helpers.py","scripts/_telonex_data_download.py","scripts/benchmark_100_replay_loading.py","scripts/benchmark_native_loader_helpers.py","scripts/generate_codebase_uml.py","scripts/pmxt_download_raws.py","scripts/run_all_backtests.py","scripts/telonex_download_data.py","strategies/README.md","strategies/__init__.py","strategies/_validation.py","strategies/account_trade_replay.py","strategies/binary_pair_arbitrage.py","strategies/breakout.py","strategies/core.py","strategies/deep_value.py","strategies/ema_crossover.py","strategies/final_period_momentum.py","strategies/late_favorite_limit_hold.py","strategies/mean_reversion.py","strategies/microprice_imbalance.py","strategies/panic_fade.py","strategies/private/.gitignore","strategies/private/__init__.py","strategies/private/btc_snapshot_model.py","strategies/private/passive_pair_accumulation.py","strategies/rsi_reversion.py","strategies/threshold_momentum.py","strategies/vwap_reversion.py","tests/__init__.py","tests/conftest.py","tests/test_backtest_script_entrypoints.py","tests/test_backtest_script_helpers.py","tests/test_backtest_utils.py","tests/test_benchmark_100_replay_loading.py","tests/test_binary_pair_arbitrage.py","tests/test_book_strategy_configs.py","tests/test_breakout_strategy_behavior.py","tests/test_docs_nav.py","tests/test_downsample_html_size.py","tests/test_execution_slippage.py","tests/test_info_sanitization.py","tests/test_joint_portfolio_artifacts.py","tests/test_kalshi_fee_model.py","tests/test_kalshi_native_data_source.py","tests/test_legacy_plot_fill_markers.py","tests/test_limit_hold_regressions.py","tests/test_live_sandbox.py","tests/test_main.py","tests/test_makefile_targets.py","tests/test_market_data_support.py","tests/test_microprice_imbalance_strategy.py","tests/test_native.py","tests/test_nautilus_override_bootstrap.py","tests/test_notebook_runner.py","tests/test_notebook_support.py","tests/test_notice_license_coverage.py","tests/test_optimizer.py","tests/test_pmxt_data_source.py","tests/test_pmxt_raw_download.py","tests/test_polymarket_fees.py","tests/test_polymarket_native_data_source.py","tests/test_polymarket_pmxt_cache.py","tests/test_polymarket_pmxt_loader.py","tests/test_polymarket_pmxt_runner.py","tests/test_prediction_market_backtest.py","tests/test_prediction_market_execution.py","tests/test_prediction_market_report_timestamps.py","tests/test_prediction_market_summary_stats.py","tests/test_replay_adapter_architecture.py","tests/test_reporting_regressions.py","tests/test_result_policies.py","tests/test_runtime_log.py","tests/test_strategy_config_validation.py","tests/test_strategy_configs.py","tests/test_strategy_core.py","tests/test_subprocess_timing_bootstrap.py","tests/test_telonex_data_download.py","tests/test_telonex_data_source.py","tests/test_timing_harness.py","tests/test_timing_test.py"],"storefront":"/r/evan-kolberg","claimed":false,"request_supported":{"post":"https://gitbuyer.com/r/evan-kolberg/prediction-market-backtesting/request-supported","requests":0},"note":"indexed from public GitHub; nothing is for sale on this page. Clone it from GitHub. Paid listings live at /search."}