A TypeScript skeleton bot for 5-minute prediction markets on Polymarket, combining on-chain style signals with optional LLM contextβbuilt for paper trading and backtesting.
- π― 5m horizon β Predicts whether the YES price will be higher in 5 minutes using a lightweight ensemble (momentum, volatility, whale flow, optional LLM).
- π Whale flow proxy β Uses recent large trades and volume/price metadata as a proxy for βsmart moneyβ flow (no wallet-level fills yet).
- π Market microstructure β Short-term price momentum (30s, 2m) and 2m volatility feed into the model.
- π€ Optional LLM scorer β You can plug in an OpenAI-compatible model to add a narrative/context bias to the score.
- π Paper-trading engine β Position sizing, edge threshold, and HOLD/BUY/SELL logic without real money until youβre ready.
cd openclaw-polymarket-betting-bot
npm i
cp .env.example .env
npm run devThe bot will poll the configured market, compute features, run the predictor, and log actions (e.g. HOLD, BUY YES, SELL YES) with p5m and confidence in the console.
See live predictions and compare them to what actually happened after 5 minutes:
npm run ui
# open http://localhost:8787The UI lets you:
- Fetch the latest bot prediction snapshot (market, current YES price, predicted side, P(UP 5m), confidence).
- Enter the actual YES price after 5 minutes (or use the auto-compare delay).
- Compare predicted side vs actual outcome (YES/NO).
- Track running accuracy (correct predictions / total).
βββ src/
β βββ app/ # Bot entry point
β β βββ index.ts # Poll loop (npm run dev)
β βββ server/ # UI HTTP server
β β βββ index.ts # Serves ui/ + /api/prediction (npm run ui)
β βββ lib/ # Shared core (used by app + server)
β βββ config.ts # Env config
β βββ types/ # Shared types
β βββ connectors/ # Polymarket API
β βββ engine/ # Features, predictor, paper trader
β βββ models/ # Optional LLM scorer
βββ ui/
β βββ index.html
β βββ css/style.css
β βββ js/app.js
βββ .env, .env.example
βββ package.json
| Part | Role |
|---|---|
| app | Bot entry: runs the prediction loop (connector β features β predictor β paper trader). |
| server | Serves ui/ and /api/prediction for the compare UI. |
| lib | Shared code: config, types, connectors, engine (features, predictor, paper trader), models (LLM). |
- Polymarket β
POLYMARKET_REST_BASE,POLYMARKET_MARKET_SLUGorPOLYMARKET_MARKET_ID(optional; otherwise the bot picks an active BTC up/down market). - Loop β
LOOP_SECONDS(how often to run the prediction loop). - Paper trading β
MAX_POSITION_USD,EDGE_THRESHOLD. - LLM β
OPENAI_API_KEY, optionalOPENAI_BASE_URL,OPENAI_MODEL.
See .env.example for all variables.
- Paper-trading by default β No real orders are placed; the connector pulls real market snapshots for a realistic test.
- Whale flow is currently a proxy (volume/price-change metadata), not wallet-level fills.
- You can pin a market with
POLYMARKET_MARKET_SLUGorPOLYMARKET_MARKET_ID. - No strategy guarantees profits β Use for learning and experimentation.
If the project is interesting for you, give it a star on GitHub. If you want to know the project in more detail or have questions, please contact me β Iβd be happy to chat.