Autonomous AI trading agent for Polymarket prediction markets. Sports, crypto, news, and general market pipelines.
Project description
predikt
Autonomous AI trading agent for Polymarket prediction markets. Trade sports, crypto, news, and general markets — autonomously or with a single command.
Install
pip install predikt
Quick Start
-
Set up your keys — create a
.envfile:POLYGON_WALLET_PRIVATE_KEY=<your-polygon-private-key> POLYMARKET_FUNDER_ADDRESS=<your-funder-address> OPENAI_API_KEY=<your-openai-key>
Optional for extended features:
NEWSAPI_API_KEY=<your-newsapi-key> # news-enriched analysis TAVILY_API_KEY=<your-tavily-key> # web search context SPORTS_DATA_API_KEY=<your-sportsdata-key> # live sports stats SPORTS_ODDS_API_KEY=<your-odds-key> # live odds feeds
-
Run it:
predikt run-autonomous-traderThat's it. The agent scans Polymarket events, runs LLM-powered superforecaster analysis, and executes trades when it finds mispriced markets.
Pipelines
predikt ships with five autonomous trading pipelines:
| Pipeline | Command | What it does |
|---|---|---|
| General | predikt run-autonomous-trader |
Scans all Polymarket events, filters candidates via RAG, runs two-stage LLM analysis, executes best trades |
| Continuous | predikt run-continuous |
High-speed loop — trades trending/breaking events every N seconds |
| Sports | predikt-sports |
Live sports trading via WebSocket — pre-game positioning + in-game score-change reactions |
| Crypto | predikt run-crypto |
Real-time crypto price feeds + LLM analysis for BTC/ETH/SOL/XRP markets |
| BTC Arbitrage | predikt run-crypto-arbitrage |
Pure algorithmic — no LLM. Dual Binance + Chainlink price feeds, 15-second intervals |
CLI Reference
Autonomous Trading
# Default: scan all markets, pick the best trade
predikt run-autonomous-trader
# Scope to a single event
predikt run-autonomous-trader --event-url "https://polymarket.com/event/..."
# Include news context in analysis
predikt run-autonomous-trader --include-news --news-limit 10 --news-days 3
# Exclude sports markets
predikt run-autonomous-trader --exclude-sports
Analyze a Specific Event
# Run prediction pipeline without executing (respects EXECUTE_TRADES env var)
predikt analyze-event-url "https://polymarket.com/event/..."
# With news enrichment
predikt analyze-event-url "https://polymarket.com/event/..." --news-limit 10
Continuous Trading
# Trade every 30 seconds, $100 session budget
predikt run-continuous
# Custom interval and budget
predikt run-continuous --interval 60 --session-budget 250
# With cooldown between trades on the same market
predikt run-continuous --cooldown 600 --volatility-threshold 0.08
Sports Trading
# Start the live sports pipeline
predikt-sports
# Connects to Polymarket sports WebSocket, streams live game state,
# executes pre-game + in-game trades autonomously.
Sports pipeline features:
- Pre-game: Two-stage LLM analysis (blind probability → market-aware value detection)
- In-game: Fast-path (cached probability, no LLM) and slow-path (full re-analysis) on score changes
- All sports: NFL, NBA, MLB, NHL, CFB, CBB, soccer, esports, tennis
- Budget coordination: Cross-process filelock with configurable per-sport caps
Key environment variables:
SPORTS_BUDGET_FRACTION="0.30" # fraction of wallet for sports
SPORTS_EXECUTE_TRADES="false" # sports-specific trade toggle
SPORTS_CAP_NFL="0.4" # per-sport budget caps
SPORTS_CAP_NBA="0.3"
SPORTS_CAP_MLB="0.15"
SPORTS_CAP_NHL="0.15"
SPORTS_INGAME_COOLDOWN_SECONDS="30" # per-game cooldown
SPORTS_MAX_GAME_EXPOSURE_USD="50.0" # max USD per game
Crypto Trading
# Trade crypto price markets with live WebSocket feeds
predikt run-crypto
# Custom symbols and edge threshold
predikt run-crypto --symbols "BTC,ETH,SOL" --min-edge 0.08 --session-budget 200
# BTC 5-minute interval arbitrage (no LLM, pure price momentum)
predikt run-crypto-arbitrage --session-budget 50 --min-edge 0.10
Market Exploration
# Browse markets sorted by spread
predikt get-all-markets --limit 10 --sort-by spread
# Browse events sorted by number of markets
predikt get-all-events --limit 10
# Search news for market context
predikt get-relevant-news "bitcoin ETF" --limit 5 --days 3
# Check wallet and USDC balance
predikt diagnose-usdc-balance
LLM & Forecasting
# Ask the superforecaster about a specific market
predikt ask-superforecaster "US Election" "Will Biden win?" "yes"
# General LLM query
predikt ask-llm "What factors affect prediction market liquidity?"
# LLM query with live Polymarket context
predikt ask-polymarket-llm "What are the best crypto markets to trade right now?"
RAG (Local Market Database)
# Build a local vector database of Polymarket events
predikt create-local-markets-rag ./local_db_events
# Query the local database
predikt query-local-markets-rag ./local_db_events "upcoming elections"
Configuration
All configuration is via environment variables. Create a .env file in the project root — predikt loads it automatically.
Core Settings
| Variable | Default | Description |
|---|---|---|
POLYGON_WALLET_PRIVATE_KEY |
— | Your Polygon wallet private key |
POLYMARKET_FUNDER_ADDRESS |
— | Polymarket funder address |
OPENAI_API_KEY |
— | OpenAI API key for LLM analysis |
OPENAI_MODEL |
gpt-5-mini |
Model to use for analysis |
EXECUTE_TRADES |
false |
Master trade execution toggle — set true for live trading |
APP_LOG_LEVEL |
INFO |
Logging verbosity |
Trade Parameters
| Variable | Default | Description |
|---|---|---|
TRADE_TOTAL_BUDGET_FRACTION |
0.30 |
Fraction of wallet to use per session |
TRADE_MAX_PER_MARKET_FRACTION |
0.10 |
Max fraction per single market |
TRADE_CANDIDATE_COUNT |
5 |
Number of candidates to evaluate |
TRADE_DIVERSITY_MODE |
soft_quota |
Diversification strategy |
TRADE_MIN_MARKET_VOLUME |
10000 |
Minimum market volume filter |
TRADE_MIN_MARKET_LIQUIDITY |
5000 |
Minimum market liquidity filter |
Continuous Mode
| Variable | Default | Description |
|---|---|---|
CONTINUOUS_INTERVAL_SECONDS |
30 |
Seconds between trade cycles |
CONTINUOUS_SESSION_BUDGET |
100 |
Session budget in USDC |
CONTINUOUS_COOLDOWN_SECONDS |
300 |
Per-market cooldown |
CONTINUOUS_VOLATILITY_THRESHOLD |
0.05 |
Minimum volatility to trade |
Crypto Mode
| Variable | Default | Description |
|---|---|---|
CRYPTO_SYMBOLS |
BTC,ETH,SOL,XRP |
Symbols to trade |
CRYPTO_MIN_EDGE |
0.05 |
Minimum edge to execute |
ARB_MIN_EDGE |
0.10 |
Minimum edge for BTC arbitrage |
ARB_PRICE_FEED_TOLERANCE |
0.001 |
Cross-feed price tolerance |
See .env.example for the full list of 60+ configuration variables.
Architecture
predikt
├── agents/
│ ├── application/ # trading pipelines and strategies
│ │ ├── trade.py # general autonomous trader
│ │ ├── continuous.py # high-speed continuous loop
│ │ ├── crypto.py # crypto price market strategy
│ │ ├── btc_arbitrage.py # pure algorithmic BTC arb
│ │ ├── sports_trader.py # pre-game sports trading
│ │ ├── ingame_trader.py # live in-game trading engine
│ │ ├── executor.py # two-stage LLM analysis engine
│ │ ├── budget.py # cross-process budget coordinator
│ │ └── ...
│ ├── connectors/ # external data sources
│ │ ├── sports_ws.py # Polymarket sports WebSocket
│ │ ├── sports_data.py # external sports stats API
│ │ ├── chroma.py # ChromaDB RAG connector
│ │ ├── news.py # NewsAPI connector
│ │ └── ...
│ ├── polymarket/ # Polymarket API clients
│ │ ├── polymarket.py # CLOB order execution
│ │ └── gamma.py # Gamma API market discovery
│ ├── utils/
│ └── sports.py # sports pipeline entry point
└── scripts/
└── python/
└── cli.py # CLI entry point (typer)
How It Works
- Discovery — Scans Polymarket events via Gamma API, filters by category, volume, liquidity
- Context — Enriches candidates with news (NewsAPI), web search (Tavily), and RAG (ChromaDB)
- Analysis — Two-stage LLM superforecaster: blind probability estimate → market-aware value detection
- Execution — Places orders via Polymarket CLOB API with confidence-weighted budget allocation
- Coordination — Cross-process budget management with filelock for multi-pipeline operation
Safety
- Dry-run by default —
EXECUTE_TRADES=falseout of the box. No trades execute until you explicitly enable it. - Paper mode first — Test with small budgets before going live.
- Budget caps — Per-market, per-sport, and per-session limits prevent runaway spending.
- Cross-process safety — Filelock-based budget coordination when running multiple pipelines.
- Minimum order guards — Configurable floor on order size and market quality filters.
Build from Source
git clone https://github.com/vahagn-madatyan/predikt.git
cd predikt
python -m venv .venv
source .venv/bin/activate
pip install -e ".[dev]"
Run tests:
pytest tests/ -q
Attribution
This project was forked from Polymarket's agents repository, extended with autonomous sports, crypto, and continuous trading pipelines.
Disclaimer
This software is for educational and research purposes. Trading on prediction markets involves risk — you can lose money. No trading system is guaranteed to be profitable. Always start with paper/dry-run mode. The authors are not responsible for any financial losses incurred through use of this software.
This code is free and publicly available under the MIT License.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file predikt-0.1.2.tar.gz.
File metadata
- Download URL: predikt-0.1.2.tar.gz
- Upload date:
- Size: 148.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ec4ca3d6c7027c185da18c049d6eb458c93bf181fd4c4be6bee54737e1c98f4d
|
|
| MD5 |
3ec17d58542905da6f281d1a89d0dade
|
|
| BLAKE2b-256 |
3610fe03690f3a07bfbcf5e829193d941e4341c235e1d8854455458842dbc890
|
Provenance
The following attestation bundles were made for predikt-0.1.2.tar.gz:
Publisher:
pypi-publish.yml on vahagn-madatyan/predikt
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
predikt-0.1.2.tar.gz -
Subject digest:
ec4ca3d6c7027c185da18c049d6eb458c93bf181fd4c4be6bee54737e1c98f4d - Sigstore transparency entry: 1120960143
- Sigstore integration time:
-
Permalink:
vahagn-madatyan/predikt@76dca3b9f0f539742470ead1306bc72866da1be7 -
Branch / Tag:
refs/tags/v0.1.2 - Owner: https://github.com/vahagn-madatyan
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
pypi-publish.yml@76dca3b9f0f539742470ead1306bc72866da1be7 -
Trigger Event:
push
-
Statement type:
File details
Details for the file predikt-0.1.2-py3-none-any.whl.
File metadata
- Download URL: predikt-0.1.2-py3-none-any.whl
- Upload date:
- Size: 109.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d8b1c5333c9f2fdb1ba6486a998b9df35d55686acabee22e0c0758136b1eb739
|
|
| MD5 |
a29a8a8972884bb2ae5752384d6d9e44
|
|
| BLAKE2b-256 |
2d7734e09d94e5b778005643742ad0762eca4b9e1113848b83d49404538a4bf6
|
Provenance
The following attestation bundles were made for predikt-0.1.2-py3-none-any.whl:
Publisher:
pypi-publish.yml on vahagn-madatyan/predikt
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
predikt-0.1.2-py3-none-any.whl -
Subject digest:
d8b1c5333c9f2fdb1ba6486a998b9df35d55686acabee22e0c0758136b1eb739 - Sigstore transparency entry: 1120960225
- Sigstore integration time:
-
Permalink:
vahagn-madatyan/predikt@76dca3b9f0f539742470ead1306bc72866da1be7 -
Branch / Tag:
refs/tags/v0.1.2 - Owner: https://github.com/vahagn-madatyan
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
pypi-publish.yml@76dca3b9f0f539742470ead1306bc72866da1be7 -
Trigger Event:
push
-
Statement type: