Skip to main content

An agent-native trading system for prediction markets

Project description

Coinjure

Agent-Native Trading System for Prediction Markets

Python 3.10+ PyPI version License Slack WeChat Blog Docs

Coinjure is an agent-native trading framework for prediction markets. It empowers LLM agents to drive the entire strategy lifecycle purely through CLI commands — autonomously discovering cross-market relations, building executable strategies, running large-scale backtests, and deploying to live execution.

Using Coinjure, LLM agents can discover over 100 backtest-positive strategies in a single hour — a capability validated by deploying to live trading and generating real profit on prediction market exchanges.

Demos

Installation

pip install coinjure

From source:

git clone https://github.com/ulab-uiuc/prediction-market-cli.git
cd prediction-market-cli
pip install poetry
poetry install

Quick Start

1) Discover — find markets and detect tradable relations

coinjure market discover -q "election" --exchange both --limit 20

Searches Polymarket and Kalshi, then auto-detects structural relations (exclusivity, complementary, implication) within each event. Discovered relations are persisted to ~/.coinjure/relations.json.

2) Backtest — validate strategies against historical data

coinjure engine backtest --all-relations

Each relation type auto-selects its matching strategy (see table above). Only relations with positive PnL advance to the next stage.

3) Paper trade — simulate live execution

coinjure engine paper-run --all-relations --detach

Deploys all backtest-passed strategies as independent background processes. Use coinjure engine monitor to attach a live TUI dashboard.

4) Live trade — execute with real funds

coinjure engine live-run --exchange polymarket --all-relations --detach

Requires exchange credentials (see Environment Variables).

5) Monitor and control

coinjure engine monitor         # live TUI across all engines
coinjure engine pause  --all    # pause all strategies
coinjure engine resume --all    # resume
coinjure engine killswitch --on # emergency halt

Coinjure Monitor

System Overview

The pipeline has four stages:

LLM Agent + market data
    → [1. Discovery]  — discover cross-market relations via CLI
    → [2. Backtest]   — validate each relation against historical data
    → [3. Execution]  — paper-trade or live-trade validated strategies
    → [4. Monitoring]  — human operator monitors and intervenes when needed

Core runtime components:

TradingEngine
  ├── DataSource          (Live / Historical / Hub)
  ├── Strategy            (Relation-based / LLM-powered / Custom)
  └── Trader              (PaperTrader / PolymarketTrader / KalshiTrader)
       ├── RiskManager    (Standard / Conservative / Aggressive)
       └── PositionManager

Each engine instance runs as an independent OS process, allowing hundreds of strategies to execute in parallel without shared-state contention. A ControlServer (Unix socket) provides per-instance pause/resume/status/stop, while the StrategyRegistry persists portfolio state across sessions.

Human-in-the-Loop Model

The operator is intentionally lightweight:

  • Use coinjure engine monitor for live TUI visibility across all running engines.
  • Use coinjure engine pause|resume|stop for intervention.
  • Use coinjure engine killswitch --on for emergency halt.
  • Use coinjure engine swap for hot-swapping strategy logic without restarting.

The operator should not need to manually place/cancel orders in normal operation.

CLI Reference

coinjure market — Market discovery and analysis

Command Description
market info Fetch detailed info for a market (by ID or slug)
market discover Multi-keyword search + auto structural relation discovery
market news Fetch news headlines (Google, RSS, TheNewsAPI)
market relations list List stored market relations (filter by type/status)
market relations add Create a relation between 2+ markets
market relations remove Remove a relation by ID

coinjure engine — Trading engine and portfolio management

Command Description
engine paper-run Start paper trading (single strategy or --all-relations batch)
engine live-run Start live trading with real funds
engine backtest Backtest relations against historical order book data
engine list Show all strategies in the portfolio registry
engine status Show engine status: positions, PnL, decisions, trades
engine pause Pause decision-making (--all for all instances)
engine resume Resume after pause
engine stop Graceful shutdown (--all for all instances)
engine swap Hot-swap strategy without restarting
engine retire Stop and mark as retired (--all for all instances)
engine promote Promote relation(s) from paper to deployed
engine monitor Attach live TUI dashboard to running engines
engine killswitch Toggle the global emergency kill-switch

Environment Variables

export POLYMARKET_PRIVATE_KEY="your_private_key"      # Polymarket live trading
export KALSHI_API_KEY_ID="your_kalshi_key_id"         # Kalshi live trading
export KALSHI_PRIVATE_KEY_PATH="/path/key.pem"        # Kalshi live trading

Citation

If you find Coinjure useful in your research or work, please cite:

@software{coinjure2026,
  title   = {Coinjure: An Agent-Native Trading System for Prediction Markets},
  author  = {Yu, Haofei and Yang, Yicheng and Liu, Yuxiang and You, Jiaxuan},
  year    = {2026},
  url     = {https://github.com/ulab-uiuc/prediction-market-cli},
  note    = {University of Illinois Urbana-Champaign}
}

License

MIT

Disclaimer

This software is for educational and research use. Live trading carries financial risk.

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

coinjure-0.1.1.tar.gz (174.6 kB view details)

Uploaded Source

Built Distribution

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

coinjure-0.1.1-py3-none-any.whl (216.1 kB view details)

Uploaded Python 3

File details

Details for the file coinjure-0.1.1.tar.gz.

File metadata

  • Download URL: coinjure-0.1.1.tar.gz
  • Upload date:
  • Size: 174.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.3.2 CPython/3.10.16 Darwin/22.6.0

File hashes

Hashes for coinjure-0.1.1.tar.gz
Algorithm Hash digest
SHA256 515725234de39c27fb3b2a23944332b9b8c98b73640076ba4fc4ed7445008700
MD5 b25bd9ff3e89a8cee69a48d1ea5954f1
BLAKE2b-256 537964b2205f5955761c8eb23aaa02c3e7d276cb7f71f216ad7b95009b7a54bb

See more details on using hashes here.

File details

Details for the file coinjure-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: coinjure-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 216.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.3.2 CPython/3.10.16 Darwin/22.6.0

File hashes

Hashes for coinjure-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 88c2af96473ac884f60432f3e0443235fd03f58fb2eac1788373ca16bba1923f
MD5 5e613d0fe8ff837d3c4e9d93e28f0bda
BLAKE2b-256 20c5bd3afecd078b7fab37accae93b6917e76f2f5e0acd0b231fa34792ea7a7d

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