{"id":51006728,"url":"https://github.com/alforge-labs/alpha-strike","last_synced_at":"2026-06-20T21:01:16.035Z","repository":{"id":358623030,"uuid":"1191624476","full_name":"alforge-labs/alpha-strike","owner":"alforge-labs","description":"Self-hosted webhook bridge from TradingView alerts to moomoo / OANDA brokers, with Cloudflare Tunnel + WAF reference architecture (Apache-2.0).","archived":false,"fork":false,"pushed_at":"2026-06-16T14:25:40.000Z","size":1210,"stargazers_count":0,"open_issues_count":2,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-06-16T16:11:49.270Z","etag":null,"topics":["algotrading","cloudflare-tunnel","fastapi","moomoo","oanda","paper-trading","python","tradingview","webhook"],"latest_commit_sha":null,"homepage":"https://alforgelabs.com/ja/docs/guides/alpha-strike-setup/","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/alforge-labs.png","metadata":{"files":{"readme":"README.en.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.en.md","funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.en.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":"SECURITY.en.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":"NOTICE","maintainers":null,"copyright":null,"agents":"AGENTS.md","dco":null,"cla":null}},"created_at":"2026-03-25T12:34:38.000Z","updated_at":"2026-06-16T14:30:12.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/alforge-labs/alpha-strike","commit_stats":null,"previous_names":["alforge-labs/alpha-strike"],"tags_count":14,"template":false,"template_full_name":null,"purl":"pkg:github/alforge-labs/alpha-strike","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alforge-labs%2Falpha-strike","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alforge-labs%2Falpha-strike/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alforge-labs%2Falpha-strike/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alforge-labs%2Falpha-strike/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/alforge-labs","download_url":"https://codeload.github.com/alforge-labs/alpha-strike/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alforge-labs%2Falpha-strike/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34585195,"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-20T02:00:06.407Z","response_time":98,"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":["algotrading","cloudflare-tunnel","fastapi","moomoo","oanda","paper-trading","python","tradingview","webhook"],"created_at":"2026-06-20T21:01:14.935Z","updated_at":"2026-06-20T21:01:16.028Z","avatar_url":"https://github.com/alforge-labs.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# alpha-strike\n\n[![PyPI version](https://img.shields.io/pypi/v/alpha-strike.svg)](https://pypi.org/project/alpha-strike/)\n[![CI](https://github.com/alforge-labs/alpha-strike/actions/workflows/ci.yml/badge.svg)](https://github.com/alforge-labs/alpha-strike/actions/workflows/ci.yml)\n[![CodeQL](https://github.com/alforge-labs/alpha-strike/actions/workflows/codeql.yml/badge.svg)](https://github.com/alforge-labs/alpha-strike/actions/workflows/codeql.yml)\n[![License: Apache 2.0](https://img.shields.io/badge/License-Apache_2.0-blue.svg)](LICENSE)\n[![Python](https://img.shields.io/pypi/pyversions/alpha-strike.svg)](https://pypi.org/project/alpha-strike/)\n\n**English** | [日本語](README.md)\n\n\u003e **Self-hosted webhook bridge from TradingView alerts to moomoo / OANDA brokers**\n\n`alpha-strike` is a FastAPI-based webhook server that receives signals from TradingView Premium / Essential alerts and routes orders to **moomoo securities (US / HK stocks, crypto)** or **OANDA securities (FX / CFD)** based on the JSON payload.\n\nThis repo also ships a **production-ready reference architecture using Oracle Cloud Always Free + Cloudflare Tunnel + Cloudflare WAF Custom Rule** that runs at zero monthly cost and is immune to home IP changes (DHCP).\n\n```\nTradingView Premium / Essential\n       │  HTTPS Webhook\n       ▼\nCloudflare WAF Custom Rule (TradingView IP allowlist)\n       │\nCloudflare Tunnel (cloudflared)\n       │  outbound only (NSG Ingress = 0)\n       ▼\nalpha-strike (FastAPI, this repo)\n       │\n       ├──► moomoo OpenD ─► moomoo SIMULATE / REAL (US / HK stocks, crypto)\n       └──► OANDA REST v20 ─► OANDA PRACTICE / LIVE (FX / CFD)\n```\n\n## Features\n\n- **TradingView webhook receiver** — accepts JSON payloads at `/webhook` with strict Pydantic validation\n- **Passphrase authentication** — HMAC-compares the request body `passphrase` against `WEBHOOK_PASSPHRASE`\n- **Multi-broker routing** — `broker: \"moomoo\" | \"oanda\"` selects the target. `asset_class` covers `US` / `HK` / `CRYPTO` / `FX` / `COMMODITY` / `INDEX`\n- **Rate limiting** — `slowapi` enforces `10 req/min/IP`\n- **Retry + timeout** — `tenacity` handles transient broker API failures (OANDA: exponential backoff ×3, moomoo: fixed 2s ×3)\n- **JSONL event log** — appends `SignalEvent` / `OrderEvent` / `FillEvent` / `TradeClosedEvent` for downstream pnl reconciliation\n- **Memory / service monitoring** — `scripts/check_memory.sh` (cron 5 min) ntfy-pushes memory, swap, service status, and OOM history\n- **Production deployment guide** — `docs/ops/vm-provisioning.md` documents the full Oracle Cloud E2.1.Micro + Cloudflare Tunnel + systemd procedure\n\n## Quick Start\n\n### From PyPI (recommended)\n\n```bash\n# uv (recommended)\nuv add alpha-strike\n\n# Or pipx for a global CLI\npipx install alpha-strike\n\n# Or plain pip into a venv\npip install alpha-strike\n```\n\nRun:\n\n```bash\nWEBHOOK_PASSPHRASE=your-secret-passphrase alpha-strike\n\n# Custom host / port\nWEBHOOK_PASSPHRASE=your-secret-passphrase alpha-strike --host 127.0.0.1 --port 9000\n\n# Verify\ncurl http://localhost:8080/health\n# → {\"status\":\"ok\"}\n```\n\n### From source (for development)\n\n```bash\ngit clone https://github.com/alforge-labs/alpha-strike.git\ncd alpha-strike\nuv sync\n\n# Configure .env\necho 'WEBHOOK_PASSPHRASE=your-secret-passphrase' \u003e .env\necho 'MOOMOO_TRD_ENV=SIMULATE' \u003e\u003e .env  # if using moomoo\necho 'OANDA_ENV=PRACTICE'     \u003e\u003e .env   # if using OANDA\n\n# Run via the CLI\nuv run alpha-strike\n\n# Hot-reload (dev)\nuv run alpha-strike --reload\n```\n\n### Production: Oracle Cloud + Cloudflare Tunnel\n\nFull operational procedure for paper-trading production:\n\n- 📖 [alpha-strike Setup Guide](https://alforgelabs.com/en/docs/guides/alpha-strike-setup/) — VM provisioning, Cloudflare Tunnel, WAF, OpenD, systemd\n- 📖 [TradingView × alpha-strike Integration](https://alforgelabs.com/en/docs/guides/tradingview-alpha-strike/) — payload spec and Pine v6 template\n\n## Environment Variables\n\n| Variable | Required | Description |\n|---|---|---|\n| `WEBHOOK_PASSPHRASE` | ✅ | Authentication passphrase (32+ char random string recommended) |\n| `ALPHA_STRIKE_HOST` | — | Bind host (default `0.0.0.0`) |\n| `ALPHA_STRIKE_PORT` | — | Bind port (default `8080`) |\n| `MOOMOO_HOST` | moomoo | OpenD host (default `127.0.0.1`) |\n| `MOOMOO_PORT` | moomoo | OpenD port (default `11111`) |\n| `MOOMOO_TRD_ENV` | moomoo | `SIMULATE` (paper) or `REAL` (live) |\n| `MOOMOO_TIME_IN_FORCE` | — | Time-in-force for **REAL** US-market MARKET orders (#76). `GTC` (default) carries orders received after the market close over to the next session's open / `DAY` restores the legacy same-day-only behavior (after-close orders expire unfilled). HK / CRYPTO always use `DAY` per moomoo spec and trading-hour characteristics. **SIMULATE (paper) always uses `DAY` regardless of this setting because moomoo 10.7 rejects GTC for paper trading**. SIMULATE after-close signals would expire as DAY, so `CARRYOVER_*` (#89) re-submits them at the next market open to fill them |\n| `MOOMOO_SELL_POSITION_GUARD` | — | Over-sell guard that clamps a moomoo SELL to the broker's actual `can_sell_qty` (trims the excess) and skips it when no position is held (default `1`=on; set `0`/`false` to disable). Prevents `Not enough positions` caused by the open-loop drift in the Pine→webhook→broker pipeline |\n| `MOOMOO_TARGET_QTY_RECONCILE` | — | When the payload carries `target_qty` (absolute target holding), re-resolves the order side/quantity against the broker's actual position (closed-loop, #80; default `1`=on). Set `0`/`false` to fall back to the legacy delta interpretation |\n| `PENDING_RECONCILE_ENABLED` | — | Periodically re-reconciles non-terminal orders (e.g. GTC orders that fill on the next trading day) and appends the confirmed fill as an `order_reconciled` event (#79; default `1`=on). Set `0`/`false` to disable |\n| `PENDING_RECONCILE_INTERVAL_SECONDS` | — | Sweep interval in seconds (default `600`). Also runs once immediately at startup |\n| `CARRYOVER_ENABLED` | — | **SIMULATE only**: carry-over emulation that re-submits US-market after-close signals at the next market open (#89; default `1`=on). Set `0`/`false` to disable. Disabled internally for REAL (which has GTC carry-over) |\n| `CARRYOVER_RESUBMIT_INTERVAL_SECONDS` | — | Carry-over re-submit sweep interval in seconds (default `300`). Also runs once immediately at startup |\n| `CARRYOVER_LOOKBACK_HOURS` | — | Expiry of a queued intent in hours (default `48`). Older intents are abandoned as stale rather than re-submitted (covers weekend gaps) |\n| `CARRYOVER_MAX_RESUBMITS` | — | Max re-submit attempts per intent (default `3`). Intents exceeding this are abandoned (prevents repeated misfires) |\n| `OANDA_API_KEY` | OANDA | Personal Access Token |\n| `OANDA_ACCOUNT_ID` | OANDA | Account ID |\n| `OANDA_ENV` | OANDA | `PRACTICE` (demo) or `LIVE` (production) |\n| `LIVE_EVENTS_PATH` | — | JSONL event-log directory (default `/app/data/events`; match the docker-compose volume mount) |\n| `STATUS_API_TOKEN` | — | Bearer token for `/status` and `/status/events` (#57). When unset, those endpoints are disabled with 503 (fail-safe, private by default) |\n| `NTFY_TOPIC` | — | ntfy topic for fill push notifications (#57 Phase 2). No-op when unset |\n| `NTFY_SERVER` | — | ntfy server (default `https://ntfy.sh`) |\n| `ORDER_RECONCILE_DELAY_SECONDS` | — | Seconds to wait before reconciling order status after submission (default `5`) |\n\n\u003e **Important**: Always use `MOOMOO_TRD_ENV=SIMULATE` / `OANDA_ENV=PRACTICE` for testing. The maintainers are not liable for accidental orders on live accounts.\n\n## Webhook Payload\n\nSee [docs/tradingview.md](docs/tradingview.md) and [docs/webhook-payload-v2.md](docs/webhook-payload-v2.md) for the full spec. Minimal example:\n\n```json\n{\n  \"passphrase\": \"your-secret-passphrase\",\n  \"broker\": \"moomoo\",\n  \"asset_class\": \"US\",\n  \"action\": \"buy\",\n  \"ticker\": \"US.AAPL\",\n  \"quantity\": 10,\n  \"run_mode\": \"paper\",\n  \"strategy_id\": \"demo_buy_v1\"\n}\n```\n\nWith the optional `target_qty` field (absolute target holding, `\u003e= 0`), moomoo orders are re-resolved against the broker's actual position (closed-loop, #80). `quantity` is still sent as the delta fallback for versions without `target_qty` support.\n\n| `asset_class` | broker | ticker example |\n|---|---|---|\n| `US` | moomoo / oanda | `US.AAPL` / `AAPL` |\n| `HK` | moomoo | `HK.00700` |\n| `CRYPTO` | moomoo | `CC.BTC` / `CC.ETH` / `CC.XRP` |\n| `FX` | oanda | `USDJPY` |\n| `COMMODITY` | oanda | `XAUUSD` |\n| `INDEX` | oanda | `NAS100` |\n\n## Documentation\n\n- 📖 [Official Documentation](https://alforgelabs.com/en/docs/) — full doc index\n- 📖 [alpha-strike Setup Guide](https://alforgelabs.com/en/docs/guides/alpha-strike-setup/) — production go-live procedure\n- 📖 [Webhook payload spec](docs/tradingview.md)\n- 📖 [VM provisioning playbook](docs/ops/vm-provisioning.md) — Oracle Cloud E2.1.Micro + Cloudflare Tunnel\n- 📖 [Paper-trading go-live checklist](docs/ops/paper-trading-go-live.md)\n- 📖 [moomoo OpenD setup](docs/moomoo_futud.md)\n\n## Contributing\n\n- **Contribution guide**: [CONTRIBUTING.en.md](CONTRIBUTING.en.md)\n- **Security reporting**: [SECURITY.en.md](SECURITY.en.md)\n- **Code of conduct**: [CODE_OF_CONDUCT.en.md](CODE_OF_CONDUCT.en.md) (Contributor Covenant v2.1)\n- **Changelog**: [CHANGELOG.md](CHANGELOG.md)\n\n## Development\n\n```bash\n# Install deps\nuv sync\n\n# Test + lint\nuv run pytest tests/ -q\nuv run ruff check .\n\n# Build PyPI artifacts locally\nuv build\n# → dist/alpha_strike-X.Y.Z-py3-none-any.whl + .tar.gz\n```\n\n## Related Projects\n\n- 🌐 [alforgelabs.com](https://alforgelabs.com/) — Alforge Labs official site\n- 📊 [alpha-visualizer](https://github.com/alforge-labs/alpha-visualizer) — Web visualization for AlphaForge backtest results (Apache-2.0)\n- 🧪 [AlphaForge](https://alforgelabs.com/en/docs/) — Backtesting and optimization engine (commercial license)\n\n## Disclaimer\n\nThis software is provided **AS IS** without any warranty. **Automated trading can result in losses exceeding your principal.** The copyright holders and contributors disclaim all liability for any direct or indirect damages (including financial losses) arising from use of this software. Use entirely at your own risk.\n\nYou are responsible for complying with each broker's terms of service, trading hours, and regulatory requirements. For example, moomoo crypto for US residents is subject to FinCEN MSB regulations; verify and comply yourself.\n\n## License\n\n[Apache License 2.0](LICENSE) © [alforge-labs](https://github.com/alforge-labs)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falforge-labs%2Falpha-strike","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Falforge-labs%2Falpha-strike","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falforge-labs%2Falpha-strike/lists"}