Skip to main content

Autonomous prediction market investment toolkit for Kalshi

Project description

TraderBot

PyPI version Python 3.12 License: MIT

Autonomous prediction market investment toolkit for Kalshi.

TraderBot provides the data pipeline, statistical analysis, risk enforcement, simulation, and execution layer that an AI agent needs to trade prediction markets.

Core Principle

Dumb pipe with smart guards. The toolkit handles the how (API calls, data normalization, risk limits, execution) but never the why (what to trade, when, how much). The agent decides strategy; the toolkit ensures execution is safe, correct, and auditable.

This separation is deliberate: it eliminates emotional bias from the execution layer. Even if the agent's LLM "decides" to go all-in on a hunch, hard-coded risk guards reject the order before it reaches the exchange.

Install

From PyPI (recommended)

pip install traderbot

From source

git clone https://github.com/JsonDaRula69/TraderBot.git
cd TraderBot
uv sync  # or: pip install -e .

One-Liner Install (Linux/macOS)

curl -fsSL https://raw.githubusercontent.com/JsonDaRula69/TraderBot/main/install/traderbot-installer.sh | bash

One-Liner Install (Linux/macOS)

curl -fsSL https://raw.githubusercontent.com/JsonDaRula69/TraderBot/main/install/traderbot-installer.sh | bash

Or install directly from PyPI on any platform:

pip install traderbot

Requires Python 3.12 and Kalshi API credentials (sign up at kalshi.com and generate an API key + RSA key pair).

Quick Start

# Store Kalshi credentials in your OS keyring
traderbot auth set-kalshi

# Scan available weather markets
traderbot scan --category weather

# Analyze a specific market
traderbot analyze KXHIGHNY-26JUN02-T72

# Paper trade with a strategy
traderbot paper momentum

# View your positions
traderbot positions

# Check for updates
traderbot update --check

Using with OpenClaw AI Agents

TraderBot integrates with OpenClaw for autonomous agent operation:

# Create a profile for your agent
traderbot profile create --name weather-agent --category weather

# Assign the profile token
traderbot profile assign --agent weather-agent --token $(traderbot profile token weather-agent)

The agent runs three autonomous loops: decision (every 5 min), heartbeat (every 30 min), and news/sentiment (event-driven). See docs/architecture.md for details.

CLI Overview

| Command | Description | |---|---|---| | traderbot scan | List open markets across categories | | traderbot analyze TICKER | Orderbook depth + implied probability | | traderbot signals | Active trading signals | | traderbot trade | Place an order through risk checks | | traderbot positions | View open positions | | traderbot audit | Decision history with filters | | traderbot performance | P&L and win-rate metrics | | traderbot paper | Run a paper trading session | | traderbot backtest | Run backtests against historical data | | traderbot compare | Compare profiles across strategies | | traderbot halt | Circuit breaker status check | | traderbot resume | Clear circuit breaker halt state | | traderbot heartbeat | Self-review cycle | | traderbot learnings | List and promote learned patterns | | traderbot check-settlements | Check for recently settled markets | | traderbot reconcile | Sync local positions with Kalshi API | | traderbot cache warm | Pre-populate event category cache | | traderbot data forecasts | Weather forecasts with NWS + GFS/ECMWF/GEM ensemble | | traderbot data signals | Trading signals by category | | traderbot data bias CITY | Historical forecast bias for a city | | traderbot news-context | News context for a category | | traderbot news-ingest | Fetch, classify, embed news to ChromaDB | | traderbot data-points | Query ChromaDB for structured data readings | | traderbot backfill | One-time or recurring historical data backfill | | traderbot sentiment TICKER | Analyze market sentiment from news | | traderbot auth | Credential management (set-kalshi, check, migrate, rotate) | | traderbot profile | Multi-agent profile management (create, list, assign, revoke) | | traderbot cron | Register heartbeat cron jobs with OpenClaw | | traderbot bootstrap | One-time environment setup wizard | | traderbot experiment | A/B test harness (populate, verify, run, results) | | traderbot update | Check for and apply updates | | traderbot uninstall | Remove TraderBot and all artifacts |

Project Structure

src/traderbot/
├── kalshi/           # Kalshi exchange adapter (client, models, signing, trading, websocket)
├── analysis/         # Statistical computation (indicators, odds, signals, registry)
├── risk/             # Immutable risk enforcement (limits, sizing, circuit breaker)
├── simulation/       # Backtesting engine & paper trading
├── news/             # News & sentiment pipeline (sources, classifier, embeddings, impact)
├── data/             # Data providers (weather NWS/Open-Meteo, base provider/signal ABCs)
├── db/               # SQLite persistence (positions, decisions, learnings, vectors, WAL)
├── profiles/         # Multi-agent profile system (models, runtime, injection, token)
├── cli/              # Typer CLI entry point and sub-commands (9 modules)
├── experiment/       # Experiment design, harness, and evaluation (treatments, results, registry)
├── sandbox.py        # Application-level filesystem sandbox (macOS sandbox-exec + chmod)
├── auth.py           # Credential management (keyring, .env, master password)
├── paper.py          # Paper balance computation
├── learning.py       # Learning log manager
├── heartbeat.py      # Self-review cycle
├── updater.py        # Version management (check, install mode detection, auto-update)
├── wal.py            # Write-ahead log for crash-safe trade execution
└── paths.py          # Data directory resolution

Documentation

Document Scope
docs/architecture.md Three-loop system, components, data flow
docs/kalshi.md Kalshi API reference
docs/risk.md Risk guards, circuit breakers, position sizing
docs/simulation.md Backtest engine, paper trading
docs/profiles.md Profile system, tokens, multi-agent
docs/deployment.md Production deployment
docs/api.md Full CLI reference

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

traderbot-0.15.14.tar.gz (2.6 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

traderbot-0.15.14-py3-none-any.whl (306.6 kB view details)

Uploaded Python 3

File details

Details for the file traderbot-0.15.14.tar.gz.

File metadata

  • Download URL: traderbot-0.15.14.tar.gz
  • Upload date:
  • Size: 2.6 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.19 {"installer":{"name":"uv","version":"0.11.19","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for traderbot-0.15.14.tar.gz
Algorithm Hash digest
SHA256 0b894e08729751ac200e757c8e58fa0c890da4b1dde54cbef71e896db7ca8f8a
MD5 d2164ce5dc534011b50e7915e626e4c8
BLAKE2b-256 42a246e99878111c6a376f437a23c884c068b6bc81a1490f9962e0ce9d1079b1

See more details on using hashes here.

File details

Details for the file traderbot-0.15.14-py3-none-any.whl.

File metadata

  • Download URL: traderbot-0.15.14-py3-none-any.whl
  • Upload date:
  • Size: 306.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.19 {"installer":{"name":"uv","version":"0.11.19","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for traderbot-0.15.14-py3-none-any.whl
Algorithm Hash digest
SHA256 e7ef46708f9a5fb6fc4b2a6b0055016eeeeb97361633880113bca3d9535fb5d6
MD5 6adaeb5ae58dd8a0434ed6040a9a4cc2
BLAKE2b-256 481ecca1e7bfcf2620fd1e3dc072d13698718f717e1f42986ff8e0c04730c9a8

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page