[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"project-77566":3},{"id":4,"name":5,"fullName":6,"owner":7,"repo":5,"description":8,"homepage":9,"htmlUrl":10,"language":11,"languages":10,"totalLinesOfCode":10,"stars":12,"forks":13,"watchers":14,"openIssues":15,"contributorsCount":15,"subscribersCount":15,"size":15,"stars1d":15,"stars7d":15,"stars30d":16,"stars90d":15,"forks30d":15,"starsTrendScore":15,"compositeScore":17,"rankGlobal":10,"rankLanguage":10,"license":10,"archived":18,"fork":18,"defaultBranch":19,"hasWiki":20,"hasPages":18,"topics":21,"createdAt":10,"pushedAt":10,"updatedAt":28,"readmeContent":29,"aiSummary":30,"trendingCount":15,"starSnapshotCount":15,"syncStatus":31,"lastSyncTime":32,"discoverSource":33},77566,"polymarket-ai-btc-arbitrage-trading-bot","Predictly-MCP-Labs\u002Fpolymarket-ai-btc-arbitrage-trading-bot","Predictly-MCP-Labs","polymarket openclaw ai trading bot polymarket ai trading bot polymarket ai trading bot polymarket ai trading bot polymarket ai trading bot polymarket ai trading bot polymarket ai trading bot polymarket ai trading bot polymarket ai trading bot polymarket ai trading bot polymarket ai trading bot polymarket ai trading bot polymarket ai trading bot","",null,"TypeScript",200,923,39,0,162,8.9,false,"main",true,[22,23,24,25,26,27],"openclaw-ai-trading-bot","polymarket-btc-5min-15min-arbitrage-bot","polymarket-btc-5min-arbitrage-bot","polymarket-btc-arbitrage-bot","polymarket-last-minute-bot","polymarket-openclaw-bot","2026-06-12 02:03:43","## OpenClaw Polymarket AI Trading Bot(BTC 5m \u002F 15m) — CLOB Arbitrage\n\nOpenClaw‑enhanced Polymarket AI trading and arbitrage bot designed for BTC 5m\u002F15m Up\u002FDown markets on the Polymarket CLOB.  \nA TypeScript\u002FNode.js system that automates short‑horizon prediction‑market trading using deterministic rule‑based logic, with an optional HTTP\u002FLLM OpenClaw decision engine for signal experimentation.\nIncludes strict risk‑management gates (cooldowns, retries, safety locks), continuous market polling, structured decision flow, and clear operator‑focused logging for reliable live or paper‑mode operation.\n\n[![Node.js](https:\u002F\u002Fimg.shields.io\u002Fbadge\u002Fnode-%3E%3D20.6-brightgreen)](https:\u002F\u002Fnodejs.org\u002F)\n[![TypeScript](https:\u002F\u002Fimg.shields.io\u002Fbadge\u002FTypeScript-5.x-blue)](https:\u002F\u002Fwww.typescriptlang.org\u002F)\n[![License](https:\u002F\u002Fimg.shields.io\u002Fbadge\u002Flicense-ISC-lightgrey)](#license)\n\n---\n\n## Table of contents\n\n- [What this bot does](#what-this-bot-does)\n- [Who this is for](#who-this-is-for)\n- [How it differs from “classic” two-window arbitrage](#how-it-differs-from-classic-two-window-arbitrage)\n- [Architecture](#architecture)\n- [Key modules](#key-modules)\n- [Quick start](#quick-start)\n- [Environment variables](#environment-variables)\n- [trade.toml reference](#tradetoml-reference)\n- [Operations and risk management](#operations-and-risk-management)\n- [Troubleshooting](#troubleshooting)\n- [Safety and compliance](#safety-and-compliance)\n- [FAQ](#faq)\n- [Keywords](#keywords-for-search--github-discovery)\n\n---\n\n## What this bot does\n\n- **Market selection** — Builds Polymarket slugs from `[market].market_coin` and `[market].market_period` (e.g. **BTC + 5m** or **BTC + 15m** short markets).\n- **Pricing** — Polls **Gamma \u002F CLOB**-backed pricing for **UP** and **DOWN** outcome tokens.\n- **Strategies** — Runs **`trade_1`** or **`trade_2`** rules from `trade.toml` (time\u002Fprice exits, range entries, optional emergency swap after a sell).\n- **OpenClaw-style decision layer (optional)** — When enabled, runs a deterministic, explainable decision module alongside the existing rules (pluggable scaffolding; not a promise of profit).\n- **Execution** — Submits **market-style orders** via the v2 CLOB client with **instant retries only for transient errors**, **entry cooldown** after failed buys, and **friendly error summaries** (no raw stack spam).\n- **Auth** — **L1** wallet signing to **derive or create** API credentials, then **L2** authenticated client for balance and orders.\n- **Operator UX** — Startup **banner**, structured logging (**`emojiprint-logger`**), and **trend \u002F position** legends in the console.\n\nIf you are looking specifically for a **synchronized dual-window (5m + 15m) paired-leg arbitrage engine**, that is **not** what this codebase implements today; see [How it differs](#how-it-differs-from-classic-two-window-arbitrage).\nThis repo is still in the same “**Polymarket arbitrage bot \u002F Polymarket trading bot**” category people search for: **Polymarket BTC 5 minute**, **Polymarket BTC 15 minute**, and **Polymarket CLOB trading bot TypeScript**.\n\n---\n\n## Who this is for\n\n- Developers building or extending a **Polymarket CLOB trading bot** in **TypeScript**.\n- Traders experimenting with **short-duration Up\u002FDown markets** (e.g. **5m \u002F 15m**) on Polymarket with **small size** and **strict risk controls**.\n- Anyone evaluating **arbitrage-adjacent** or **rule-based** automation on **Polymarket prediction markets** (not only directional “picks”).\n\n---\n\n## How it differs from “classic” two-window arbitrage\n\nMany guides describe **cross-window** ideas (e.g. comparing **5-minute** and **15-minute** BTC markets at once, synchronized `endTime`, paired legs). **This repo** instead:\n\n- Trades **one window per running config** (`market_period` = `5`, `15`, `60`, etc.).\n- Uses **transparent `trade.toml`** thresholds (ratios, ranges) rather than a hard-coded dual-leg arbitrage engine.\n\nYou can **run two processes** with two configs (e.g. one `market_period = \"5\"`, one `\"15\"`) as a **future operational pattern**; that is not bundled as a single orchestrated binary here.\n\n---\n\n## Architecture\n\n```\n┌─────────────────────────────────────────────────────────────────┐\n│                    index.ts (bootstrap + banner)                 │\n│  CLOB L1 → derive\u002Fcreate API key → CLOB L2 client               │\n└────────────────────────────┬────────────────────────────────────┘\n                             │\n                             ▼\n┌─────────────────────────────────────────────────────────────────┐\n│  Market loop (per window slug)                                   │\n│  • Gamma: resolve market + token IDs                             │\n│  • Prices: poll quotes for UP \u002F DOWN                             │\n│  • Trade.updatePrices → make_trading_decision                    │\n└────────────────────────────┬────────────────────────────────────┘\n                             │\n                             ▼\n┌─────────────────────────────────────────────────────────────────┐\n│  Strategy (trade_1 | trade_2)              trade\u002Fdecision.ts    │\n│  • Entry gates, exits, optional emergency swap                   │\n└────────────────────────────┬────────────────────────────────────┘\n                             │\n                             ▼\n┌─────────────────────────────────────────────────────────────────┐\n│  Orders + balances                     trade\u002Ftrade.ts             │\n│  • createAndPostMarketOrder (FAK)                                │\n│  • Retry policy (utils\u002Fretry.ts) + trading errors (human text)   │\n└─────────────────────────────────────────────────────────────────┘\n```\n\n---\n\n## Key modules\n\n| Area | Path | Role |\n|------|------|------|\n| Entry | `src\u002Findex.ts` | Banner, CLOB auth, market loop, `Trade` lifecycle |\n| CLOB \u002F wallet | `src\u002Fservices\u002Fclob.ts` | Host, chain, signer, funder, signature type |\n| Gamma API | `src\u002Fservices\u002Fgamma.ts` | Market metadata by slug |\n| Config | `src\u002Fconfig\u002Ftoml.ts`, `src\u002Fconfig\u002Fenv.ts`, `src\u002Fconfig\u002FvalidateEnv.ts` | Zod-validated `trade.toml`, `.env` (with early startup validation) |\n| Slug | `src\u002Fconfig\u002Fslug.ts` | Coin + period → Polymarket slug |\n| Decision | `src\u002Ftrade\u002Fdecision.ts` | `trade_1` \u002F `trade_2` branching |\n| Prices | `src\u002Ftrade\u002Fprices.ts` | Quote polling and status lines |\n| Execution | `src\u002Ftrade\u002Ftrade.ts` | Buys\u002Fsells, cooldowns, balance waits |\n| Errors | `src\u002Futils\u002FtradingErrorMessage.ts`, `retry.ts` | Operator-friendly messages |\n| SDK noise | `src\u002Futils\u002FsuppressClobConsole.ts` | Quiet CLOB `console.error` during key setup |\n\n---\n\n## Quick start\n\n### Prerequisites\n\n- **Node.js ≥ 20.6**\n- **Polygon** wallet with Polymarket-compatible setup (**private key** + **funder \u002F proxy deposit address** as required by your account type)\n- Small **USDC** balance appropriate for **`trade_usd`** experiments\n\n### 1. Clone and install\n\n```bash\ngit https:\u002F\u002Fgithub.com\u002Florine93s\u002Fopenclaw-polymarket-ai-arbitrage-trading-bot\ncd openclaw-polymarket-ai-arbitrage-trading-bot\nnpm install\n```\n\n### 2. Environment\n\nCopy `.env.example` to `.env` and fill in secrets (**never commit `.env`**).\nThe bot validates required env values on startup and will show a clear warning if your **private key** or **funder address** is missing\u002Finvalid.\n\n### 3. Strategy and market\n\nEdit **`trade.toml`**:\n\n- Set **`[market].market_period`** to **`\"5\"`** or **`\"15\"`** for **Polymarket 5 minute** or **15 minute** BTC (or other coin) windows.\n- Choose **`strategy`** = `trade_1` or `trade_2`.\n- Set **`trade_usd`**, **`max_retries`**, **`entry_buy_cooldown_sec`**.\n\n### 4. Run\n\n```bash\n# Development\nnpm run dev\n\n# Production-style\nnpm run build\nnpm start\n```\n\n---\n\n## Environment variables\n\n| Variable | Required | Description |\n|----------|----------|-------------|\n| `POLYMARKET_PRIVATE_KEY` | Yes | Wallet private key used to sign CLOB L1 \u002F L2 operations |\n| `POLYMARKET_FUNDER_ADDRESS` | Yes | Funder \u002F deposit (proxy) address that holds trading collateral |\n| `PROXY_WALLET_ADDRESS` | Alternate | **Alias**: accepted by the loader if `POLYMARKET_FUNDER_ADDRESS` is unset |\n| `POLYMARKET_SIGNATURE_TYPE` | No | `EOA` · `POLY_PROXY` · `POLY_GNOSIS_SAFE` · `POLY_1271`. Defaults to proxy-friendly behavior when omitted |\n\nSee **`.env.example`** for commented templates.\n\n**Related queries:** *Polymarket API credentials*, *Polymarket CLOB wallet setup*, *Polymarket trading bot environment variables*, *Polymarket private key invalid byteslike*.\n\n---\n\n## trade.toml reference\n\n| Key | Meaning |\n|-----|--------|\n| `strategy` | `trade_1` or `trade_2` |\n| `trade_usd` | Notional per buy (USD) |\n| `max_retries` | Transient-error retries (network \u002F 5xx \u002F 429) |\n| `entry_buy_cooldown_sec` | Pause before retrying **entry** after a failed buy |\n| `[openclaw]` | Optional OpenClaw-style decision engine settings (enabled\u002Fthresholds\u002Flookback) |\n| `[market].market_coin` | `btc`, `eth`, `sol`, `xrp` |\n| `[market].market_period` | `5`, `15`, `60`, `240`, `1440` |\n| `[trade_1]`, `[trade_2]` | Strategy parameters (see Zod schema in `src\u002Fconfig\u002Ftoml.ts`) |\n\nTo emphasize **Polymarket BTC 5 minute** vs **Polymarket BTC 15 minute**, change only **`market_period`** (and optionally `market_coin`).\n\n---\n\n## OpenClaw-style AI decision layer\n\nThis repo includes an **optional OpenClaw-style decision module** designed to be **pluggable**, **testable**, and **operator-explainable**.\nIt is **not** a generic ML framework and it does **not** promise “risk-free arbitrage”.\n\n- **Default behavior preserved**: If `[openclaw].enabled = false`, the bot behaves exactly as before using `trade_1` \u002F `trade_2`.\n- **What it consumes**: current UP\u002FDOWN quotes, a small in-memory lookback window of recent quotes, time-to-expiry, position state, and thresholds from `trade.toml`.\n- **What it produces**: high-level actions like `BUY_UP`, `BUY_DOWN`, `CLOSE_POSITION`, `HOLD` with a reason string (logged in the console).\n- **Safety gates**: the signal is still subject to existing bot risk controls (cooldowns, `hasBought`, retries, etc.). If an action isn’t allowed, the bot simply won’t place the order.\n\nConfig block in `trade.toml`:\n\n```toml\n[openclaw]\nenabled = true\nmode = \"deterministic\" # or \"http\"\nmin_edge_bps = 50\nmax_spread_bps = 200\nlookback_points = 12\n\n# Optional: OpenClaw HTTP\u002FLLM integration (mode=\"http\")\n# [openclaw.http]\n# url = \"https:\u002F\u002Fyour-openclaw-service.example.com\u002Fdecide\"\n# bearer_token = \"optional\"\n# timeout_ms = 2500\n```\n\n---\n\n## Operations and risk management\n\n- Start with **low `trade_usd`** and verify **fills**, **balances**, and **logs**.\n- **Execution risk** remains: partial fills, API errors, and fast-moving **5m \u002F 15m** books can move against you between signal and fill.\n- **`entry_buy_cooldown_sec`** reduces tight loops when a failure is **not** transient (e.g. credential \u002F signing issues).\n- Prefer a **dedicated wallet** and balance you can afford to lose.\n\n---\n\n## Troubleshooting\n\n| Symptom | What to check |\n|---------|----------------|\n| `Could not derive api key` (suppressed raw log) | Normal on first run; bot should **create** a key next. If both fail: wallet \u002F signature type \u002F Polymarket account. |\n| L2 \u002F HMAC \u002F `ERR_INVALID_ARG_TYPE` | Incomplete **API credentials** on the client (e.g. missing secret). Re-run auth; verify client is constructed with full `creds` after L1. |\n| No trades | `trade_2` **entry** gates (time ratio + price range); **`hasBought`**; **`entryBuyCooldownUntil`** after failures. |\n| Auth \u002F 401 | Funder vs signer mismatch, wrong **`POLYMARKET_SIGNATURE_TYPE`**, or blocked API access. |\n\n---\n\n## Safety and compliance\n\n- This software **places real orders** when configured with live keys and a funded account.\n- **No warranty**. Past or hypothetical **arbitrage** edges do not guarantee future results.\n- Comply with **local laws**, **Polymarket Terms of Service**, and eligibility rules in your jurisdiction.\n- **Never** commit private keys or paste them into support chats.\n\n---\n\n## FAQ\n\n**Is this a “risk-free Polymarket arbitrage bot”?**  \nNo automated strategy is risk-free. This project automates **rules and execution**; **slippage**, **failed legs**, and **operational bugs** can lose money.\n\n**Is this specifically a Polymarket BTC 5 minute market bot?**  \nYou configure **`market_period = \"5\"`** (and `market_coin = \"btc\"`) for that use case. The same code path supports **15m** and other periods.\n\n**Does it run Polymarket WebSocket feeds?**  \nThe core loop described here uses **polling** for prices; dependencies may include WS-oriented packages for future extension — check `src\u002F` for actual usage.\n\n**Can I use it for ETH \u002F SOL Polymarket markets?**  \nYes — set **`market_coin`** in `trade.toml`.\n\n---\n\n## Keywords\n\nCommon search terms this repo targets:\n\n`polymarket trading bot`, `polymarket arbitrage bot`, `polymarket btc trading bot`, `polymarket btc arbitrage bot`, `polymarket clob bot`, `polymarket clob trading bot`, `polymarket orderbook bot`, `@polymarket\u002Fclob-client-v2`, `polymarket api key`, `polymarket market making bot`, `polymarket up down bot`, `polymarket 5 minute bot`, `polymarket 5m btc`, `polymarket 15 minute bot`, `polymarket 15m btc`, `polymarket typescript bot`, `polymarket nodejs bot`, `prediction market trading bot`, `crypto prediction market bot`, `openclaw prediction market bot`, `openclaw polymarket trading bot`, `openclaw ai prediction market bot`, `openclaw prediction market bot`, \n\n---\n\n## License\n\nISC — see [`package.json`](package.json). Use at your own risk.\n","该项目是一个基于OpenClaw AI的Polymarket交易平台上的BTC 5分钟和15分钟市场自动交易与套利机器人。其核心功能包括构建特定市场的交易对、实时获取价格信息、执行预设交易策略，并可选地集成HTTP\u002FLLM OpenClaw决策引擎以增强信号处理能力。技术上，该系统使用TypeScript\u002FNode.js开发，具备严格的风险管理机制如冷却时间、重试逻辑和安全锁等，确保操作的安全性和稳定性。适用于希望在Polymarket平台上进行短期预测市场交易的用户，无论是实盘还是模拟模式下都能提供可靠的自动化交易体验。",2,"2026-05-29 04:05:26","CREATED_QUERY"]