[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"project-83095":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":16,"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":27,"readmeContent":28,"aiSummary":29,"trendingCount":15,"starSnapshotCount":15,"syncStatus":30,"lastSyncTime":31,"discoverSource":32},83095,"polymarket-5min-15m-btc-trading-bot","RetroValixx\u002Fpolymarket-5min-15m-btc-trading-bot","RetroValixx","polymarket bot polymarket bot polymarket bot polymarket bot polymarket bot polymarket bot polymarket bot polymarket bot polymarket bot polymarket bot polymarket bot polymarket bot polymarket bot polymarket bot polymarket bot polymarket bot polymarket bot polymarket bot polymarket bot polymarket bot polymarket trading bot polymarket trading bot","",null,"Python",110,407,105,0,1,7.83,false,"main",true,[22,23,24,25,26],"ai","arbitrage","bot","polymarket","trading","2026-06-12 02:04:31","# Polymarket Trading Bot\n\n**What is your native language** [🇨🇳 中文](README.zh.md) · [🇷🇺 Русский](README.ru.md)\n\n---\n\u003Cimg width=\"1981\" height=\"793\" alt=\"thumbnail\" src=\"https:\u002F\u002Fgithub.com\u002Fuser-attachments\u002Fassets\u002F31efdf63-1172-46b2-8713-e1173dc06722\" \u002F>\n\u003Cbr>\u003Cbr>\n\u003Cp align=\"center\">\n  \u003Cstrong>⭐ Want more profitable trading bots?\u003C\u002Fstrong>\u003Cbr>\u003Cbr>\n  Built by \u003Ca href=\"https:\u002F\u002Fgithub.com\u002FRetroValixx\">\u003Cstrong>Retro Valix\u003C\u002Fstrong>\u003C\u002Fa> — high-performance automated trading systems for Polymarket.\u003Cbr>\u003Cbr>\n  \u003Ca href=\"https:\u002F\u002Fgithub.com\u002FRetroValixx\">\u003Cimg alt=\"GitHub\" src=\"https:\u002F\u002Fimg.shields.io\u002Fbadge\u002FGitHub-RetroValixx-181717?logo=github&logoColor=white\">\u003C\u002Fa>&nbsp;\n  \u003Ca href=\"https:\u002F\u002Ft.me\u002FRetroValix\">\u003Cimg alt=\"Telegram\" src=\"https:\u002F\u002Fimg.shields.io\u002Fbadge\u002FTelegram-@RetroValix-26A5E4?logo=telegram&logoColor=white\">\u003C\u002Fa>&nbsp;\n  \u003Ca href=\"https:\u002F\u002Fx.com\u002FRetroValix\">\u003Cimg alt=\"X\" src=\"https:\u002F\u002Fimg.shields.io\u002Fbadge\u002FX-@RetroValix-000000?logo=x&logoColor=white\">\u003C\u002Fa>\n\u003C\u002Fp>\n\n---\n## How does the bot work\n\n\u003Cvideo width=\"100%\" controls src=\"https:\u002F\u002Fgithub.com\u002Fuser-attachments\u002Fassets\u002Fd89a6bc1-0cf6-4a1f-a29e-5e0549945e6f\">\n  \u003Ca href=\"https:\u002F\u002Fgithub.com\u002Fuser-attachments\u002Fassets\u002Fd89a6bc1-0cf6-4a1f-a29e-5e0549945e6f\">Watch demo video\u003C\u002Fa>\n\u003C\u002Fvideo>\n\n---\n## Proof of work\n\n\u003Cimg width=\"100%\" alt=\"2\" src=\"https:\u002F\u002Fgithub.com\u002Fuser-attachments\u002Fassets\u002F447c9671-3f47-4bde-a4be-744af27bdbb1\" \u002F>\n\n\u003Cimg width=\"100%\" alt=\"4\" src=\"https:\u002F\u002Fgithub.com\u002Fuser-attachments\u002Fassets\u002F8b88610b-c54b-4e3d-b7a6-2ccef7b72ca4\" \u002F>\n\n\u003Cimg width=\"100%\" alt=\"3\" src=\"https:\u002F\u002Fgithub.com\u002Fuser-attachments\u002Fassets\u002Ff7052333-8107-40d8-9703-d1bbd2b77bc7\" \u002F>\n\n---\n\n## Core Idea\n\nPrediction markets for short-horizon BTC moves are noisy and fast. This project treats them like a **systematic trading problem**: pull in market and context data, normalize it through a single ingestion path, fuse multiple detectors into a decision, then execute through a broker adapter with **hard risk limits** (small size per trade, take profit parameters). The goal is not \"one magic signal\" but a **testable stack** you can run in simulation, observe in Grafana, and only then point at live capital.\n\n---\n\n## Features\n\n- **Seven-phase pipeline** — External feeds → ingestion → Nautilus core → signal processors and fusion → execution and risk → monitoring → feedback \u002F learning hooks.\n- **Multi-signal stack** — Spike detection, sentiment-style inputs, divergence logic, order-book and momentum-style processors, plus fusion to combine votes.\n- **Risk-first defaults** — Configurable caps (e.g. ~$1 per trade), take profit, entry-price band, spread filter, direction lock, and anti-chase guard.\n- **Stop-loss toggle** — `ENABLE_STOP_LOSS=false` lets positions ride to take-profit or settlement; flip to `true` to re-enable the early-exit SL.\n- **ML edge gate** — Only bets when the XGBoost model's probability is at least `MIN_ML_EDGE` (default 10 pp) away from Polymarket's price.\n- **One bet per market** — `MAX_TRADES_PER_MARKET=1` fires a single entry per 15-min slot and moves on.\n- **Simulation and live** — Run paper \u002F test modes without touching production keys; switch to live only when ready.\n- **Operational tooling** — Redis-based mode hints, Grafana-friendly metrics, paper trade inspection, auto-restart wrapper for long runs.\n- **Self-learning hook** — Weights can be adjusted from performance feedback (see `feedback\u002F` and strategy configuration).\n- **Resilience** — WebSocket handling, rate limiting, validation, and patches around Polymarket + Nautilus edge cases (Gamma loading, market-order sizing, Windows `prometheus_client` guard).\n\n---\n\n## Prerequisites\n\n- **Python 3.14+**\n- **Redis** — used for mode switching and related control-plane behavior\n- **Polymarket account** with API credentials for live trading\n- **Git**\n\n---\n\n## Quick Start\n\n### 1. Clone the repository\n\n```bash\ngit clone https:\u002F\u002Fgithub.com\u002Fyourusername\u002Fpolymarket-btc-15m-bot.git\ncd polymarket-btc-15m-bot\n```\n\n### 2. Create a virtual environment\n\n```bash\n# Windows\npython -m venv venv\nvenv\\Scripts\\activate\n\n# macOS \u002F Linux\npython -m venv venv\nsource venv\u002Fbin\u002Factivate\n```\n\n### 3. Install dependencies\n\n```bash\npip install -r requirements.txt\n```\n\n### 4. Configure environment variables\n\n```bash\ncp .env.example .env\n```\n\nEdit `.env` with your credentials and parameters:\n\n```env\nPOLYMARKET_PK=your_private_key_here\nPOLYMARKET_API_KEY=your_api_key_here\nPOLYMARKET_API_SECRET=your_api_secret_here\nPOLYMARKET_PASSPHRASE=your_passphrase_here\n\nREDIS_HOST=localhost\nREDIS_PORT=6379\nREDIS_DB=2\n\nENABLE_STOP_LOSS=false\nTAKE_PROFIT_PCT=0.40\nMIN_ENTRY_PRICE=0.25\nMAX_ENTRY_PRICE=0.75\nMAX_TRADES_PER_MARKET=1\nMIN_ML_EDGE=0.10\n```\n\n### 5. Start Redis\n\n```bash\nredis-server\n```\n\nOn macOS with Homebrew: `brew install redis && redis-server`.\nOn Debian\u002FUbuntu: `sudo apt install redis-server && redis-server`.\n\n### 6. Run the bot\n\n```bash\n# Fast test loop (simulated trades ~every minute)\npython main.py --test-mode\n\n# Normal simulation (15-min clock)\npython main.py --simulation\n\n# Live trading (real money — requires valid credentials)\npython supervisor.py --live\n```\n\n---\n\n## Configuration\n\n| Parameter | Description | Default |\n|-----------|-------------|---------|\n| `ENABLE_STOP_LOSS` | Enable early stop-loss exit | `false` |\n| `STOP_LOSS_PCT` | Capital fraction lost at SL (only when SL enabled) | `0.50` |\n| `TAKE_PROFIT_PCT` | Fraction of remaining upside to take | `0.40` |\n| `MIN_ENTRY_PRICE` | Minimum token price to enter | `0.25` |\n| `MAX_ENTRY_PRICE` | Maximum token price to enter | `0.75` |\n| `MAX_SPREAD_PCT` | Max bid-ask spread relative to mid | `0.05` |\n| `ENTRY_COOLDOWN_SEC` | Seconds between entry attempts | `90` |\n| `MAX_TRADES_PER_MARKET` | Max entries per 15-min market | `1` |\n| `LOCK_MARKET_DIRECTION` | Lock direction after first trade on a market | `true` |\n| `MAX_CHASE_DELTA` | Max price delta allowed for re-entry | `0.12` |\n| `MIN_ML_EDGE` | Min ML probability gap required to bet | `0.10` |\n| `LATE_ENTRY_CUTOFF_SEC` | Refuse entries this close to settlement | `120` |\n| `MARKET_BUY_USD` | USD per order | `1.00` |\n\nSee `.env.example` for the full list with inline comments.\n\n---\n\n## Running the Bot\n\n- **Unified entrypoint**: `main.py` supports `--test-mode`, `--simulation`, and `--live`.\n- **Auto-restart wrapper**: `supervisor.py` runs `main.py` in a loop for unattended operation.\n- **Paper trades**: After simulation runs, inspect history with:\n\n```bash\npython scripts\u002Fview_trades.py\n```\n\n---\n\n## Monitoring\n\n- Metrics exporters and helpers live under `monitoring\u002F`.\n- Grafana dashboard assets live under `grafana\u002F` (import with `grafana\u002Fimport_dashboard.py`).\n\nWire these to your own Prometheus\u002FGrafana stack as needed.\n\n---\n\n## Trading Modes\n\nMode switching via Redis is supported for toggling simulation vs live without restarting; see `scripts\u002Fredis_control.py`.\n\n---\n\n## Testing Individual Phases\n\nRun the numbered checks **in order** after each previous phase succeeds.\n\n| Phase | Focus | Command |\n|-------|-------|---------|\n| 1 | Data sources (exchanges, news) | `python scripts\u002Ftest_data_sources.py test` |\n| 2 | Ingestion (adapter, websockets, validation) | `python scripts\u002Ftest_ingestion.py test` |\n| 3 | Nautilus core (instruments, engine, events) | `python scripts\u002Ftest_nautilus.py test` |\n| 4 | Strategy brain (processors, fusion) | `python scripts\u002Ftest_strategy.py test` |\n| 5 | Execution (risk, client, engine) | `python scripts\u002Ftest_execution.py test` |\n\nDebug the Gamma API directly:\n\n```bash\npython scripts\u002Fdebug_gamma_api.py\n```\n\n---\n\n## How Much Money Do I Need to Start?\n\nThe reference configuration uses **~$1 per fill**. You still need enough balance to cover fees, spread, and a string of losses. Many operators keep **$10–$50** for early experiments; scale only after simulation matches expectations. **This is not financial advice.**\n\n---\n\n## Is This Profitable?\n\nThere is **no guarantee** of profit. Short-horizon markets have fees, spread, adverse selection, and outages. Simulation results **do not** reliably predict live performance. Use paper mode and small size first; treat every run as an experiment.\n\n---\n\n## Best For\n\n- **Traders who want speed and automation** for 15-minute crypto prediction markets.\n- **Developers** comfortable editing `.env`, reading logs, and running phase tests.\n- **People who treat risk as primary** and want explicit caps and observability before scaling.\n\n---\n\n## Contributing and Ideas\n\nContributions are welcome via the usual GitHub flow (fork, branch, pull request).\n\n**Ideas for contributions:**\n- Add derivatives context (funding, open interest) as additional processors.\n- New signal processors or fusion rules.\n- Telegram or Discord alerts for fills and errors.\n- A small web UI for config and status.\n- Extend beyond BTC to ETH, SOL, and other Polymarket short-horizon products.\n- Stronger ML \u002F calibration layers with honest evaluation and paper-trading gates.\n\n---\n\n## License\n\nMIT License. See the repository's `LICENSE` file.\n\n---\n\n## Disclaimer\n\nTrading cryptocurrencies and prediction-market instruments involves **substantial risk of loss**. This software is provided for **education and research**. Past performance does not guarantee future results. The authors are **not** responsible for any financial losses. Start in simulation, use small size, and only trade with capital you can afford to lose entirely.\n\n---\n\n## Acknowledgments\n\n- [NautilusTrader](https:\u002F\u002Fnautilustrader.io\u002F) — Trading framework\n- [Polymarket](https:\u002F\u002Fpolymarket.com) — Prediction market venue\n\n\u003Cdiv align=\"center\">\n  \u003Ch2>Made with ❤️ by\u003C\u002Fh2>\n  \u003Ca href=\"https:\u002F\u002Ft.me\u002FRetroValix\">\n    \u003Cimg width=\"85\" height=\"85\" alt=\"XTLLbabR_400x400\" src=\"https:\u002F\u002Fgithub.com\u002Fuser-attachments\u002Fassets\u002F66c994bf-c618-40e7-a0f4-d295e09d1e91\" \u002F>    \u003Cbr>\n    \u003Cspan>Retro Valix\u003C\u002Fspan>\n  \u003C\u002Fa>\n\u003C\u002Fdiv>\n","该项目是一个用于Polymarket平台的比特币交易机器人，旨在通过系统化的方法在预测市场中进行短期BTC价格变动的交易。核心功能包括七阶段流水线处理、多信号堆栈融合决策以及严格的风险控制机制，如每笔交易金额限制和止损设置。技术上利用Python语言开发，并结合了机器学习模型来提升交易决策的质量。适用于希望在高波动性市场环境下实现自动化且风险可控交易策略的用户。",2,"2026-06-06 04:11:40","CREATED_QUERY"]