Skip to content

Repository files navigation

BitCo Bot

A fast, Rust-first trading bot for Polymarket BTC Up/Down 5m & 15m markets. One central Rust engine owns all live state and runs the decision cycle on every tick; strategies never place orders, the risk manager can block every entry, and every decision is logged.

Architecture

Bybit / Binance / Chainlink / Polymarket WS  ──►  collectors (events)
                                                     │  bounded channel
                                                     ▼
            in-memory state ─► feature builder ─► fair probability
                ─► strategy controller ─► ML filter ─► risk manager
                ─► executor (paper|live) ─► logs / DB / dashboard

Decision flow and design rules follow 01_system_architecture.md / 03_strategy_risk_execution.md. See progress_context.md for every place the implementation diverged from the docs and why.

Components

Path What
trading-engine-rust/ The engine: market data, features, fair probability, strategies, ML inference, risk, execution, storage, telemetry, API.
dashboard-typescript/ Next.js read-only monitor + safe controls (pause/resume/cancel-all/emergency-stop) + revenue chart.
research-python/ Offline ML training, Python/Rust parity test, backtesting. Never in the live path.
database/ PostgreSQL/TimescaleDB schema + migration.
ops/ systemd units, deploy/backup/healthcheck scripts, docker-compose (local), .env.example.
trading-engine-rust/config/strategy.toml All thresholds (defaults = strategy doc), fully editable.

Quick start (paper mode)

cd trading-engine-rust
cargo test                 # 77 tests
cargo run --release        # engine + API on http://127.0.0.1:8080

# in another shell
curl -s http://127.0.0.1:8080/state | jq .

Dashboard:

cd dashboard-typescript
npm install && npm run build
ENGINE_API_BASE=http://127.0.0.1:8080 node .next/standalone/server.js   # http://localhost:3000

Analyzing Tool:

cd research-python/analyzer
./run.sh #for the first time

#after first time
./sync_logs.sh

Trading modes

OFFLINE_BACKTEST · PAPER_LIVE_DATA · SHADOW_LIVE · LIVE_SMALL · LIVE_NORMAL · PAUSED · EMERGENCY. Set in config/strategy.toml [engine].mode. Live order placement additionally requires POLY_* credentials and the EIP-712 signer (see progress_context.md §4.7); without them the engine stays paper-safe.

Safety invariants

  1. Strategies return candidates; only the executor places/cancels orders.
  2. The risk manager can block every entry; exits are never blocked.
  3. The dashboard cannot drive the trading loop — controls are advisory commands.
  4. Paper and live use the same strategy code.
  5. Every decision produces a log record; every no-trade has a reason.
  6. Stale data, low disk, position mismatch, or loss limits stop new entries.

Core design rule

After every win or loss the logs must answer: did we lose because the prediction was wrong, or because execution/data was bad? If they can't, it's not ready for real money.

Status

Engine builds and runs live in paper mode (pulls real Bybit/Binance BTC prices); all tests + clippy clean; dashboard builds; ML Rust/Python parity verified. Outstanding before live money: validate Polymarket market discovery against the live API, complete Chainlink HMAC auth (or keep the documented fallback), and implement EIP-712 order signing. Full detail in progress_context.md.


The original design pack lives in polymarket_bot_system_docs/ (system architecture, market data/APIs, strategies/risk/execution, ML/logging/ backtesting, dashboard/deployment/ops, problems/checklists, references).

About

Polymarket BTC Up/Down Bot

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages