[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"project-79731":3},{"id":4,"name":5,"fullName":6,"owner":7,"repo":5,"description":8,"homepage":9,"htmlUrl":10,"language":10,"languages":10,"totalLinesOfCode":10,"stars":11,"forks":12,"watchers":13,"openIssues":14,"contributorsCount":14,"subscribersCount":14,"size":14,"stars1d":14,"stars7d":14,"stars30d":15,"stars90d":14,"forks30d":14,"starsTrendScore":14,"compositeScore":16,"rankGlobal":10,"rankLanguage":10,"license":10,"archived":17,"fork":17,"defaultBranch":18,"hasWiki":19,"hasPages":17,"topics":20,"createdAt":10,"pushedAt":10,"updatedAt":28,"readmeContent":29,"aiSummary":30,"trendingCount":14,"starSnapshotCount":14,"syncStatus":31,"lastSyncTime":32,"discoverSource":33},79731,"polymarket-btc-5min-15min-arbitrage-trading-bot","PolyMomentum\u002Fpolymarket-btc-5min-15min-arbitrage-trading-bot","PolyMomentum","polymarket trading bot polymarket trading bot polymarket trading bot polymarket trading bot polymarket trading bot polymarket trading bot polymarket trading bot polymarket trading bot polymarket trading bot polymarket trading bot polymarket trading bot polymarket trading bot polymarket trading bot polymarket trading bot polymarket trading bot ","",null,244,6367,25,0,76,10,false,"main",true,[21,22,23,24,25,26,27],"polymarket-5min-bot","polymarket-arbitrage-trading-bot","polymarket-btc-5min-15min-arbitrage-bot","polymarket-btc-5min-arbitrage-bot","polymarket-btc-arbitrage-bot","polymarket-trading-bot","polymarket-trading-bot-strategies","2026-06-12 02:03:54","# Polymarket BTC Up\u002FDown 5m\u002F15m Arbitrage Bot\n\nTrader-oriented TypeScript bot for **Polymarket BTC Up\u002FDown** short-duration markets on the **CLOB** (commonly **5-minute** and **15-minute** windows).\n\n**What you get:** configurable, rule-driven entries\u002Fexits from `trade.toml`, live UP\u002FDOWN quote polling, market-style order execution with retries + cooldowns, and wallet-based authentication via `@polymarket\u002Fclob-client-v2`.\n\n**Important:** this repository automates *execution + rule logic*. It does **not** guarantee “risk-free arbitrage” profits, and it does **not** implement a single, synchronized two-leg 5m↔15m arb engine in one process (details below).\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- [At a glance](#at-a-glance)\n- [How Polymarket BTC Up\u002FDown markets work (quick mental model)](#how-polymarket-btc-updown-markets-work-quick-mental-model)\n- [What this bot does](#what-this-bot-does)\n- [What “5m\u002F15m arbitrage” means in this repo](#what-5m15m-arbitrage-means-in-this-repo)\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- [Running 5m and 15m together](#running-5m-and-15m-together)\n- [Operations runbook (risk controls)](#operations-runbook-risk-controls)\n- [Troubleshooting](#troubleshooting)\n- [Safety and compliance](#safety-and-compliance)\n- [FAQ](#faq)\n- [Keywords](#keywords-for-search--github-discovery)\n\n---\n\n## At a glance\n\n- **Markets**: Polymarket **BTC Up\u002FDown** CLOB markets for a chosen window (ex: **5m** or **15m**).\n- **Strategy**: rules from `trade.toml` (`trade_1` \u002F `trade_2`) based on **UP\u002FDOWN prices** and simple timing\u002Fratio gates.\n- **Execution**: market-style orders (FAK), transient retry policy, entry cooldown after failed buys, operator-friendly logs.\n- **Ops model**: **one market window per process** (run two processes if you want 5m + 15m simultaneously).\n\n---\n\n## How Polymarket BTC Up\u002FDown markets work (quick mental model)\n\nPolymarket Up\u002FDown markets are typically represented as **two outcome tokens** on the CLOB:\n\n- **UP**: pays out if the condition “BTC is up” is satisfied for the specified time window.\n- **DOWN**: pays out if the “down” condition is satisfied for the same window.\n\nOn the CLOB you are trading **tokenized outcomes**, so:\n\n- You can **buy UP** or **buy DOWN** like any orderbook asset.\n- Prices are quotes for these outcome tokens and can move quickly, especially on **short windows** (5m\u002F15m).\n- “Arbitrage” ideas people discuss often involve **relative pricing** between UP and DOWN and\u002For between **different time windows**. This repo supports *rule-based trading on one window at a time* and can be operated in multi-process mode for 5m + 15m.\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\n---\n\n## What “5m\u002F15m arbitrage” means in this repo\n\nMany “classic” writeups describe **cross-window** or **paired-leg** arbitrage, for example:\n\n- trading **5m vs 15m** in a synchronized way,\n- constructing both legs at once,\n- tightly coupling entry\u002Fexit to a shared end time.\n\n**This codebase instead:**\n\n- Trades **one configured window per process** (`market_period` = `5`, `15`, `60`, …).\n- Uses a **transparent rule file** (`trade.toml`) to decide entries\u002Fexits for that one window.\n- Lets you operate **two instances** (one for 5m, one for 15m) if that’s your workflow, without packaging them as a single orchestrator.\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\u002FPolyMomentum\u002Fpolymarket-btc-5min-15min-arbitrage-trading-bot.git\ncd polymarket-btc-5min-15min-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---\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## Running 5m and 15m together\n\nThis repo is intentionally simple operationally: **one window per process**.\n\n- **Option A (recommended for clarity):** duplicate `trade.toml` into two files (ex: `trade.5m.toml`, `trade.15m.toml`) and run two terminals with different configs (if your code supports selecting the path), or swap the config between runs.\n- **Option B:** run two copies of the repo (two folders), each with its own `trade.toml`.\n\nIf you run two processes:\n\n- Treat them as **independent strategies** unless you explicitly build shared inventory\u002Frisk logic.\n- Ensure you’re not unintentionally **doubling exposure** (two bots buying UP at once on different windows can still correlate strongly).\n\n---\n\n## Operations runbook (risk controls)\n\n- Start with **low `trade_usd`** and verify **fills**, **balances**, and **logs**.\n- **Execution risk** remains: partial fills, fast-moving books, and price movement between signal and fill (especially on **5m \u002F 15m**).\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 only fund what you can afford to lose.\n- Run with a clear **kill-switch** procedure (stop the process, verify open orders, re-check balances).\n- Assume external dependencies can degrade: **429s**, **5xx**, RPC hiccups, and delayed state.\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 btc arbitrage bot`, `polymarket btc 5min arbitrage bot`, `polymarket btc 15min arbitrage 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","该项目是一个面向交易者的TypeScript机器人，专为Polymarket平台上BTC涨跌5分钟和15分钟市场设计。核心功能包括通过`trade.toml`文件配置的规则驱动入场与离场策略、实时UP\u002FDOWN报价轮询、基于市场的订单执行机制（含重试和冷却期），以及通过`@polymarket\u002Fclob-client-v2`进行的钱包认证。技术上采用Node.js (>=20.6) 和 TypeScript 5.x构建。适用于希望在Polymarket BTC短期市场中自动化执行交易策略的用户，但需注意它不保证无风险套利收益，也不实现单一进程内的同步双窗口套利引擎。",2,"2026-05-29 04:08:39","CREATED_QUERY"]