Self-Hosted, Governed Multi-Market Strategy-Research Agent Runtime · Autonomous Research & Evolution Loop
🌐 English · 🇨🇳 中文说明 · Architecture Overview · System Architecture · Pluggable Market Targets · RD-Agent Evolution · QuantLab & A-Share Rules · Production Probes & Tokens · External Ground Truth · Product Spec
HyperTrade is a self-hosted, governed Agent runtime for quantitative strategy research and autonomous evolution. It transforms natural-language research goals into verifiable Missions constrained by permissions, budgets, evidence, and human review. The ARC autonomous research loop (powered by Microsoft RD-Agent Hypothesis Evolution Trees and Co-STEER structured synthesis) proposes candidate strategies, tests them via isolated sandboxes and same-window baselines, and deploys them to target paper trading environments (BitPro for Crypto SWAP and QuantLab for A-Shares / multi-asset equities). In production, an always-on evolution engine continuously scans for benchmark-relative performance decay, triggers targeted re-research, and performs position netting smooth relay handovers during strategy promotion, saving >80% in turnover friction.
Four core principles:
-
Governed, never self-authorizing. The model only produces schema-bounded plans and code; permissions, approvals, budgets, and risk gates are validated independently before and after execution. Mainnet live trading is hard-blocked (
live_allowed=false); external writes target only authorized paper trading instances. -
Pluggable markets with native microstructure enforcement. The core evolution engine is completely decoupled from underlying trading platforms via
market_target.v1profiles andmarket-evolution.v1MCP contracts. For Chinese A-shares, hard institutional rules are strictly enforced across Prompt and ASTGatekeeper levels: T+1 settlement state machine, spot long-only enforcement (no naked shorting), price limit band liquidity cutoffs, 100-share lot size constraints, and institutional friction models (0.05% stamp duty, transfer fees, commissions, and slippage). -
Hypothesis-driven scientific evolution with minimal friction. Integrates RD-Agent's Hypothesis Evolution Tree (HET) for genealogical tracking and explicit hypothesis pruning. During champion-challenger promotions, two-leg position netting (
$\Delta = C - P$ ) preserves common holdings$\min(P_i, C_i)$ , cutting turnover costs by over 80%. - External selection pressure with third-party Ground Truth. Integrates external forward-only prediction arenas (Headline Arena) for objective real-price settlement and Brier scoring, supplying ARC simulation incubation and causal attribution with unpolluted external truth signals.
-
Zero-trust credential governance and cloud-native observability. Production container health probes (
/livez,/readyz,/healthz) provide granular diagnostics for Kubernetes and load balancers.TokenRotationServiceprovides SHA-256 hashed credentials, zero plaintext persistence, granular scopes, and zero-downtime 24-hour grace period hot rotation.
It is not an automated money maker, promises no profitability, and does not provide investment advice.
flowchart LR
Op["Operator / External Agent<br/>Web · ht CLI · TUI · Desktop"] --> API["FastAPI Control Plane<br/>Mission · TokenManager · Probes (/livez, /readyz, /healthz)"]
API --> DB[("PostgreSQL + pgvector<br/>50 migrations · Mission projections · HET tree · Memory")]
Worker["Worker Loops (13 Loops)<br/>Mission · AVO research · evolution · auto-review · meta-tuning"] --> DB
Worker --> Research["ARC Autonomous Research Loop (AVO + RD-Agent)<br/>HET tree → Co-STEER synthesis → AST gatekeeper → sandbox → baseline"]
Worker --> Evolution["Evolution Engine (default on)<br/>decay / launch scan → budget admission → re-research or rule tweak → admission → race duel → ledger"]
Research --> Sandbox["Isolated Strategy Sandbox<br/>UDS · non-root · no network · digest-bound"]
Research --> Targets["Multi-Market Target Layer<br/>market_target.v1 · market-evolution.v1"]
Evolution --> Relay["Position Netting Relay Handover<br/>retain min(P,C) · >80% turnover saved · K slices"]
Relay --> Targets
Targets --> BitPro["BitPro Target<br/>Crypto SWAP · Market Data · Backtests · Paper"]
Targets --> QuantLab["QuantLab Target<br/>A-Shares · Vectorized Matrix Backtests · T+1 / Long-Only"]
External trading platforms remain the source of truth for their own domains. HyperTrade maintains only bounded references, digests, hashes, metrics, and audit projections, never replicating private platform logic or directly accessing private databases.
The source of truth for research tasks is the Mission (Plan / Step / Event / budgets / approvals / completion proof); interaction is driven by the server-owned Thread / Turn / Item protocol with resumable cursor SSE. External writes require one-shot parameter-bound approvals and write-ahead DispatchIntent records. The platform integrates TokenRotationService: credentials store only SHA-256 hashes, support granular scopes (arc:read, arc:start, etc.), seamless 24-hour grace periods during hot rotation, and proactive 7-day expiration audits.
Design docs: 30 Roadmap · 31 Technical Design · 67 Probes & Token Rotation
Extracts key methodologies from Microsoft RD-Agent:
- Hypothesis Evolution Tree (HET): Maintains complete hypothesis lineages from root to mutant branches, explicitly pruning underperforming or overfitted hypotheses.
- Co-STEER Structured Code Synthesis: Guides LLMs to generate modular features, signals, and sizing logic.
- ASTGatekeeper Syntax & Anti-Lookahead Gate: Statically scans AST nodes at compile time to block lookahead bias, future data leakage, and unauthorized system calls.
- Isolated Sandbox & Same-Window Baselines: Bounded UDS sandboxing with byte-identical time window comparisons.
Design docs: 65 RD-Agent Evolution & Layered Memory · 37 ARC Architecture · 61 Research Loop Rationalization
The evolution core decouples from execution platforms via market_target.v1 and market-evolution.v1:
- BitPro Target: 24/7 perpetual cryptocurrency swaps, dual-direction long/short.
- QuantLab Target: A-share equities;
QuantLabStrategyTranspilertranslates standard strategies into native vectorizedMatrixStrategymodules with isolated_BASE_EVO_SCAFFOLD. - Institutional Hard Rules: Prompt contexts and ASTGatekeeper strictly enforce T+1 settlement state machines, spot long-only enforcement (blocking
-1short signals), price limit bands, 100-share integer lot sizes, and exact institutional friction models (0.05% stamp duty, transfer fees, commissions).
Design docs: 62 Pluggable Market Targets · 66 QuantLab & A-Share Microstructure
Scans active incubating paper strategies hourly:
- Benchmark-Relative Decay Detection: Strategy performance change over 14 days minus benchmark buy-and-hold change prevents broader market drops from falsely flagging strategy decay.
-
Position Netting Relay Service: During strategy turnover, intersecting holdings
$\min(P_i, C_i)$ are preserved in place. Only net differences$\Delta = C - P$ are sliced and executed over$K$ periods with 100-share constraints, slashing turnover friction by >80%. - Effectiveness Ledger & Feishu Alerts: Full ledger accounting with automatic Feishu webhook card alerts for stalled data gaps and error streaks.
- Variant Supply for Every Parent (opt-in): once a paper parent has run 7 complete days it can receive variants before full decay evidence exists; exploration missions can use a deterministic one-step parameter-neighbour researcher, and a candidate that fails the strict final gate may still race if it is not clearly worse than its parent on the same window. Succession still requires winning the forward race.
Design docs: 63 Evolution Hardening · 66 Smooth Relay Handover
- Probe Matrix:
/livez(liveness),/readyz(readiness withSELECT 1DB probe),/healthz(comprehensive diagnostics with DB latency, adapter heartbeats, paper session counts, and token status), fully aligned with Kubernetes standards. - Quantum Portfolio Dashboard: React 19 UI with BitPro / QuantLab target switcher, dynamic A-share rule badges, interactive HET evolution tree visualization, and real-time relay handover slice stepping monitor.
Design docs: 67 Production Probes & Token Rotation
Source parameter proposals must bind verifiable citations, explicit counter-evidence, and net profit increase / drawdown reduction targets; merely decreasing trade count is not an improvement. Known execution failures settle separately as failed research and must not mutate further as trading performance. Source backtest comparisons require identical execution environments, costs, frozen market data, and economic inputs; formal Paper audits must match the final passing receipt and source code. Operator pauses cannot be overridden by stale receipts. Deployment health check disconnects perform bounded retries only for existing action receipts, halting after 5 failures or a 24-hour limit; audit recovery scripts can re-verify original bindings to resume deployment disconnect waits without replenishing budget or resetting Paper history.
Same-version interruptions resume original jobs; when execution environments or backend packages have changed, original frozen verifications are strictly preserved, creating linked new-version revalidations with identical economic inputs. Existing jobs and snapshots are never overwritten, and the recovery chain remains bounded by a 2-retry limit; known waiting states display as validating rather than prompting manual operator handling.
Research backtests durably save action checkpoints before and after external side effects: requests, attempts, source code, jobs, and frozen inputs are bound together; after disconnects, the original job is read, with interrupted jobs recovering up to 2 times, and failed/cancelled jobs never retried. After 5 consecutive read failures or a 24-hour wait, explicit reconciliation is demanded, and operator stops cannot be overwritten by recoverers. Deployment sequencing prioritizes BitPro durable idempotent interfaces.
flowchart LR
A[Research Action] --> J[(Durable Action Checkpoint)]
J --> B[Frozen Backtest Job]
B --> S{Real Status}
S -->|Running| J
S -->|Interrupted| R[Bounded Original Job Recovery]
R --> B
R -->|Version Invalidated| V[Linked Version Revalidation]
V --> B
S -->|Completed| Q[Compare Results with Parent]
S -->|Failed or Cancelled| F[Failure Evidence]
Deployments discover the BitPro host gateway from the active Docker network and verify DNS and authentication health requests for API/workers. Unknown development side effects converge only via exact external reconciliation receipts, never blindly retrying or falsely declaring success.
uv sync
docker compose up -d postgres
uv run alembic upgrade head
uv run uvicorn hypertrade.main:app --app-dir backend/src --reload --host 0.0.0.0 --port 3334API and 13 background worker loops start in the same process; workers can also run standalone:
uv run python -m hypertrade.workercd frontend && pnpm install && pnpm devcurl http://localhost:3334/livez
curl http://localhost:3334/readyz
curl http://localhost:3334/healthzQuery registered market targets:
curl http://localhost:3334/api/portfolio/targetsTrigger an autonomous cryptocurrency trend strategy research mission:
curl -X POST http://localhost:3334/api/v1/missions \
-H "Content-Type: application/json" \
-d '{
"goal": "Mine an adaptive trend-following strategy on BTC/USDT 1h with ATR trailing stops",
"market": "crypto",
"target_id": "bitpro-crypto-swap",
"budget": {"max_steps": 10, "max_llm_cost_usd": 2.0}
}'| Document | Focus |
|---|---|
| 00 Overview | System boundaries, domain separation, mission truth |
| 33 System Architecture | High-level topology, control and data plane separation |
| 66 QuantLab & A-Share Rules | A-share microstructure, T+1 state machines, relay handover |
| 67 Probes & Token Rotation | Production probe matrix (/livez, /readyz, /healthz) and token rotation |
| 65 RD-Agent Evolution & Memory | HET hypothesis trees, Co-STEER synthesis, FinMem memory |
| 64 Autonomous Trading Agent | Full autonomous agent architecture, feedback loops, risk gates |
| 62 Pluggable Market Targets | market_target.v1 profile and market-evolution.v1 MCP contracts |
| 63 Evolution Hardening | Effectiveness ledgers, data-gap alerts, benchmark-relative decay |
| Product Spec | Product scope, user journeys, acceptance criteria, non-goals |
| Progress Log | Current verified state and production evidence |
| Delivery Contracts | Sprint-by-sprint scope and technical contracts |
| Runbooks | Deployment, monitoring, and incident response |
| Developer Guide | Local development and extension guide |
ht research start "research goal" follows the research process with live events and activity panes. Use --detach to submit in background. Use ht research watch <mission-id> to reconnect.
We welcome community feedback, feature proposals, and code contributions!
- Discussions: Share ideas, research hypotheses, and questions in GitHub Discussions.
- Contributing Guide: Please review CONTRIBUTING.md and our Code of Conduct.
- Security Vulnerabilities: For responsible disclosure, refer to SECURITY.md.
- Roadmap: Track upcoming milestones and good first issues in Roadmap v0.2.0.
Open-source under MIT License. See LICENSE.
Disclaimer: Nothing in this repository constitutes investment advice. Mainnet live trading is strictly forbidden by risk governance (
live_allowed=false).
Legacy self-healing parameter proposals do not represent verified candidates. Verification fails when an immutable candidate backtest receipt is missing—parent strategy results are never borrowed, and neither success notifications nor Paper trading are initiated; standard ARC source variants, same-window verifications, and audit workflows remain responsible for automated R&D. The 7-dimensional attribution reuses execution evidence contracts; aggregated backtest metrics cannot deduce execution paths or causal conclusions; data-gap scans remain unavailable without generating synthetic candidates.
2026-10-15: ARC added a read-only summary endpoint GET /api/v1/arc/variant-status?source_strategy_id=…&candidate_strategy_id=…. Scoped to the BitPro target with exact parent/candidate binding, it projects only durable subfields and the most recent blocking event of currently impeded missions without reconstructing controllers or hydrating full events/model dialogs; permission remains arc:read. Queries search up to the parent's 100 most recent missions, returning not_found when unmatched (which does not represent audit approval).