[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"project-78418":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":25,"readmeContent":26,"aiSummary":27,"trendingCount":15,"starSnapshotCount":15,"syncStatus":28,"lastSyncTime":29,"discoverSource":30},78418,"crypto-trading-bot","Polymarket-Trading-kit\u002Fcrypto-trading-bot","Polymarket-Trading-kit","crypto trading bot crypto trading bot crypto trading bot crypto trading bot crypto trading bot crypto trading bot crypto trading bot crypto trading bot crypto trading bot crypto trading bot crypto trading bot crypto trading bot crypto trading bot crypto trading bot crypto trading bot crypto trading bot crypto trading bot crypto trading bot crypto","https:\u002F\u002Fpolymarket.com\u002Fsports",null,"TypeScript",198,1303,29,0,63,9.35,false,"main",true,[22,23,24],"polymarket-copy-trading-bot","polymarket-copytrading-bot","polymarket-sports-trading","2026-06-12 02:03:47","# Polymarket Arbitrage Trading Bot (TypeScript) \n\nA Polymarket Trading bot that trades on [Polymarket](https:\u002F\u002Fpolymarket.com) **binary crypto markets** (e.g. “Bitcoin up or down in the next 15 minutes”). It connects to Polymarket’s CLOB and real-time data, subscribes to a market by coin and period, and can run configurable strategies.\n\n\n## What kind of bot is this?\n\n**Not classic arbitrage.** The codebase supports two styles of logic:\n\n1. **Trend-following (`trade_1` in `decision.ts`)**  \n   Detects short-term “trend” from order-book price changes and would buy the **UP** or **DOWN** token when the market is trending that way, within a configurable price range. This is **directional trading**, not arbitrage.\n\n2. **Binary “arbitrage” (`trade_1` in `ws_clob.ts`)**  \n   When real-time price velocity exceeds a threshold, it computes prices such that UP + DOWN &lt; 1 − `min_arb_price_difference`, and would buy **both** UP and DOWN to lock in a margin. That’s **binary market arbitrage** (buying both sides when they’re cheap relative to $1).  \n\n**Current state:** Order placement for both strategies is **commented out**. The bot runs as a **framework**: it connects, subscribes to markets and RTDS, updates prices, and logs signals; it does not send live orders unless you uncomment and enable the trade calls.\n\n## Features\n\n- **Market selection**: Coin (`btc`, `eth`, `sol`, `xrp`) and period (15, 60, 240, 1440 minutes).\n- **Live data**: CLOB WebSocket (order book) and RTDS (e.g. BTCUSDT \u002F Chainlink) for price velocity.\n- **Strategies**: `trade_1` (time\u002Fprice exit), `trade_2` (entry\u002Fexit ranges + optional emergency swap).\n- **Config**: TOML config (`trade.toml`) for strategy, market, trading range, thresholds, simulation.\n- **Simulation**: Optional `simulation = true` to skip sending orders.\n\n## Change the market(`trade.toml`)\n\n   You can change crypto market \n   ** [market]\n      market_coin = \"btc\"  # btc \u002F eth \u002F sol \u002F xrp\n      market_period = \"5\" # 5 \u002F 15 \u002F 60 \u002F 240 \u002F 1440 **\n\n## Strategy logic (`decision.ts`)\n\n### trade_1 — Time \u002F price exit\n\n- **Goal**: Hold a position (UP or DOWN) and exit when either time or price threshold is reached.\n- **Exit**: If **remaining time ratio** (elapsed time \u002F market duration) &gt; `trade_1.exit_time_ratio` **or** **up-price ratio** (distance of UP bid from 0.5) &gt; `trade_1.exit_price_ratio`, the bot sells the currently held token:\n  - Holding **UP** → `sellUpToken()`\n  - Holding **DOWN** → `sellDownToken()`\n- **Config** (`[trade_1]` in `trade.toml`): `exit_time_ratio`, `exit_price_ratio`, plus `entry_price_range`, `swap_price_range`, `take_profit`, `stop_loss` for future entry\u002Frisk logic.\n\n### trade_2 — Entry\u002Fexit ranges + emergency swap\n\n- **Goal**: Enter when price and time are in range; exit when price is in an exit band; optionally flip to the opposite side in an “emergency” price band.\n- **Entry** (when not holding): If `remaining_time_ratio` &gt; `trade_2.entry_time_ratio` and **up-price ratio** is inside `trade_2.entry_price_ratio` `[min, max]`, buy the cheaper side (UP if `upBuyPrice` &gt; `downBuyPrice`, else DOWN).\n- **Exit**: If up-price ratio falls inside any of the `trade_2.exit_price_ratio_range` intervals:\n  - Holding **UP** → `sellUpToken()`; if sell succeeds and up-price ratio is in `trade_2.emergency_swap_price`, then `buyDownToken()`.\n  - Holding **DOWN** → `sellDownToken()`; if sell succeeds and up-price ratio is in `trade_2.emergency_swap_price`, then `buyUpToken()`.\n- **Config** (`[trade_2]`): `entry_price_ratio`, `entry_time_ratio`, `exit_price_ratio_range`, `emergency_swap_price` (optional).\n\n### trade_3 — Arbitrage Strategy ( Private )\n\n[![Watch the video](https:\u002F\u002Fimg.youtube.com\u002Fvi\u002FkOf64hqhbjE\u002Fmaxresdefault.jpg)](https:\u002F\u002Fwww.youtube.com\u002Fwatch?v=kOf64hqhbjE)\n\n\n\n## Requirements\n\n- **Node.js** ≥ 20.6.0\n- **Wallet**: Polymarket proxy wallet and signer (private key) for the CLOB.\n\n## Setup\n\n1. **Clone and install**\n\n   Ubuntu\n   ```bash\n   git clone https:\u002F\u002Fgithub.com\u002FPolymarket-Trading-kit\u002Fcrypto-trading-bot\n   cd crypto-trading-bot\n   \n   npm install\n   ```\n\n2. **Environment**\n\n   Create a `.env` in the project root (see `.gitignore`; do not commit secrets):\n\n   - `POLYMARKET_PRIVATE_KEY` – EOA private key that signs for the proxy wallet.\n   - `PROXY_WALLET_ADDRESS` – Proxy wallet address used with Polymarket CLOB.\n\n3. **Config**\n\n   Edit `trade.toml`:\n\n   - `strategy`: `\"trade_1\"` or `\"trade_2\"`.\n   - `trade_usd`, `max_retries`, `simulation`.\n   - `[market]`: `market_coin`, `market_period`.\n   - `[trade_1]`: `trading_range`, `price_change_threshold`, `min_arb_price_difference`, etc.\n\n## Scripts\n\n| Command   | Description                          |\n|----------|--------------------------------------|\n| `npm run dev`   | Run bot: `tsx src\u002Findex.ts`          |\n| `npm run log`   | Run and log stdout\u002Fstderr to `log.txt` |\n| `npm run check` | Run inspector: `tsx src\u002Finspect.ts`  |\n| `npm run build` | Compile: `tsc`                       |\n| `npm start`     | Run compiled: `node dist\u002Findex.js`   |\n\n## Project layout\n\n- `src\u002Findex.ts` – Entry: load config, create CLOB client, resolve market slug, connect WebSockets, instantiate `Trade`, main loop.\n- `src\u002Fconfig\u002F` – Env, TOML config, market\u002Fslug helpers.\n- `src\u002Fservices\u002F` – CLOB client, Gamma API, WebSockets (CLOB + RTDS).\n- `src\u002Ftrade\u002F` – `Trade` class: decision logic, prices\u002Ftrending, order placement (buy\u002Fsell UP\u002FDOWN).\n- `trade.toml` – Strategy and market configuration.\n\n## Contact\n\n[t.me\u002F@mshrieve](https:\u002F\u002Ft.me\u002F@mshrieve)\n","Polymarket Arbitrage Trading Bot 是一个基于 TypeScript 的加密货币交易机器人，专为 Polymarket 平台上的二元市场（如“比特币在接下来15分钟内涨跌”）设计。该项目支持两种交易逻辑：趋势跟随和二元套利。前者通过订单簿价格变化检测短期趋势，并据此买入UP或DOWN代币；后者则是在市场价格变动超过一定阈值时同时买入UP和DOWN代币以锁定利润差。该工具提供了丰富的配置选项，包括市场选择、实时数据接入以及多种策略设置，但默认情况下不执行实际交易，需要手动启用相关功能。适用于希望利用算法自动执行交易策略的加密货币投资者。",2,"2026-05-24 02:30:14","CREATED_QUERY"]