Skip to content

feat(autoresearch): live trade bridge + all-symbol research (HCLI port 2/5) - #28

Open
JaeLeex wants to merge 1 commit into
mainfrom
feat/autoresearch-live-bridge
Open

feat(autoresearch): live trade bridge + all-symbol research (HCLI port 2/5)#28
JaeLeex wants to merge 1 commit into
mainfrom
feat/autoresearch-live-bridge

Conversation

@JaeLeex

@JaeLeex JaeLeex commented Jun 4, 2026

Copy link
Copy Markdown
Contributor

Part 2 of 5 of the HCLI → agent-cli port. Lets a user research → create → trade a strategy entirely from agent-cli, for crypto and BTCSWP + commodities. This is the foundation the House fleet (PR 3/5) builds on.

What's new

  • hl strategy load <name> — runs an autoresearch strategy LIVE. AutoBarStrategy bridges the hourly on_bar(bar_data, portfolio) -> [Signal] contract to the tick engine: folds 10s ticks into hourly bars, calls on_bar once per boundary (wall-clock OR tick-count fallback for replay/mock), holds target between bars, and translates each Signal.target_position (signed USD) into delta = target − context.position_notional → |delta|/mid IOC order. Faithful port of ACC server/src/strategy-deployer.ts.
  • hl strategy new|list|show|path|prepare — scaffold lifecycle.
  • hl autoresearch run <name> [--iterations] [--agent demo|llm] — the Karpathy loop (scaffold → baseline → propose → eval → keep/discard, results.tsv + JSONL event log) + status|results|tail. Ports the nunchi-cli worktree command + scaffold template.
  • cli/autotrader_bridge.py — Python port of ACC autotrader-bridge.ts results.tsv parser (best score/commit/#experiments).

All-symbol support (real coin names, discovered live — no fabrication)

The scaffold prepare.py gains an HIP-3 data adapter. Coin names were discovered from the live HL info API (perpDexs + meta/candleSnapshot), not guessed:

  • BTCSWPyex:BTCSWP (testnet-only; mainnet returns null — routed to the testnet endpoint).
  • Commodities (mainnet xyz dex, confirmed returning candles): xyz:GOLD, xyz:SILVER, xyz:COPPER, xyz:PLATINUM, xyz:PALLADIUM, xyz:NATGAS, xyz:BRENTOIL, xyz:CL (WTI). Listed-but-no-data yet (WHEAT/CORN/URANIUM/ALUMINIUM) documented as add-once-liquid.
  • Crypto (BTC/ETH/SOL) stays on CryptoCompare. Date splits made env-overridable (HIP-3 history is newer).

Guardrails (the live loop previously lacked these)

  • Drift detection — rolling live realized return/Sharpe vs the kept backtest score; warns on divergence.
  • Retrain trigger — one-shot retrain_callback; the runner writes a retrain.flag marker.
  • reduce_only / safe_mode — suppress new/added risk (reducing orders still allowed).

Verification (real, measured)

  • Imports clean; hl strategy + hl autoresearch + subcommands render.
  • autoresearch run smoke --iterations 1 --agent demo ran the full loop and wrote results.tsv.
  • strategy load smoke --mock --max-ticks 50 → bridge produced 15 orders, first fill = exactly 10% of $100k equity (sizing correct), 0 sent on held ticks.
  • Real downloads + backtests: GOLD 3923 bars, BTCSWP 2672 bars; crypto sanity backtest score 2.57. (Naive momentum scores poorly on commodities — that's what the research loop is for; the scoring pipeline is structurally sound for HIP-3 symbols.)

Notes

  • Based off main. Scaffold default keeps ACTIVE_SYMBOLS=[BTC,ETH,SOL]; commodities/BTCSWP are opt-in (data+adapter support all).
  • Builder fee auto-attaches on live orders via the unchanged place_order path (same as PR 1/5).

…t 2/5)

`hl strategy load` runs an autoresearch strategy live: AutoBarStrategy bridges the
hourly on_bar(bar_data, portfolio)->[Signal] contract to the tick engine (rolling
tick→hourly fold, on_bar once/boundary, target held between bars, signed-USD target
→ delta vs position_notional → IOC order). Faithful port of ACC strategy-deployer.ts.

`hl autoresearch run` ports the Karpathy loop (scaffold→baseline→propose→eval→
keep/discard, results.tsv + JSONL) + scaffold template; adds status/results/tail;
cli/autotrader_bridge.py results parser.

All-symbol research: scaffold prepare.py adds an HIP-3 data adapter for BTCSWP
(yex:BTCSWP, testnet) + commodities (xyz:GOLD/SILVER/COPPER/PLATINUM/PALLADIUM/
NATGAS/BRENTOIL/CL, mainnet) — coin names discovered live from the HL info API;
crypto stays on CryptoCompare. Real backtests run (GOLD 3923 bars, BTCSWP 2672).

Guardrails: live-vs-backtest drift detection, one-shot retrain hook,
reduce_only/safe_mode suppression.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant