[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"project-80599":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":14,"lastSyncTime":32,"discoverSource":33},80599,"polymarket-auto-trading","ShadowSpread\u002Fpolymarket-auto-trading","ShadowSpread","polymarket trading bot, polymarket auto trading bot, polymarket profitable bot, polymarket, trading bot, polymarket trading bot, polymarket arbitrage bot, polymarket arbitrage bot, polymarket trading bot, polymarket auto trading bot, polymarket profitable bot, polymarket trading bot, polymarket auto trading bot, polymarket profitable bot, ","https:\u002F\u002Fpolymarket.com",null,"TypeScript",93,4635,2,0,91,10,false,"main",true,[22,23,24,25,26,27,28],"auto-trading-bot","polymarket","polymarket-bot","polymarket-trading","polymarket-trading-bot","prediction-market","trading-bot","2026-06-12 02:04:04","﻿# Polymarket Copy Trading Bot (TypeScript)\n\n[![GitHub](https:\u002F\u002Fimg.shields.io\u002Fbadge\u002FGitHub-Orionovant--labs%2Fpm--bot-181717?logo=github)](https:\u002F\u002Fgithub.com\u002FOrionovant-labs\u002Fpm-bot)\n\nA TypeScript bot for monitoring a target Polymarket account and optionally mirroring its trades.\n\n## Overview\nThis project connects to Polymarket APIs and does two things:\n\n- **Account monitoring:** Polls active positions for a target account and prints a concise status view.\n- **Copy trading (optional):** When the target account opens a position, the bot places a corresponding **BUY** order. When the target position disappears, it places a **SELL** order to close.\n\nOrder execution uses Polymarket's CLOB via `@polymarket\u002Fclob-client`.\n\n## Verified Target & Performance Evidence\n\nThis bot has been used to monitor and mirror activity from the following profiles:\n- **My profile:**\n- **Target wallet profile:** \n### Trading history snapshots\n#### 1D view\n![Copy trading history - 1D](docs\u002F1d.jpg)\n\n#### 1W view\n![Copy trading history - 1W](docs\u002F1w.jpg)\n\n#### 1M view\n![Copy trading history - 1M](docs\u002F1m.jpg)\n\n#### All-time view\n![Copy trading history - All-time](docs\u002Fall.jpg)\n\n### Features\n- Polling-based monitoring of a single `TARGET_ADDRESS`\n- Optional copy-trading controlled by `COPY_TRADING_ENABLED`\n- Dry-run mode (`DRY_RUN=true`) to simulate order decisions without posting orders\n- Guardrails for position\u002Ftrade sizing (min\u002Fmax USD thresholds)\n\n## Prerequisites\n- Node.js 18+\n- A Polygon wallet private key (only required for copy trading)\n\n## Setup\n1. Clone this repository:\n\n   ```bash\n   git clone https:\u002F\u002Fgithub.com\u002FShadowSpread\u002Fpolymarket-auto-trading.git\n   cd polymarket-auto-trading\n   ```\n\n2. Install dependencies:\n\n   ```bash\n   npm install\n   ```\n\n3. Create a `.env` file:\n\n   You can base it on `.env.example` if it exists, or use the example below.\n\n4. Start in development mode:\n\n   ```bash\n   npm run dev\n   ```\n\n## Environment Variables\n\n### Required\n- `TARGET_ADDRESS` (string): Address to monitor and (optionally) copy-trade\n\n### Copy trading (optional)\n- `COPY_TRADING_ENABLED` (`true`\u002F`false`): Set to `true` to enable copy trading\n- `PRIVATE_KEY` (string): Required when `COPY_TRADING_ENABLED=true`\n\n### Tuning\n- `POLL_INTERVAL` (milliseconds, default: `2000`)\n- `DRY_RUN` (`true`\u002F`false`, default: `false`): If enabled, the bot simulates order execution.\n- `POSITION_SIZE_MULTIPLIER` (default: `1.0`)\n- `MAX_POSITION_SIZE` (default: `10000`): USD cap used as a guardrail\n- `MAX_TRADE_SIZE` (default: `5000`): USD cap used as a guardrail\n- `MIN_TRADE_SIZE` (default: `1`): USD minimum to execute a trade\n- `SLIPPAGE_TOLERANCE` (default: `1.0`): Reserved\u002Fwired but not enforced in the current order parameters\n- `DEBUG` (`true`\u002F`false`, optional): Enables additional logging in API client code\n\n### Example `.env`\n\n```env\nTARGET_ADDRESS=0x1234567890123456789012345678901234567890\n\n# Enable copy trading (monitoring works even when false)\nCOPY_TRADING_ENABLED=false\n\n# Required only when COPY_TRADING_ENABLED=true\nPRIVATE_KEY=0xYourPrivateKeyHere\n\n# Execution controls\nDRY_RUN=true\nPOLL_INTERVAL=2000\n\n# Sizing controls (USD-based)\nPOSITION_SIZE_MULTIPLIER=1.0\nMAX_POSITION_SIZE=10000\nMAX_TRADE_SIZE=5000\nMIN_TRADE_SIZE=1\n\n# Wired config (not enforced in current order params)\nSLIPPAGE_TOLERANCE=1.0\n\n# Optional\nDEBUG=false\n```\n\n## Run Modes\n\n### Monitoring only\nSet `COPY_TRADING_ENABLED=false` (default behavior) and run:\n\n```bash\nnpm run dev\n```\n\n### Copy-trading dry run\nSet `COPY_TRADING_ENABLED=true` and `DRY_RUN=true`, then run:\n\n```bash\nnpm run dev\n```\n\nThe bot will show what BUY\u002FSELL orders it *would* post without sending live orders.\n\n### Live copy trading\nAfter validating behavior in dry run, set `DRY_RUN=false` and run:\n\n```bash\nnpm run dev\n```\n\n## Copy-Trading Behavior\n\nWhen `COPY_TRADING_ENABLED=true`, the bot wraps the account monitor and performs the following loop:\n\n1. Poll the target account’s **active positions** at `POLL_INTERVAL`.\n2. Compare the newly fetched open positions against the previous snapshot.\n3. For each **newly observed open position**, submit a **CLOB BUY** order.\n4. For each **position that disappears** from the target snapshot, submit a **CLOB SELL** order to close.\n\n### Order sizing and guardrails\n\nFor BUY\u002FSELL execution, the bot uses the target position’s `quantity` and `price` to compute a USD value and applies your risk controls:\n\n- `tradeQuantity = position.quantity * POSITION_SIZE_MULTIPLIER`\n- `tradeValue = tradeQuantity * position.price`\n- Execute only if:\n  - `tradeValue >= MIN_TRADE_SIZE`\n  - `tradeValue \u003C= MAX_TRADE_SIZE`\n  - `position.value * POSITION_SIZE_MULTIPLIER \u003C= MAX_POSITION_SIZE`\n\n### Important limitations\n\n- State is kept **in memory only**. If you restart the process, it treats currently open positions as \"new\" and may re-submit BUY orders (and will not reliably know which positions it previously opened). Run a dry test first and consider external operational controls.\n- `SLIPPAGE_TOLERANCE` is wired into configuration, but is **not applied to the current posted order parameters** in this version.\n- `enableWebSocket` exists as an option name in the code, but monitoring is currently implemented as **polling**.\n\n## What You’ll See While Running\n\n### Account monitoring output\n\nThe account monitor prints a formatted view with a timestamp and a list of up to 10 open positions, including:\n\n- outcome name\n- share quantity\n- current price\n- market question (truncated for readability)\n\n### Copy-trading logging\n\nWhen new positions are detected, logs show the intended BUY action (or a simulated action in `DRY_RUN`). When positions close on the target, logs show SELL actions as the bot attempts to close corresponding positions on your wallet.\n\n## Project Structure\n\n- `src\u002Findex.ts`: Entry point. Loads `dotenv`, validates `TARGET_ADDRESS`, optionally validates `PRIVATE_KEY`, then starts either the monitor-only mode or copy-trading mode.\n- `src\u002Fapi\u002Fpolymarket-client.ts`: Fetches user positions from Polymarket’s Data API and normalizes market\u002Fposition fields.\n- `src\u002Fmonitor\u002Faccount-monitor.ts`: Poll-based monitor that detects changes in open positions and renders formatted status output.\n- `src\u002Ftrading\u002Fcopy-trading-monitor.ts`: Compares snapshots and coordinates BUY\u002FSELL execution.\n- `src\u002Ftrading\u002Ftrade-executor.ts`: Creates the wallet + CLOB client and posts orders (or simulates in `DRY_RUN`).\n\n## Available NPM Scripts\n\n- `npm run dev`: Run directly from TypeScript (`ts-node src\u002Findex.ts`)\n- `npm run watch`: TypeScript compile in watch mode (`tsc --watch`)\n- `npm run build`: Build to `dist\u002F` (`tsc`)\n- `npm start`: Run the compiled bot (`node dist\u002Findex.js`)\n\n## Build & Production\n- Build TypeScript:\n\n  ```bash\n  npm run build\n  ```\n\n- Start production build:\n\n  ```bash\n  npm start\n  ```\n\n## Safety Notes\n- Do **not** commit your `.env` file (it is ignored by `.gitignore`).\n- Test with `DRY_RUN=true` before enabling live trading.\n- Double-check your sizing guardrails (`MIN_TRADE_SIZE`, `MAX_TRADE_SIZE`, `MAX_POSITION_SIZE`).\n\n## Troubleshooting\n- **Invalid `PRIVATE_KEY`:** The bot validates that the key is not missing or a placeholder.\n- **API errors \u002F timeouts:** Enable `DEBUG=true` for more logging; verify network access to Polymarket endpoints.\n- **No positions detected:** Confirm `TARGET_ADDRESS` has active positions.\n\n## License\nMIT (per `package.json`)\n\n## Contact\n@Tokidokitrader\n","该项目是一个用于Polymarket平台的自动交易机器人，使用TypeScript编写。它能够监控指定账户的活动，并可选择性地复制其交易操作，即当目标账户开仓时自动买入，平仓时自动卖出。该机器人通过轮询机制获取目标地址的实时状态，并利用Polymarket的CLOB客户端执行订单。此外，还提供了干运行模式以模拟交易决策过程而不实际下单，以及设置最小\u002F最大交易额度等风控措施。此工具适用于希望跟随特定用户或策略进行自动化预测市场交易的投资者。","2026-06-01 03:51:40","CREATED_QUERY"]