[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"project-75814":3},{"id":4,"name":5,"fullName":6,"owner":7,"repo":5,"description":8,"homepage":9,"htmlUrl":10,"language":11,"languages":9,"totalLinesOfCode":9,"stars":12,"forks":13,"watchers":14,"openIssues":15,"contributorsCount":9,"subscribersCount":16,"size":16,"stars1d":15,"stars7d":17,"stars30d":18,"stars90d":16,"forks30d":16,"starsTrendScore":19,"compositeScore":20,"rankGlobal":9,"rankLanguage":9,"license":9,"archived":21,"fork":21,"defaultBranch":22,"hasWiki":21,"hasPages":21,"topics":9,"createdAt":9,"pushedAt":9,"updatedAt":23,"readmeContent":24,"aiSummary":25,"trendingCount":16,"starSnapshotCount":16,"syncStatus":26,"lastSyncTime":27,"discoverSource":28},75814,"go-trader","richkuo\u002Fgo-trader","richkuo","Crypto trading bot — backtesting, paper trading, live trading with risk management",null,"https:\u002F\u002Fgithub.com\u002Frichkuo\u002Fgo-trader","Go",313,92,4,3,0,11,38,9,5.91,false,"main","2026-06-12 02:03:36","# go-trader — Crypto Trading Bot\n\n[![GitHub release](https:\u002F\u002Fimg.shields.io\u002Fgithub\u002Fv\u002Frelease\u002Frichkuo\u002Fgo-trader)](https:\u002F\u002Fgithub.com\u002Frichkuo\u002Fgo-trader\u002Freleases\u002Flatest)\n[![Discord](https:\u002F\u002Fimg.shields.io\u002Fbadge\u002FDiscord-Join-5865F2?logo=discord&logoColor=white)](https:\u002F\u002Fdiscord.com\u002Finvite\u002F44BykmWZsP)\n[![License: MIT](https:\u002F\u002Fimg.shields.io\u002Fbadge\u002FLicense-MIT-yellow.svg)](LICENSE)\n\nA Go + Python hybrid trading system. A single Go binary (~8MB idle RAM) orchestrates 50+ strategies across spot, options, perpetual futures, and CME futures by spawning short-lived Python scripts. Both paper and live execution are supported per strategy.\n\nSupported platforms: Binance US, Deribit, IBKR\u002FCME, Hyperliquid, TopStep, Robinhood (crypto + stock options), OKX (spot + perps + options), Luno. Per-platform Discord\u002FTelegram channels post hourly summaries plus immediate trade alerts. When a new release ships, the bot DMs the configured owner — reply **yes** and it pulls, rebuilds, and restarts itself.\n\nJoin the Discord: [https:\u002F\u002Fdiscord.gg\u002F46d7Fa2dXz](https:\u002F\u002Fdiscord.gg\u002F46d7Fa2dXz)\n\n---\n\n## Getting Started\n\n**Quick flow for a new server:** tell OpenClaw or Hermes:\n\n```\ninstall https:\u002F\u002Fgithub.com\u002Frichkuo\u002Fgo-trader and init.\n```\n\n### AI Agent Setup (Recommended)\n\nGive your AI agent [SKILL.md](SKILL.md) (raw: `https:\u002F\u002Fraw.githubusercontent.com\u002Frichkuo\u002Fgo-trader\u002Fmain\u002FSKILL.md`) — it clones the repo, installs deps, walks through configuration, builds the binary, and starts the service. For non-Claude agents see [AGENTS.md](AGENTS.md). Using [OpenClaw](https:\u002F\u002Fopenclaw.ai) or [Hermes](https:\u002F\u002Fhermes-agent.nousresearch.com\u002F)? Just say \"Set up go-trader\".\n\n### Interactive Setup (go-trader init)\n\nAfter building the binary, run the config wizard:\n\n```bash\n.\u002Fgo-trader init\n```\n\nIt walks asset\u002Fstrategy\u002Fplatform\u002Fcapital\u002Frisk\u002FDiscord choices and writes `scheduler\u002Fconfig.json`. Defaults to a minimal BTC spot starter; risk prompts (warn threshold, portfolio kill-switch) appear only when live trading is selected.\n\nFor scripted deployments, use `--json`:\n\n```bash\n.\u002Fgo-trader init --json '{\"assets\":[\"BTC\"],\"enableSpot\":true,\"spotStrategies\":[\"sma_crossover\"],\"spotCapital\":1000,\"spotDrawdown\":10}' --output config.json\n```\n\n### Manual Setup\n\n```bash\ngit clone https:\u002F\u002Fgithub.com\u002Frichkuo\u002Fgo-trader.git && cd go-trader\ncurl -LsSf https:\u002F\u002Fastral.sh\u002Fuv\u002Finstall.sh | sh    # install uv if needed\nuv sync                                             # Python deps from lockfile\n\nVER=$(git describe --tags --always --dirty 2>\u002Fdev\u002Fnull || echo dev)\ncd scheduler && go build -ldflags \"-X main.Version=$VER\" -o ..\u002Fgo-trader . && cd ..\n\n.\u002Fgo-trader init                                    # or --json '{...}', or copy config.example.json\n.\u002Fgo-trader --config scheduler\u002Fconfig.json --once   # smoke-test one cycle\n\nexport DISCORD_BOT_TOKEN=\"your-token\"\nsudo bash scripts\u002Finstall-service.sh                # systemd install + enable + start\ncurl -s localhost:8099\u002Fstatus | python3 -m json.tool\n```\n\n### Running multiple instances\n\nUse the templated unit `systemd\u002Fgo-trader@.service`; each instance lives under `\u002Fopt\u002Fgo-trader-\u003Cname>\u002F`:\n\n```bash\nsudo mkdir -p \u002Fopt\u002Fgo-trader-paper-testing\u002Fscheduler\nsudo cp go-trader \u002Fopt\u002Fgo-trader-paper-testing\u002F\nsudo cp scheduler\u002Fconfig.json \u002Fopt\u002Fgo-trader-paper-testing\u002Fscheduler\u002F\nsudo chown -R go-trader:go-trader \u002Fopt\u002Fgo-trader-paper-testing\nsudo bash scripts\u002Finstall-service.sh systemd\u002Fgo-trader@.service paper-testing\n```\n\nSet `NO_START=1` to enable without starting.\n\n---\n\n## Architecture\n\n```\nGo scheduler (always running, ~8MB idle)\n  ↓ each cycle, spawns short-lived Python check scripts\n  ↓ receives JSON signals, executes paper\u002Flive trades, manages risk\n  ↓ persists to scheduler\u002Fstate.db, serves localhost:8099\u002Fstatus\n  ↓ posts Discord\u002FTelegram summaries and trade alerts\n\nPython adapters: binanceus, deribit, ibkr, hyperliquid, topstep, robinhood, okx, luno\n```\n\nPython provides the quant libraries (pandas, numpy, scipy, CCXT); Go provides memory efficiency. 50+ strategies peak around ~220MB for ~30s, then back to ~8MB idle.\n\n---\n\n## Strategies & Platforms\n\nStrategies are auto-discovered from `shared_strategies\u002F` at `go-trader init` time. Common picks: spot\u002Fperps share entries like `sma_crossover`, `ema_crossover`, `momentum`, `rsi`, `bollinger_bands`, `macd`, `mean_reversion`, `triple_ema`, `tema_cross`, `pairs_spread`, `chart_pattern`, `liquidity_sweeps`, `donchian_breakout`, `session_breakout`. Options use `vol_mean_reversion`, `momentum_options`, `protective_puts`, `covered_calls` (plus `wheel` and `butterfly` on Robinhood); new trades are scored vs. existing positions (strike distance, expiry spread, Greek balance). Max 4 positions per options strategy; min score 0.3 to execute.\n\n| Platform | Type | Assets | Live env vars | Paper data |\n|---|---|---|---|---|\n| Binance US | Spot | BTC, ETH, SOL | — | CCXT public |\n| Deribit | Options | BTC, ETH | — | Live quotes |\n| IBKR\u002FCME | Options | BTC, ETH | IBKR creds | Black-Scholes |\n| Hyperliquid | Perps | any HL-listed | `HYPERLIQUID_SECRET_KEY` | SDK public |\n| TopStep | Futures | ES, NQ, MES, MNQ, CL, GC | `TOPSTEP_API_KEY` \u002F `_SECRET` \u002F `_ACCOUNT_ID` | yfinance |\n| Robinhood | Crypto | BTC, ETH, SOL, DOGE, … | `ROBINHOOD_USERNAME` \u002F `_PASSWORD` \u002F `_TOTP_SECRET` | yfinance |\n| Robinhood | Stock options | SPY, QQQ, AAPL, … | (same as above) | Black-Scholes |\n| OKX | Spot + Perps + Options | BTC, ETH, SOL | `OKX_API_KEY` \u002F `_SECRET` \u002F `_PASSPHRASE` (`OKX_SANDBOX=1` for demo) | CCXT public |\n| Luno | Spot | BTC, ETH, … | Luno creds | CCXT public |\n\n**Hyperliquid perps direction** — per-strategy `direction: \"long\" | \"short\" | \"both\"`. `long` (default) opens longs only; `short` opens shorts only; `both` flips on reversals. Bidirectional\u002Fshort-focused strategies (`triple_ema_bidir`, `bear_pullback_st`, `vwap_rejection_st`, `donchian_breakout`, `chart_pattern`, `liquidity_sweeps`) require `\"short\"` or `\"both\"`. Legacy `allow_shorts` migrates automatically.\n\n**Coin sharing on Hyperliquid** — multiple HL strategies (including `type: \"manual\"`) can share a coin\u002Fwallet, with per-strategy SQLite bookkeeping over a single on-chain position. Peers must share `margin_mode` + `leverage`; at most one peer may run a trailing stop. Reduce-only SL and N-tier TPs are sized per strategy. Sub-accounts are the only path to fully independent direction\u002Fleverage\u002Fmargin.\n\n---\n\n## Configuration Reference\n\n### `scheduler\u002Fconfig.json`\n\nUse `.\u002Fgo-trader init` (interactive) or `.\u002Fgo-trader init --json '...'` (scripted) to generate this file. The full structure:\n\n```json\n{\n  \"config_version\": 14,\n  \"interval_seconds\": 3600,\n  \"db_file\": \"scheduler\u002Fstate.db\",\n  \"log_dir\": \"logs\",\n  \"auto_update\": \"daily\",\n  \"status_port\": 8099,\n  \"risk_free_rate\": 0.04,\n  \"default_stop_loss_atr_mult\": 1.0,\n  \"portfolio_risk\": {\n    \"max_drawdown_pct\": 25,\n    \"max_notional_usd\": 0,\n    \"warn_threshold_pct\": 60\n  },\n  \"regime\": {\n    \"enabled\": false,\n    \"period\": 14,\n    \"adx_threshold\": 20\n  },\n  \"discord\": {\n    \"enabled\": true,\n    \"token\": \"\",\n    \"owner_id\": \"\",\n    \"channels\": { \"spot\": \"CHANNEL_ID\", \"options\": \"CHANNEL_ID\", \"hyperliquid\": \"CHANNEL_ID\", \"topstep\": \"CHANNEL_ID\", \"robinhood\": \"CHANNEL_ID\", \"okx\": \"CHANNEL_ID\", \"luno\": \"CHANNEL_ID\" },\n    \"trade_alert_channels\": { \"hyperliquid\": \"TRADE_CHANNEL_ID\" }\n  },\n  \"platforms\": {\n    \"hyperliquid\": { \"risk\": { \"max_drawdown_pct\": 50 } }\n  },\n  \"strategies\": [ ... ]\n}\n```\n\n`config_version` is bumped automatically by `go-trader init` and migrated on startup. Recent migrations: v9 added HL perps stop-loss \u002F margin-mode fields; v11 added the `regime` block; v13 reshaped `open_strategy`\u002F`close_strategies` into co-located `{name, params}` refs; v14 replaced `allow_shorts` with the `direction` enum.\n\n### Portfolio Risk\n\n| Field | Description | Default |\n|-------|-------------|---------|\n| `portfolio_risk.max_drawdown_pct` | Kill switch — halt all trading if portfolio drops this % from peak | 25 |\n| `portfolio_risk.max_notional_usd` | Hard cap on total notional exposure (0 = disabled) | 0 |\n| `portfolio_risk.warn_threshold_pct` | Emit a Discord\u002FTelegram warning when drawdown reaches this % of `max_drawdown_pct` (repeats every cycle while in band) | 60 |\n| `risk_free_rate` | Annualized risk-free rate used in Sharpe-ratio calculations (e.g. `0.04` for 4%); `null`\u002Fomitted → default rate | 0.04 |\n| `status_port` | HTTP status server port; auto-falls-back up to 5 ports on collision. Override via `--status-port` CLI flag. | 8099 |\n| `default_stop_loss_atr_mult` | Top-level fallback ATR multiplier used to arm fixed-ATR stops on HL perps strategies that omit all five `stop_loss_*` \u002F `trailing_stop_*` fields. Set to `0` to opt every such strategy out fleet-wide. | 1.0 |\n\n### Regime Detection\n\nOptional ADX+DI 3-state gate (`trending_up` \u002F `trending_down` \u002F `ranging`) computed from the strategy's own OHLCV. Per-strategy `allowed_regimes` blocks new entries when the current regime isn't whitelisted (closes always pass). `regime.enabled` requires a restart; `allowed_regimes` is SIGHUP-reloadable. Options strategies don't emit a regime label yet.\n\n```json\n{\n  \"regime\": { \"enabled\": true, \"period\": 14, \"adx_threshold\": 20 },\n  \"strategies\": [{ \"id\": \"hl-momentum-btc\", \"allowed_regimes\": [\"trending_up\", \"trending_down\"] }]\n}\n```\n\n`regime.period` defaults to 14, `regime.adx_threshold` to 20 (below this → `ranging`).\n\n**Regime-aware ATR multipliers (HL perps).** With `regime.enabled: true`, four close-strategy \u002F stop-loss surfaces can resolve their ATR multiplier per regime label instead of using a fixed scalar: `stop_loss_atr_regime`, `trailing_stop_atr_regime` (strategy-level), and `tiered_tp_atr_regime` \u002F `tiered_tp_atr_live_regime` (close-strategy refs). Operators opt in by swapping the scalar field for the `*_regime` sibling. `{\"use_defaults\": true}` expands to a baseline table (trending: tighter SL \u002F wider TP; ranging: opposite); explicit form is `{\"trend_regime\": {\"trending_up\": {\"atr\": 2.0}, \"trending_down\": {\"atr\": 2.0}, \"ranging\": {\"atr\": 1.5}}}` (all three labels required). The regime is frozen at open via `pos.Regime` for stop and `_regime` TP refs; `tiered_tp_atr_live_regime` re-resolves each tick.\n\n### Correlation Tracking\n\nOpt-in via `correlation.enabled: true`. Warns when a single asset exceeds `max_concentration_pct` (default 60) of portfolio gross exposure or `max_same_direction_pct` (default 75) of strategies on an asset share a direction. Warnings go to active Discord channels and the owner DM; snapshot also available at `\u002Fstatus`.\n\n### Auto-Update & DM Upgrades\n\n`auto_update`: `\"off\"` (default), `\"daily\"`, or `\"heartbeat\"` (every cycle). When an update is found, all active Discord channels are notified; if `discord.owner_id` is set, the bot also DMs you `Would you like me to upgrade automatically? (yes\u002Fno)`. Reply **yes** → it runs `scripts\u002Fupdate.sh` (git pull → uv sync → go build) and restarts itself.\n\nAfter an upgrade, any new config fields introduced since your `config_version` are collected via DM (10-minute reply window per field) and written back to `config.json` atomically.\n\nDiscord user ID: right-click your username → **Copy User ID** (Developer Mode: Settings → Advanced).\n\n### Discord Settings\n\n| Field | Description |\n|---|---|\n| `discord.enabled` | Toggle Discord notifications |\n| `discord.token` | Leave blank — set `DISCORD_BOT_TOKEN` env var |\n| `discord.owner_id` | Discord user ID for DM upgrade prompts + post-upgrade config migration (env: `DISCORD_OWNER_ID`) |\n| `discord.channels` | Map of channel IDs keyed by `spot` \u002F `options` \u002F `\u003Cplatform>` \u002F `\u003Cplatform>-paper` |\n| `discord.trade_alert_channels` | Optional override routing trade-fill alerts to a separate channel; `stratType` keys (e.g. `perps`) reroute that type across all platforms. SIGHUP-reloadable. |\n| `telegram.trade_alert_channels` | Same override for Telegram |\n\n### Summary Frequency\n\nTop-level `summary_frequency` map keyed by channel name controls per-channel cadence. Trades always force an immediate post.\n\n```json\n{ \"summary_frequency\": { \"spot\": \"hourly\", \"hyperliquid\": \"every\", \"topstep\": \"30m\" } }\n```\n\nValues: `every` \u002F `per_check` \u002F `always` (every cycle), `hourly`, `daily`, Go durations like `30m` \u002F `2h`, or `\"\"` (legacy: options\u002Fperps\u002Ffutures every cycle, spot hourly). Wall-clock based and persisted in SQLite, so restarts and SIGHUP reloads don't reset the throttle.\n\n### Strategy Entry\n\n| Field | Description | Default |\n|---|---|---|\n| `id` | Unique identifier (e.g. `hl-momentum-btc`) | required |\n| `type` | `spot` \u002F `options` \u002F `perps` \u002F `futures` \u002F `manual` (HL hand-placed positions) | required |\n| `platform` | `binanceus` \u002F `deribit` \u002F `ibkr` \u002F `hyperliquid` \u002F `topstep` \u002F `robinhood` \u002F `okx` \u002F `luno` | required |\n| `script`, `args` | Python entry-point + argv (auto-filled for `manual`) | required |\n| `capital` | Starting capital in USD | 1000 |\n| `max_drawdown_pct` | Per-strategy CB; peak-relative (spot\u002Foptions\u002Ffutures), margin-relative (perps) | spot 5, options 10, perps 5 |\n| `interval_seconds` | Check interval (0 → global) | 0 |\n| `htf_filter` | Higher-timeframe trend filter | false |\n| `open_strategy` | Co-located ref `{name, params}` overriding the entry; falls back to `args[0]` | null |\n| `close_strategies` | Ordered `[{name, params}, …]`; largest `close_fraction` per cycle wins | null |\n| `leverage` | Perps — exchange leverage (also sizing if `sizing_leverage` omitted) | 1 |\n| `sizing_leverage` | Perps — order sizing multiplier (`cash × sizing_leverage`); separate from exchange leverage | `leverage` |\n| `margin_per_trade_usd` | HL perps — notional becomes `min(margin_per_trade_usd, cash) × leverage` | omitted |\n| `stop_loss_pct` \u002F `stop_loss_margin_pct` \u002F `stop_loss_atr_mult` \u002F `trailing_stop_pct` \u002F `trailing_stop_atr_mult` | HL perps — pick at most one positive value. Margin variant divides by `leverage`; ATR variants arm at open from `entry_atr`; trailing stops cap at 50% and debounce via `trailing_stop_min_move_pct`. All five omitted → scheduler arms `default_stop_loss_atr_mult * entry_atr`; explicit `0` opts out. | omitted |\n| `trailing_stop_min_move_pct` | HL trailing stop — minimum move before cancel\u002Freplace (HL caps OIDs at 1000) | 0.5 |\n| `margin_mode` | HL perps — `isolated` \u002F `cross`; applied from flat only | `isolated` |\n| `direction` | Perps — `long` \u002F `short` \u002F `both`; legacy `allow_shorts` migrates automatically | `long` |\n| `allowed_regimes` | Whitelist of regime labels for new entries (closes always run); requires `regime.enabled` | (no gate) |\n| `theta_harvest` | Early-exit config for sold options | null |\n\n### Custom Strategy Parameters\n\nPer-strategy `params` is merged with the strategy's built-in defaults (config keys override). Runtime data (e.g. funding rates) wins over config params.\n\n```json\n{ \"id\": \"ts-st-es\", \"type\": \"futures\", \"platform\": \"topstep\",\n  \"script\": \"shared_scripts\u002Fcheck_topstep.py\",\n  \"args\": [\"supertrend\", \"ES\", \"5m\", \"--mode=paper\"],\n  \"params\": {\"multiplier\": 2.0, \"atr_period\": 10} }\n```\n\n### Theta Harvesting (Options)\n\nCloses sold options early. `profit_target_pct` (% of premium captured), `stop_loss_pct` (% of premium lost, e.g. `200` = 2× premium), `min_dte_close` (force-close inside N days to expiry).\n\n```json\n{ \"theta_harvest\": { \"enabled\": true, \"profit_target_pct\": 60, \"stop_loss_pct\": 200, \"min_dte_close\": 3 } }\n```\n\n---\n\n## Manual Trading on Hyperliquid\n\nFor hand-placed positions (or TradingView alerts) tracked by the scheduler for P&L, stops\u002FTPs, and Discord summaries, declare a `type: \"manual\"` strategy and use:\n\n```bash\n.\u002Fgo-trader manual-open  hl-manual-btc                                          # defaults: --side long --margin 50\n.\u002Fgo-trader manual-open  hl-manual-btc --side long  --notional 500 --atr 250\n.\u002Fgo-trader manual-open  hl-manual-btc --side short --size 0.05 --record-only --fill-price 64500\n.\u002Fgo-trader manual-close hl-manual-btc [--qty 0.025]\n```\n\nSizing flags are mutually exclusive (`--size` \u002F `--notional` \u002F `--margin`); when all three are omitted (and not `--record-only`), `--margin 50` is auto-applied. `--side` defaults to `long`. Omitting `--atr` auto-fetches ATR(14) from Hyperliquid OHLCV for the strategy's symbol+timeframe; a leverage-aware fallback (`0.1 * fill_price \u002F leverage`) is used only if the fetch fails. SL + N-tier TPs are placed inline so the position is never naked; on queue-insert failure the scheduler auto-flattens and cancels the protective orders. `type=manual` strategies with no stop fields default to `stop_loss_atr_mult = 1.5×`. All four defaults (margin, SL multiplier, side, TP tiers) are overridable via an optional top-level `manual_defaults` config block (hot-reloadable via SIGHUP).\n\n---\n\n## Backfilling Hyperliquid Fees\n\nHistorical `exchange_fee = 0` rows can be rewritten from Hyperliquid `userFills`:\n\n```bash\n.\u002Fgo-trader backfill hl-fees --strategy hl-btc-momentum               # dry-run, single strategy\n.\u002Fgo-trader backfill hl-fees --all                                     # dry-run, all HL strategies\n.\u002Fgo-trader backfill hl-fees --strategy hl-btc-momentum --apply        # apply changes\n.\u002Fgo-trader backfill hl-fees --all --apply --reset-cash                # also replay strategies.cash\n```\n\n`--apply` refuses to run while another `go-trader` process is alive on the same DB.\n\n---\n\n## Build & Deploy\n\nThe canonical update path is `scripts\u002Fupdate.sh` — `git pull --ff-only` → `uv sync` → `go build` (version-stamped) → atomic binary swap → optional restart with `\u002Fhealth`-and-PID verify and automatic rollback to the previous binary on failed restart. If `go` is not on `PATH`, the script tries common install locations (`\u002Fopt\u002Fhomebrew\u002Fbin\u002Fgo`, then `\u002Fusr\u002Flocal\u002Fgo\u002Fbin\u002Fgo`). With `--restart`, it warns when systemd's `ExecStart` binary is not the same file as this checkout's `.\u002Fgo-trader`, so you can catch a unit pointed at the wrong path before assuming the upgrade took effect. A startup compatibility probe refuses to launch on a Go\u002FPython version mismatch, so prefer the script over hand-rolled rebuilds. `systemctl restart` drains gracefully (in-flight `--execute` \u002F close orders complete; read-only checks cancel immediately) and exits within ~20s instead of hanging on systemd's SIGKILL.\n\nTwo restart modes are supported:\n- **`--restart-mode systemd`** (default) — `sudo systemctl restart \u003Cunit>`, polls `systemctl is-active` + `\u002Fhealth`.\n- **`--restart-mode signal`** — for Linux bare-process deploys without systemd. SIGTERMs the PID from a pidfile (`.\u002Fgo-trader.pid` by default), then respawns via a wrapper script (`.\u002Frun.sh` by default) with the same `\u002Fhealth`+PID verify and rollback. Generate a starter wrapper with `bash scripts\u002Fcreate-run-sh.sh`.\n\nUse `--all` to batch-update all `go-trader-*\u002F` sibling directories in one pass (requires `--restart`).\n\n```bash\nsudo bash scripts\u002Fupdate.sh --restart                  # systemd deploy\nbash scripts\u002Fupdate.sh --restart --restart-mode signal # bare-process deploy\nbash scripts\u002Fupdate.sh --all --restart                 # update all instances\nbash scripts\u002Fupdate.sh                                 # build only, no restart\n```\n\n| Change | Action |\n|--------|--------|\n| Go or Python source | `sudo bash scripts\u002Fupdate.sh --restart` |\n| Config (hot-reloadable subset) | `systemctl kill -s HUP go-trader` — applies capital\u002Fdrawdown\u002Fintervals\u002Fparams\u002Frisk knobs\u002Fchannels\u002F`allowed_regimes` in place; rejects shape changes (strategy add\u002Fremove, type\u002Fplatform, leverage\u002F`direction` with open positions) |\n| Config (roster, script\u002Fargs\u002Ftype\u002Fplatform, `regime` block) | `systemctl restart go-trader` |\n| Service file | `systemctl daemon-reload && systemctl restart go-trader` |\n\n---\n\n## Monitoring\n\n```bash\nsystemctl status go-trader              # service health\ncurl -s localhost:8099\u002Fstatus            # live prices + P&L (default port 8099; override with --status-port)\ncurl -s localhost:8099\u002Fhealth            # simple health check\nopen http:\u002F\u002Flocalhost:8099\u002Fdashboard     # local dashboard with strategy charts and trade markers\njournalctl -u go-trader -n 50           # recent logs\n.\u002Fgo-trader inspect \u003Cstrategy-id>        # effective post-migration config (resolved SL\u002FTP + provenance)\n.\u002Fgo-trader inspect --all --json         # all strategies, machine-readable\n```\n\nThe dashboard is served by the same loopback-only status server as `\u002Fstatus` and `\u002Fhealth` (Go binds `localhost:\u003Cport>` — use `http:\u002F\u002F127.0.0.1:\u003Cport>\u002Fdashboard` or `http:\u002F\u002Flocalhost:\u003Cport>\u002Fdashboard`). If `status_token` is configured, the page prompts for that token and stores it in browser local storage for API calls. Prefer leaving each instance on loopback and reaching it through your VPN or reverse proxy; do not widen the bind to `0.0.0.0` just for remote viewing.\n\n### Remote dashboard (Tailscale Serve)\n\nOn a host with [Tailscale](https:\u002F\u002Ftailscale.com\u002F), [Tailscale Serve](https:\u002F\u002Ftailscale.com\u002Fkb\u002F1242\u002Ftailscale-serve) can publish HTTPS on the tailnet while go-trader stays on loopback. That avoids exposing the status port on a public interface and keeps go-trader’s dashboard separate from the **OpenClaw** web UI (different process, ports, and URL paths — do not assume they are the same dashboard).\n\nExample: one HTTPS port per go-trader instance (adjust ports to match each deployment’s `status_port`):\n\n| Instance \u002F role (example) | Typical `status_port` |\n|----------------------------|------------------------|\n| live | 8099 |\n| paper-testing | 8100 |\n| paper-hl-btc | 8101 |\n| paper-hl-eth | 8102 |\n| paper-hl-bnb | 8103 |\n| paper-hl-sol | 8104 |\n\n```bash\ntailscale serve --bg --https=8443 http:\u002F\u002F127.0.0.1:8099\ntailscale serve --bg --https=8444 http:\u002F\u002F127.0.0.1:8100\n```\n\nThen open `https:\u002F\u002F\u003Cnode>.tailnet.ts.net:8443\u002Fdashboard` (and `:8444\u002Fdashboard`, etc.) from another machine on the tailnet. Use Serve’s access controls as needed; `status_token` still applies to API calls from the dashboard page.\n\n`inspect` is read-only and safe to run against a live deployment — it loads `scheduler\u002Fconfig.json`, applies migrations and defaults, and prints which `stop_loss_*` field won, the resolved tier list on the configured TP close ref, and explicit-vs-default markers from the raw JSON. Use it to diagnose why a strategy isn't behaving like the JSON suggests, or to verify a config edit before SIGHUP.\n\nDiscord strategy summaries show columns `Init | Value | PnL | PnL% | DD | Wallet% | Tf | Int | #T | W\u002FL` plus a `Book Sharpe (realized, annualized)` footer and the go-trader version + PID in the title. `okx-options` and `robinhood-options` channel keys route options summaries separately from spot\u002Fperps. `#T`\u002F`W\u002FL` come from the SQLite trades table; partial closes collapse into one round trip per position.\n\nOpen-position lines append `SL: $\u003Ctrigger_px> (\u003Csigned_pct>%)` when a Hyperliquid stop-loss trigger is set (percent sign-flipped for shorts so it always reads as the loss if hit), `\u003CN>x ($\u003Cmargin> margin)` for leveraged perps, and tier marks (`✓`) for filled TP rungs. Each TP price includes the configured ATR multiple in parentheses (for example `12345.6 (2x)`), matching trade-alert formatting. Spot and 1× perps stay clean.\n\n---\n\n## Risk Management\n\n- **Portfolio kill switch** — halts trading at `portfolio_risk.max_drawdown_pct` (default 25); submits real close orders on HL \u002F OKX perps \u002F Robinhood crypto \u002F TopStep, clearing virtual state only after every platform confirms flat.\n- **Per-strategy circuit breakers** — pause on max-drawdown breach (24h cooldown); peak-relative for spot\u002Foptions\u002Ffutures, margin-relative for perps. HL\u002FOKX perps, Robinhood crypto, and TopStep CBs auto-close reduce-only; OKX spot and Robinhood options surface an `operator-required` warning every cycle until flattened by hand.\n- **Hyperliquid stop-loss** — exchange-side reduce-only trigger via one of `stop_loss_pct` \u002F `stop_loss_margin_pct` \u002F `stop_loss_atr_mult` \u002F `trailing_stop_pct` \u002F `trailing_stop_atr_mult` (mutually exclusive when positive). All five omitted → fixed ATR stop at `default_stop_loss_atr_mult * entry_atr` (default `1.0`); explicit `0` opts out. Trailing stops debounce via `trailing_stop_min_move_pct` to stay under HL's 1000-OID cap.\n- **On-chain N-tier TP\u002FSL ladders** — `tiered_tp_atr` \u002F `tiered_tp_atr_live` close evaluators place reduce-only TPs at configured ATR multiples (default `[{1×, 0.5}, {2×, 1.0}]`); final tier absorbs rounding dust. Full close cancels all SL+TP OIDs in one shot.\n- **Regime gate** — per-strategy `allowed_regimes` blocks new entries outside the whitelist; closes always run.\n- **HL margin mode** — defaults to `isolated`; override with `margin_mode: \"cross\"` (applied from flat only).\n- **Misc** — notional cap (`portfolio_risk.max_notional_usd`); correlation warnings (opt-in); 5 consecutive losses → 1h pause; spot max 95% capital per position; options max 4 positions per strategy with portfolio-aware scoring; theta harvesting on sold options.\n\n---\n\n## TradingView Export\n\nExport SQLite trades to a TradingView portfolio-import CSV. `--strategy` is repeatable; `--all` exports everything.\n\n```bash\n.\u002Fgo-trader export tradingview --strategy hl-btc-momentum --output tv-hl-btc.csv\n.\u002Fgo-trader export tradingview --all --output tv-all.csv\n```\n\nBuilt-in mappings cover known OKX\u002FBinanceUS pairs; add `tradingview_export.symbol_overrides: { \"hl:BTC\": \"BYBIT:BTCUSDT\" }` for the rest. CB close trades are included.\n\n---\n\n## Trading Fees\n\n| Market | Fee | Slippage |\n|--------|-----|----------|\n| Binance US Spot | 0.1% taker | ±0.05% |\n| Deribit Options | 0.03% of premium | — |\n| IBKR\u002FCME Options | $0.25\u002Fcontract | — |\n| Hyperliquid Perps | 0.035% taker | ±0.05% |\n| TopStep Futures | Per-contract (configurable) | ±0.05% |\n| Robinhood Crypto | No commission (spread embedded) | ±0.05% |\n| Robinhood Options | $0.03\u002Fcontract (regulatory fee) | — |\n\nLive `--execute` fills on Hyperliquid \u002F OKX \u002F Robinhood \u002F TopStep record the exchange-reported fee plus order ID, so backfills and TradingView exports match the venue ledger.\n\n---\n\n## Layout & Dependencies\n\n`scheduler\u002F` (Go: config, state DB, HTTP status, risk, notifications) · `shared_scripts\u002F` (Python entry points) · `platforms\u002F` (exchange adapters) · `shared_tools\u002F`, `shared_strategies\u002F` (registry + impls) · `backtest\u002F` · `systemd\u002F`, `scripts\u002F` · `SKILL.md`, `AGENTS.md` (agent guides).\n\nPython 3.12+ via [uv](https:\u002F\u002Fgithub.com\u002Fastral-sh\u002Fuv) (ccxt, pandas, numpy, scipy, hyperliquid-python-sdk); Go 1.26.2 with [`bwmarrin\u002Fdiscordgo`](https:\u002F\u002Fgithub.com\u002Fbwmarrin\u002Fdiscordgo); systemd.\n\n---\n\n## Troubleshooting\n\n| Problem | Solution |\n|---|---|\n| No Discord messages | Check `DISCORD_BOT_TOKEN`, channel IDs, bot permissions |\n| Service won't start | `journalctl -u go-trader -n 50` |\n| Didn't come back after reboot | Unit installed but not enabled — re-run `sudo bash scripts\u002Finstall-service.sh` |\n| Strategy not trading | Check circuit breaker in `\u002Fstatus`, verify params |\n| Reset positions | `rm scheduler\u002Fstate.db && systemctl restart go-trader` |\n| Live mode fails | Set the env vars listed in the Platforms table for that platform |\n| \"state DB missing but live strategies configured\" | Update wiped the repo dir instead of `git pull`. Restore `scheduler\u002Fstate.db` from backup, or set `GO_TRADER_ALLOW_MISSING_STATE=1` for a genuine first-run deployment. |\n\n---\n\n## Risk Disclaimer\n\nThis software is provided for informational and educational purposes only and does not constitute financial advice. Trading involves substantial risk of loss; past performance is not indicative of future results. The authors make no guarantees regarding accuracy, profitability, or outcomes, and accept no liability for any losses incurred. You are solely responsible for your investment decisions — only trade with funds you can afford to lose.\n\n*This is not financial advice. Trade at your own risk.*\n","go-trader 是一个加密货币交易机器人，支持回测、模拟交易和实盘交易，并具备风险管理功能。项目采用 Go 语言编写，通过启动短暂的 Python 脚本来管理超过 50 种策略，覆盖现货、期权、永续合约及 CME 期货等多种市场类型。该系统设计紧凑，单个 Go 可执行文件在空闲时仅占用约 8MB 内存，适合部署于对资源消耗敏感的环境。此外，它还支持多种交易平台如 Binance US、Deribit 等，并能够通过 Discord 或 Telegram 渠道发送交易通知与摘要。适用于需要自动化执行复杂交易策略同时保持较低运维成本的专业投资者或机构。",2,"2026-06-11 03:53:25","trending"]