[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"project-79460":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":29,"readmeContent":30,"aiSummary":31,"trendingCount":15,"starSnapshotCount":15,"syncStatus":32,"lastSyncTime":33,"discoverSource":34},79460,"polymarket-btc-5min-15min-up-down-arbitrage-bot","PredictiveFlow-Labs\u002Fpolymarket-btc-5min-15min-up-down-arbitrage-bot","PredictiveFlow-Labs","polymarket arbitrage bot polymarket arbitrage bot polymarket arbitrage bot polymarket arbitrage bot polymarket arbitrage bot polymarket arbitrage bot polymarket arbitrage bot polymarket arbitrage bot polymarket arbitrage bot polymarket arbitrage bot polymarket arbitrage bot polymarket arbitrage bot polymarket arbitrage bot polymarket arbitrage bot ","",null,"TypeScript",62,3487,1,0,104,10,false,"main",true,[22,23,24,25,26,27,28],"polymarket-arbitrae-trading-bot","polymarket-arbitrage-bot","polymarket-bot","polymarket-btc-5min-arbitrage-bot","polymarket-btc-arbitrage-bot","polymarket-btc-arbitrage-trading-bot","polymarket-trading-bot","2026-06-12 02:03:54","# Polymarket Trading Bot (BTC 5m \u002F 15m) — CLOB Arbitrage \u002F Automation (TypeScript)\n\n**Polymarket trading bot** for short-horizon crypto prediction markets (BTC, ETH, SOL, XRP) — built with **Node.js 20+** and **TypeScript**.\nIf you are searching for **“Polymarket trading bot”**, **“Polymarket arbitrage bot”**, **“Polymarket BTC 5 minute bot”**, or **“Polymarket CLOB bot”**, this repo is a practical starting point.\n\nThis bot trades **Polymarket Up\u002FDown markets** on the **Polymarket CLOB (order book)** using the official **`@polymarket\u002Fclob-client-v2`** SDK.\nIt runs **one market window at a time** (configured by coin + period, e.g. **BTC 5m** or **BTC 15m**), polls prices, applies **rule-based entry\u002Fexit strategies**, and places orders with **retries, cooldowns, and operator-friendly logging**.\nThis is **automation scaffolding** for experimentation and operations — **not** a promise of “risk-free arbitrage” profits.\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- **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 clone https:\u002F\u002Fgithub.com\u002Florine93s\u002Fpolymarket-btc-5min-15min-arbitrage-bot.git\ncd polymarket-btc-5min-15min-arbitrage-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| `[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## 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`\n\n---\n\n## License\n\nISC — see [`package.json`](package.json). Use at your own risk.\n","这是一个用于Polymarket平台上短期加密货币预测市场的交易机器人，支持BTC、ETH、SOL和XRP等币种。项目采用Node.js 20+和TypeScript构建，利用官方的`@polymarket\u002Fclob-client-v2` SDK进行开发。其核心功能包括基于规则的入场\u002F出场策略、自动下单（带有重试、冷却时间和用户友好的日志记录）以及对单一市场窗口（如BTC 5分钟或15分钟）的支持。该机器人适合那些希望自动化处理Polymarket上Up\u002FDown市场订单簿操作的开发者或交易者使用，并作为实验与运营的基础框架，但不保证无风险套利收益。",2,"2026-06-01 03:48:39","CREATED_QUERY"]