{"id":50425637,"url":"https://github.com/leionion/tradingview-webhook-to-bybit-lite","last_synced_at":"2026-05-31T10:30:35.389Z","repository":{"id":351258756,"uuid":"1180050696","full_name":"leionion/tradingview-webhook-to-bybit-lite","owner":"leionion","description":"A 50-line Flask bridge that turns any TradingView alert into a live executed trade on Bybit with zero lag.","archived":false,"fork":false,"pushed_at":"2026-04-14T08:02:43.000Z","size":20,"stargazers_count":20,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2026-04-14T10:03:33.863Z","etag":null,"topics":["algo-trading","automated-trading","bybit","bybit-api","crypto-trading","exchange-api","flask","python","quant-trading","self-hosted","signal-execution","trading-bot","tradingview","tradingview-alerts","webhook"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/leionion.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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-03-12T16:43:16.000Z","updated_at":"2026-04-14T09:06:21.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/leionion/tradingview-webhook-to-bybit-lite","commit_stats":null,"previous_names":["leionion/tradingview-webhook-to-bybit-lite"],"tags_count":null,"template":false,"template_full_name":null,"purl":"pkg:github/leionion/tradingview-webhook-to-bybit-lite","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leionion%2Ftradingview-webhook-to-bybit-lite","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leionion%2Ftradingview-webhook-to-bybit-lite/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leionion%2Ftradingview-webhook-to-bybit-lite/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leionion%2Ftradingview-webhook-to-bybit-lite/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/leionion","download_url":"https://codeload.github.com/leionion/tradingview-webhook-to-bybit-lite/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leionion%2Ftradingview-webhook-to-bybit-lite/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":33728391,"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-05-31T02:00:06.040Z","response_time":95,"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":["algo-trading","automated-trading","bybit","bybit-api","crypto-trading","exchange-api","flask","python","quant-trading","self-hosted","signal-execution","trading-bot","tradingview","tradingview-alerts","webhook"],"created_at":"2026-05-31T10:30:34.627Z","updated_at":"2026-05-31T10:30:35.379Z","avatar_url":"https://github.com/leionion.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# TradingView Webhook to Bybit\n\nProduction-ready webhook bridge for executing Bybit orders from TradingView alerts with strong safety defaults.\n\n## What Is Implemented\n\nThis project is fully implemented as a robust Flask service (not a minimal prototype).  \nIt includes:\n\n- TradingView webhook endpoint: `POST /webhook`\n- Health endpoint: `GET /health`\n- Payload schema validation with Pydantic\n- Webhook secret authentication via configurable header\n- Paper vs live execution modes\n- Live execution gate (`ALLOW_LIVE_WITHOUT_OVERRIDE`)\n- Bybit V5 request signing and order submission\n- In-memory replay/duplicate protection (TTL-based)\n- Structured JSON logging for operations and failures\n- Automated test suite with success and failure cases\n\n## Architecture\n\n```text\nTradingView Alert\n      |\n      v\nFlask API (/webhook)\n  -\u003e auth check\n  -\u003e payload validation\n  -\u003e dedup check\n  -\u003e mode gate (paper/live)\n  -\u003e Bybit V5 signed request (live)\n      |\n      v\nBybit Order API\n```\n\n## Project Structure\n\n```text\n.\n├── app.py\n├── requirements.txt\n├── .env.example\n├── tv_bybit_lite\n│   ├── bybit.py\n│   ├── config.py\n│   ├── dedup.py\n│   ├── logging_utils.py\n│   ├── schemas.py\n│   └── service.py\n└── tests\n    ├── conftest.py\n    └── test_webhook.py\n```\n\n## Requirements\n\n- Python 3.10+\n- Bybit API key/secret (only required for live mode)\n\n## Quick Start\n\n1) Clone and install dependencies:\n\n```bash\ngit clone https://github.com/leionion/tradingview-webhook-to-bybit-lite.git\ncd tradingview-webhook-to-bybit-lite\npython3 -m venv .venv\nsource .venv/bin/activate\npip install -r requirements.txt\n```\n\n2) Configure environment:\n\n```bash\ncp .env.example .env\n```\n\n3) Run the service:\n\n```bash\npython app.py\n```\n\n4) Verify health:\n\n```bash\ncurl http://localhost:5000/health\n```\n\n## Environment Variables\n\nCore settings (see `.env.example` for full list):\n\n- `BYBIT_API_KEY`\n- `BYBIT_API_SECRET`\n- `BYBIT_TESTNET` (`true|false`)\n- `BYBIT_RECV_WINDOW` (default: `5000`)\n- `HOST` (default: `0.0.0.0`)\n- `PORT` (default: `5000`)\n- `WEBHOOK_SECRET` (recommended for production)\n- `WEBHOOK_SECRET_HEADER` (default: `X-Webhook-Secret`)\n- `DEFAULT_MODE` (`paper|live`, default: `paper`)\n- `ALLOW_LIVE_WITHOUT_OVERRIDE` (`false` by default)\n- `ENABLE_DEDUP` (`true` by default)\n- `DEDUP_TTL_SECONDS` (default: `120`)\n\n## Webhook Payload\n\n### Required fields\n\n```json\n{\n  \"symbol\": \"BTCUSDT\",\n  \"side\": \"Buy\",\n  \"qty\": \"0.01\",\n  \"orderType\": \"Market\",\n  \"category\": \"linear\"\n}\n```\n\n### Optional fields\n\n- `price` (required when `orderType` is `Limit`)\n- `reduceOnly` (`true|false`)\n- `timeInForce` (`GTC|IOC|FOK|POSTONLY`)\n- `mode` (`paper|live`) - overrides `DEFAULT_MODE`\n- `alertId` (recommended for deterministic dedupe key)\n\n## Example Requests\n\n### Paper mode (safe default)\n\n```bash\ncurl -X POST http://localhost:5000/webhook \\\n  -H \"Content-Type: application/json\" \\\n  -H \"X-Webhook-Secret: change-me\" \\\n  -d '{\n    \"symbol\":\"BTCUSDT\",\n    \"side\":\"Buy\",\n    \"qty\":\"0.001\",\n    \"orderType\":\"Market\",\n    \"category\":\"linear\",\n    \"mode\":\"paper\",\n    \"alertId\":\"tv-btc-001\"\n  }'\n```\n\n### Live mode\n\n```bash\ncurl -X POST http://localhost:5000/webhook \\\n  -H \"Content-Type: application/json\" \\\n  -H \"X-Webhook-Secret: change-me\" \\\n  -d '{\n    \"symbol\":\"ETHUSDT\",\n    \"side\":\"Sell\",\n    \"qty\":\"0.02\",\n    \"orderType\":\"Limit\",\n    \"price\":\"3600\",\n    \"category\":\"linear\",\n    \"mode\":\"live\",\n    \"alertId\":\"tv-eth-002\"\n  }'\n```\n\n## Response Behavior\n\n- `200`: accepted and processed (`paper` or `live`)\n- `400`: invalid JSON or schema validation failed\n- `401`: webhook secret invalid/missing\n- `403`: policy restriction (e.g., live mode blocked)\n- `409`: duplicate payload detected\n- `502`: upstream Bybit/API execution failure\n\n## Testing\n\nRun tests:\n\n```bash\npytest -q\n```\n\nCurrent status: **6 passing tests**.\n\nCovered scenarios:\n\n- authentication required\n- paper mode success\n- live mode success path\n- duplicate detection\n- live mode policy blocking\n- order payload mapping correctness\n\n## Security and Production Notes\n\n- Always set `WEBHOOK_SECRET` in production.\n- Keep `DEFAULT_MODE=paper` while validating strategy behavior.\n- Only enable `ALLOW_LIVE_WITHOUT_OVERRIDE=true` when you intentionally want live execution.\n- Use unique `alertId` from TradingView to improve replay protection.\n- Use Bybit testnet first before any real capital.\n\n## TradingView Alert Message Template\n\nUse this JSON in TradingView alert message body:\n\n```json\n{\n  \"symbol\": \"{{ticker}}\",\n  \"side\": \"Buy\",\n  \"qty\": \"0.01\",\n  \"orderType\": \"Market\",\n  \"category\": \"linear\",\n  \"mode\": \"paper\",\n  \"alertId\": \"{{timenow}}-{{strategy.order.action}}\"\n}\n```\n\n## Contact\n\n- GitHub: [@leionion](https://github.com/leionion)\n\n## Disclaimer\n\nThis software can place real orders. Misconfiguration, payload errors, or logic flaws can cause losses.  \nUse testnet, paper mode, strict risk controls, and independent monitoring before live trading.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fleionion%2Ftradingview-webhook-to-bybit-lite","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fleionion%2Ftradingview-webhook-to-bybit-lite","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fleionion%2Ftradingview-webhook-to-bybit-lite/lists"}