{"id":50491238,"url":"https://github.com/doge-8/btc5m-web","last_synced_at":"2026-06-02T03:03:09.372Z","repository":{"id":361526639,"uuid":"1254799538","full_name":"doge-8/btc5m-web","owner":"doge-8","description":"Quick-order tool \u0026 pluggable automated strategy framework for Polymarket's BTC/ETH/SOL 5m \u0026 15m up/down markets. Real-time order book + Binance/Chainlink data, market \u0026 limit (maker) strategies, dual-mode panel, backtesting. Self-hosted, open source.","archived":false,"fork":false,"pushed_at":"2026-05-31T03:14:33.000Z","size":4760,"stargazers_count":0,"open_issues_count":0,"forks_count":1,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-05-31T04:19:59.400Z","etag":null,"topics":["algorithmic-trading","bitcoin","crypto","nodejs","polymarket","prediction-markets","trading","trading-bot","typescript","websocket"],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/doge-8.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2026-05-31T02:43:07.000Z","updated_at":"2026-05-31T03:16:30.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/doge-8/btc5m-web","commit_stats":null,"previous_names":["doge-8/btc5m-web"],"tags_count":null,"template":false,"template_full_name":null,"purl":"pkg:github/doge-8/btc5m-web","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/doge-8%2Fbtc5m-web","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/doge-8%2Fbtc5m-web/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/doge-8%2Fbtc5m-web/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/doge-8%2Fbtc5m-web/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/doge-8","download_url":"https://codeload.github.com/doge-8/btc5m-web/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/doge-8%2Fbtc5m-web/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":33803734,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-02T02:00:07.132Z","response_time":109,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["algorithmic-trading","bitcoin","crypto","nodejs","polymarket","prediction-markets","trading","trading-bot","typescript","websocket"],"created_at":"2026-06-02T03:03:08.477Z","updated_at":"2026-06-02T03:03:09.367Z","avatar_url":"https://github.com/doge-8.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# BTC 5m — Quick Order Tool \u0026 Automated Strategy Framework\n\n\u003e A quick-order tool and automated strategy framework for Polymarket's **BTC 5-minute up/down** market.\n\n![License](https://img.shields.io/badge/license-MIT-blue.svg)\n![Node](https://img.shields.io/badge/node-%3E%3D20-brightgreen.svg)\n![TypeScript](https://img.shields.io/badge/TypeScript-5.x-3178c6.svg)\n\nRun it fully locally for fast manual trading with helper overlays, or deploy it to a cloud server for low-latency, 24/7 automated trading. It connects to multiple upstream WebSockets (Polymarket order book / Chainlink price / Binance reference price) and shows the live order book, price trends, positions, and an order panel — with a pluggable strategy system for automation.\n\n**Multi-market by design:** the data layer supports **BTC / ETH / SOL** across **5m / 15m** windows (6 markets, switchable from the UI), and adding a new symbol is a one-line config change. The bundled example strategies target BTC 5m; other markets are ready for your own strategies (thresholds differ a lot per coin, so they shouldn't be blindly reused).\n\n![Main dashboard](docs/screenshots/dashboard.png)\n\n\u003e _Main dashboard (full mode): live order book, strategy tooltip, probability \u0026 price curves, and the order panel._\n\n---\n\n## Table of Contents\n\n- [Why this tool](#why-this-tool)\n- [Features](#features)\n- [Quick Start](#quick-start)\n- [Project Structure](#project-structure)\n- [Strategies](#strategies)\n- [API](#api)\n- [Cloud Deployment](#cloud-deployment)\n- [Security](#security)\n- [Contributing](#contributing)\n- [Support this project](#support-this-project)\n- [License](#license)\n\n---\n\n## Why this tool\n\n| | Polymarket Official | This Tool |\n|---|---|---|\n| **Order flow** | Wallet signature required every time, easy to miss the moment | Credentials auto-cached after the first signature, one-click order |\n| **Price reference** | Chainlink oracle price only | Also shows Binance real-time price, faster reaction |\n| **Data visualization** | Probability numbers only | Probability curve + Binance price curve + diff comparison |\n| **Automated trading** | None | Modular strategy framework, fully automated execution of custom strategies |\n| **Deployment** | Browser only | Local run / cloud server, 24/7 unattended |\n\n\u003e ⚠️ **Disclaimer:** The built-in strategies are framework examples only and **cannot guarantee profits**. Develop and tune your own strategies based on your own analysis. Trading involves risk; you are solely responsible for any losses.\n\n![Multi-account monitor](docs/screenshots/monitor.png)\n\n\u003e _Multi-account monitor: track balance, PnL, win rate, and live status across multiple instances at a glance._\n\n---\n\n## Features\n\n### ⚡ Quick Order\n- After the first private-key signature, API credentials are auto-cached — no repeated signing\n- FOK (fill-or-kill) market orders, avoiding resting-order risk\n- One-click buy up / buy down from the panel, with slippage settings\n\n### 🌐 Multi-Market\n- **BTC / ETH / SOL** × **5m / 15m** = 6 markets, switchable from the UI\n- Data-driven config (`market-configs.ts`) — add a new symbol/period in one entry\n- Per-coin price precision handled automatically (BTC integer, SOL 4 decimals, etc.)\n- Built-in strategies target BTC 5m; other markets are ready for your own strategies\n\n### 📊 Real-Time Data\n- Four parallel WebSockets: Polymarket order book, Chainlink oracle, user fills, Binance real-time price\n- Binance price reacts faster than the Chainlink oracle, providing a leading signal\n- Automatic price-offset calibration (MAD outlier filtering + trimmed mean)\n- Automatic market-window switch (every 5m / 15m depending on the market)\n\n### 🧩 Strategy Framework\n- Each strategy is a single file under `strategies/`, implementing a unified interface\n- Add a strategy: drop in a file → restart, and the frontend shows it automatically\n- Strategy parameters carry comments; frontend hover descriptions are generated automatically\n- Supports both **market** and **limit (maker)** order strategies\n- Multiple entries per round (count configurable, persisted)\n- Trade records saved automatically, with entry/exit reasons and PnL details\n\n### 🖥 Frontend Panel (Dual Mode)\n- **Full mode** — Complete dashboard: order-book depth, probability/price curves, manual order panel, strategy controls, trade records — for manual trading and monitoring\n- **Low mode** — Lean panel for automation: core data (probability/diff/countdown) + strategy status + trade records, low bandwidth — for unattended running and mobile viewing\n- Toggle strategy switches, amounts, and per-round counts in real time\n- Auto-claim of expired positions\n\n### 🔬 Data Collection \u0026 Backtesting\n- One-click backtest data collection from the frontend\n- Records diff, probability, time remaining, and other key metrics every second\n- Companion Python analysis script with parameter-sweep optimization (multi-core)\n\n---\n\n## Quick Start\n\n### Requirements\n- Node.js **20+**\n\n### Install\n```bash\nnpm install\n```\n\n### Configure\n```bash\ncp .env.example .env\n```\n\n**Required:**\n- `POLYMARKET_PRIVATE_KEY` — Polygon private key (auto-generates API credentials on first run)\n- `POLYMARKET_PROXY_ADDRESS` — Polymarket proxy wallet address (**not the deposit address**; log in to polymarket.com → top-right avatar → Settings → Wallet → copy \"Proxy Wallet\", which maps one-to-one with the private key; a wrong value triggers `invalid signature`)\n\n**Optional:**\n- `APP_MODE` — `full` (with panel) or `headless` (API only)\n- `STRATEGY_\u003cKEY\u003e_ENABLED` / `STRATEGY_\u003cKEY\u003e_AMOUNT` — strategy switch and amount (KEY is the uppercase strategy name, e.g. `D1`, `P1`, `P2`)\n- `ORDER_DEFAULT_SLIPPAGE` — default slippage\n- `AUTO_CLAIM_ENABLED` — auto-claim expired positions\n\n### Run\n```bash\n# macOS / Linux\n./start.sh\n\n# Windows\nstart.bat\n\n# or\nnpm start\n```\n\nThen open **http://localhost:3456**\n\n---\n\n## Project Structure\n\n```\n├── server.ts              # Backend service (Express + WebSocket, port 3456)\n├── index.html             # Frontend panel\n├── strategies/            # Strategy modules (plugin-based: add/remove files, no registry edits)\n│   ├── types.ts           # Shared types and the IStrategy interface\n│   ├── registry.ts        # Strategy registry (driven by _runtime/loader)\n│   ├── _runtime/          # Dynamic loader\n│   ├── _core/             # Shared core logic (fair-prob / momentum factors)\n│   ├── d1.ts              # Diff-based\n│   └── p1.ts, p2.ts       # Prob-chase\n├── backtest-data/         # Backtest data (generated at runtime)\n├── .env.example           # Environment variable template\n├── start.sh               # macOS/Linux launch script\n└── start.bat              # Windows launch script\n```\n\n---\n\n## Strategies\n\n### Built-in\n\n| Key | Name | Logic Summary |\n|-----|------|---------------|\n| **D1** | Diff 1 · Tail Sweep | large-diff entry at the window tail, diff-cross-0 stop-loss, holds to settlement |\n| **P1** | Prob-Chase 1 | fair-prob table lookup, entry when probability lags the diff, reverse ±5 stop-loss |\n| **P2** | Prob-Chase 2 · End-Game Crossing | rem 90~30s crossing entry + bias/probability filter, reverse ±5 stop-loss |\n\nEach strategy file has full parameters and comments at the top; hover over the strategy name in the UI to see its detailed rules.\n\n### Add your own (plugin-based)\n\nCreate a file under `strategies/` whose name matches `\u003cletter-prefix\u003e\u003cnumber\u003e.ts` (e.g. `d3.ts`, `x1.ts`) and export a class implementing `IStrategy`. After restarting, the dynamic loader registers it automatically and the frontend generates the UI for it.\n\n```ts\n// strategies/x1.ts example\nimport type { IStrategy, StrategyTickContext, EntrySignal, ExitSignal } from \"./types.js\";\n\nexport default class X1 implements IStrategy {\n  readonly key = \"x1\";\n  readonly number = 1;\n  readonly name = \"My Strategy\";\n  getDescription() { return { key: this.key, number: this.number, name: this.name, title: \"X1\", lines: [] }; }\n  updateGuards(_ctx: StrategyTickContext) {}\n  checkEntry(_ctx: StrategyTickContext): EntrySignal | null { return null; }\n  checkExit(_ctx: StrategyTickContext): ExitSignal { return null; }\n  resetState() {}\n  getStatePayload() { return {}; }\n}\n```\n\nTo remove a strategy, just delete its file — no registry changes needed.\n\nPrefixes: `d` diff · `p` prob-chase · `t` trend · `l` limit-order (maker) · `m` momentum (reserved).\n\nSee **[strategies/STRATEGY-GUIDE.md](strategies/STRATEGY-GUIDE.md)** for the full development guide, including how to build limit-order (maker) strategies.\n\n---\n\n## API\n\n| Method | Path | Description |\n|--------|------|-------------|\n| `GET`  | `/api/state` | Full state snapshot |\n| `GET`  | `/api/strategy/descriptions` | Strategy descriptions |\n| `POST` | `/api/strategy/config` | Update strategy config |\n| `POST` | `/api/order` | Manual order |\n| `POST` | `/api/claim` | Claim expired positions |\n| `POST` | `/api/backtest/toggle` | Toggle backtest data collection |\n\n---\n\n## Cloud Deployment\n\nAfter uploading the project to your server, configure and start it as above. Keep it running in the background with `screen`:\n\n```bash\nscreen -S btc5m\nnpm start\n# press Ctrl+A then D to detach\n```\n\nAccess the panel securely via an SSH tunnel (do **not** expose the port publicly):\n\n```bash\nssh -L 3456:127.0.0.1:3456 username@server_ip\n```\n\nThen open **http://127.0.0.1:3456** in your local browser.\n\n---\n\n## Security\n\n**Private key \u0026 credentials**\n- The private key lives only in your local `.env` and is never uploaded anywhere\n- API credentials are derived from it and cached to `.polymarket-creds.json` for reuse\n- Both are excluded via `.gitignore`\n\n**Network access**\n- The service listens on `localhost:3456`, accessible only from the local machine\n- **Never expose the port directly to the public internet** — anyone who can reach it can place orders via the API\n- Always use an SSH tunnel for remote access\n\n**Fund safety**\n- Test with the smallest amount first; scale up only after confirming the behavior\n- Strategy switches and amounts can be adjusted from the frontend at any time\n- Built-in strategies are examples only and are not investment advice\n\n**Never share or commit these files:**\n\n| File | Contents |\n|------|----------|\n| `.env` | Private key and wallet address |\n| `.polymarket-creds.json` | API credentials |\n| `.strategy-config.json` | Persisted config |\n\n---\n\n## Contributing\n\nThe tool provides a complete strategy framework and backtesting capability, but good strategies need continuous iteration. Contributions and ideas are very welcome — especially if you:\n\n- Have better entry/exit ideas or have discovered new data patterns\n- Want to do strategy backtesting and optimization together\n- Want to **build more powerful features on top of this project** (forks encouraged!)\n- Have any thoughts on the Polymarket BTC 5-minute market\n\nOpen an issue / PR, or reach out directly — let's achieve a 1+1 \u003e 2 effect.\n\n---\n\n## Support this project\n\nThis project is free and open source. If you find it useful, here are a few ways to support it — all cost you nothing and mean a lot:\n\n- ⭐ **Star this repo** — it helps more people discover the project and keeps me motivated to maintain it\n- 🔗 **Sign up for Polymarket via my referral link** — directly supports continued development:\n  ### 👉 https://polymarket.com/?r=yue188888x\n- 🛠 **Build on top of it** — fork it and create something more powerful; I'd love to see what you make\n- 🤖 **Prefer copy-trading?** If you'd rather follow trades than run your own strategies, try **Kreo** — a copy-trading Telegram bot ([@kreoapp](https://x.com/kreoapp)). Tap to open it in Telegram: **https://t.me/KreoPolyBot?start=ref-188888x**\n- 📈 **Trade crypto \u0026 RWAs?** Check out **Variational (Omni)** ([@variational_io](https://x.com/variational_io)) — a trading platform for crypto, RWAs, and more (recently raised $50M). Trade and earn points along the way: **https://omni.variational.io/?ref=OMNI88888**\n- 🐦 **Get in touch** — questions, ideas, or collaboration on X (Twitter): **[@x_188888_x](https://x.com/x_188888_x)**\n\nThank you for supporting open source! 🙏\n\n---\n\n## License\n\nMIT — for personal use and learning/research. The risk of using this tool for trading is borne solely by the user.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdoge-8%2Fbtc5m-web","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdoge-8%2Fbtc5m-web","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdoge-8%2Fbtc5m-web/lists"}