astra-quant-agent README

项目的 README,来自 github.com/0xethanq/astra-quant-agent。合并为一个 markdown 文件:README.md。

AstraQuant

Self-Hosted OKX Perpetuals AI Quant Decision & Execution System

License Python Vue 3 OKX V5 Version

English · 简体中文 · 3-Site Hub (astraquant.top) · OKX Terminal (okx.astraquant.top) · Sister Skills Hub (tradeskill.si)


AstraQuant Live Dashboard


Overview

AstraQuant is a self-hosted algorithmic trading and operations system built natively for OKX USDT-Margined Perpetuals (OKX V5 API). It pairs deterministic Python microstructure analysis and hard risk interlocks with configurable LLM reasoning — backed by an interactive Web workstation and a conversational Control Plane.


Visual Tour (v9.2.0)

Live Trading Workstation
Live Workstation
AI Assistant & Atomic Diff Proposals
AI Assistant Console
Strategy Config & Smart Order Routing
Strategy Config
AI Decisions Timeline
AI Decisions
Chain-of-Thought Audit Drawer
CoT Audit Drawer
Closed-Loop Strategy Review
Strategy Review
Trade Ledger & Lifecycle
Trade Ledger
Market Intelligence & Long/Short Ratio
Market News

Core Architecture

OKX V5 (Candles · Orderbook · Funding · OI · Positions)
   │
   ▼
7-Tier Quantitative Factor Matrix (backend/scripts/market_radar.py)
   │  Multi-timeframe trend (4H/1H/15M), VWAP value area, CVD divergence, orderbook imbalance
   ▼
AI Decision Engine (backend/scripts/ai_brain_trader.py)
   │  Single primary LLM or optional Multi-Model Council (Macro / Tech / Risk / CIO)
   ▼
32-Param Fail-Closed Risk Engine (backend/scripts/risk_constants.py)
   │  1R risk budget · leverage caps · min R:R · daily loss circuit breaker · cooldown · DEMO gate
   ▼
Execution & Cloud Protection (backend/scripts/trader/)
   │  Smart hybrid (Post-Only maker -> IOC fallback) · Limit · Market
   │  Two-leg Scale-Out (TP1 partial close + SL to breakeven + TP2 runner) · Cloud OCO Algo orders
   ▼
Closed-Loop Operations (/admin/agent · /lab)
      Trade attrition review, structured experience rules, conversational Agent diagnostics & rollback

Key Capabilities in v9.2.0

  1. Conversational AI Assistant (/admin/agent): Inspects live positions, 48-cycle order funnel drop-offs, risk conflicts, and runtime logs via read-only tools. Every configuration change is staged as a visual Key-Value Diff Proposal card with an automatic Pre-Apply Policy Snapshot and 1-Click Rollback.
  2. Unified 5-Tab Strategy Config (/admin/strategy):
    • Risk & Orders: 3 preset risk suites (conservative, balanced, aggressive), limit / market / smart hybrid order routing, Scale-Out (TP1/TP2 + breakeven SL) toggle, and 32 validated physics risk gates.
    • Model Council: Enable or bypass multi-seat deliberation (Macro, Tech, Risk, CIO) with per-seat model binding, reasoning effort, and fallback to single primary model.
    • Prompts: Modular system/user prompt pipeline editor with locked safety cores and versioned profiles.
    • Memory & Review: Automated post-trade attribution (self_improvement_engine.py) and toggleable experience rules injected back into future prompts.
    • Windows & Jobs: UTC+8 trading-session gates and on-demand manual maintenance jobs.
  3. Hard DEMO / LIVE Isolation: Separate encrypted keystores and .env execution gates ensure simulated paper accounts (DEMO) can never accidentally submit real mainnet orders.

Supporting AstraQuant through OKX order attribution

AstraQuant takes ongoing work to develop, test, document, and host. Thank you for supporting the project. OKX order attribution is on by default when there is no saved preference. While enabled, new orders carry the project code and OKX may pay the project a rebate on eligible trades. The account signup invitation is managed separately, and account fees follow OKX rules.

A superadmin can review the beneficiary and code and turn attribution off at any time under Account Access → OKX Broker Attribution. DEMO and LIVE preferences are separate. Turning it off omits the code on later requests, including protection orders and emergency closes. OKX continues to manage orders it has already accepted.

Upgrades preserve existing settings, including saved opt-outs. Portable backups exclude this preference file. A new installation restored from a backup alone starts with the default, so review the setting before trading.

Quick Start

git clone https://github.com/0xethanq/astra-quant-agent.git
cd astra-quant-agent

# Copy default template (defaults to OKX DEMO paper mode)
cp backend/env.example backend/.env
chmod 600 backend/.env

# Optional: run interactive initialization wizard
python3 backend/scripts/setup_wizard.py

# Start backend + watchdog + gateway
ASTRA_BUILD_REVISION="$(git rev-parse HEAD)" docker compose up -d --build

Open http://127.0.0.1:8080:

The admin version page compares the running image's commit with GitHub main. To deploy a newer commit, rebuild the backend and gateway images from a clean host checkout using the same build command.

2. Local Standalone Development

See STANDALONE.md for running Python + Vite without Docker and RECOVERY_GUIDE.md for daemon & database recovery procedures.


Sister Project: TradeSkill (OKX 20% Fee Rebate & AI IDE Skills)

Looking to query markets or place trades directly inside Claude Code, Cursor, Codex, or Windsurf, or reduce OKX perpetual fees?

Sister Single-Venue Editions & Live Terminals

Edition Live Terminal GitHub Repository TradeSkill Companion
AstraQuant · OKX V5 okx.astraquant.top 0xethanq/astra-quant-agent OKX Skills · 20% Rebate
AstraQuant · Gate V4 gate.astraquant.top 0xethanq/astra-quant-gate Gate Skills · 20% Rebate
AstraQuant · Binance USDⓈ-M bn.astraquant.top 0xethanq/astra-quant-binance Binance Skills · 20% Rebate
AstraQuant · 3-Site Hub astraquant.top 0xethanq/astra-quant-agent Unified Portal · TradeSkill
TradeSkill Hub tradeskill.si 0xethanq/crypto-trading-skills 164 Skills & Calculator

Repository Layout

astra-quant-agent/
├── backend/
│   ├── astra_backend/       # FastAPI control plane, Agent console, LLM hub, risk & backup APIs
│   ├── astra_gateway/       # Encrypted secrets vault, notification channels & backup supervisor
│   ├── scripts/             # Core quant loop, 7-tier market radar, execution & evolution engine
│   ├── docs/images/         # Documentation screenshots served at /images/* and /docs/images/*
│   └── tests/               # Offline pytest/unittest audit, trading, UI, LLM & ops suites
├── frontend/
│   ├── src/views/dashboard/ # Public terminal views (/, /factors, /news, /lab, /history)
│   ├── src/views/admin/     # Admin workbench (/admin/agent, /admin/strategy, /admin/llm, ...)
│   ├── src/views/docs/      # Interactive in-app user manual (/docs)
│   └── tests/               # Frontend design parity, i18n copy & dead-UI Node test gates
├── Dockerfile               # Multi-stage Node 26 + Python 3.14 production build
└── docker-compose.yml       # Single-host deployment orchestration

Code map

Entry-point guides inside each subsystem:

Notice: OPENCODE.md does not exist in this repository and was never contained here. Start from the subsystem READMEs below.

File Purpose
backend/astra_backend/README.md Backend layering & subsystem placement rules (L0-L3, routers vs domain services)
backend/scripts/README.md Runtime scripts & daemons entrypoints (ai_brain_trader, market_radar, trader/)
frontend/src/components/admin/README.md Frontend components & state conventions, composables, and design gates
RECOVERY_GUIDE.md Emergency stop, process restart, and ledger recovery commands

Automated doc & test baseline gates:


Brand & codename

The public product name is AstraQuant and the internal codebase prefix is astra (astra_backend, astra_gateway, ASTRA_*). Intentional historical markers retained solely for backward compatibility with existing exchange orders and encrypted backups:


License & Disclaimer

Licensed under GNU AGPL-3.0 + Commons Clause v1.0 + Anti-Scam Special Addendum — personal/internal quant usage and transparent auditing are free; unauthorized commercial resale, SaaS hosting, or fraudulent signal schemes are prohibited.

Risk Disclosure: Algorithmic cryptocurrency futures trading carries significant financial risk. Start in OKX DEMO simulated mode, validate risk parameters and stop-loss protection before committing real capital, and never expose admin tokens or API keys publicly.

astra-quant-agent (0xethanq/astra-quant-agent)

正在搜索数据库…

这是什么?R20 Quantum Trading System 是一个自主的加密货币交易 agent,它用一个由多个 LLM(Claude、GPT-4o、DeepSeek、Gemini 等)组成的委员会来分析市场并提出交易建议,同时由一个独立的确定性 Python 层执行硬性风险规则并在 OKX 上下单。
AI 是真的在下单,还是只是提建议?LLM 委员会只有 “提议权”——每笔订单仍必须先通过基于 Python 的 Fail-Closed 物理拦截层才能下达,该层会检查几何有效性、R:R >= 2.0、4H 趋势否决以及同方向持仓上限。
怎么让它跑起来?系统不设默认提供商,你要为自己想用的模型提供商自行配置 LLM_BASE_URL/OPENAI_BASE_URL 和 LLM_API_KEY,然后先以模拟模式对接 OKX 启动系统。
需要我自己的 LLM API 密钥和 OKX 账户吗?需要——系统不带任何内置的默认中转网关,所以你必须明确配置自己的 LLM 端点/密钥(OpenAI 兼容、直连提供商或自建中转)以及用于执行的 OKX 账户。
直接切换到实盘交易安全吗?不安全——它默认处于 OKX 的 demo/模拟模式,必须由你显式切换到实盘;即便如此,17 道执行层风险闸门(置信度阈值、ADX 过滤、R:R 下限、日亏损熔断等)仍可能强制交易进入 WAIT 状态。
自我进化功能实际做什么?系统每 6 小时复盘真实的已平仓交易,把胜率和盈利因子的经验提炼进 AI_TRADING_MEMORY.md 文件,反馈到之后的每一次决策,并设有防范离群噪音的护栏和 7-14 天的半衰期,让过时的经验逐步被淘汰。
多模型投资委员会(Council Pro)是什么?你可以自由增减顾问席位(动量、风险、量化、宏观、情绪或自定义专家),把每个席位绑定到不同的 LLM 提供商和温度参数,让它们跨多轮辩论,最后由一个 CIO 模型发出最终的结构化订单。
策略改动出了问题能回滚吗?每一份完整配置(提示词、拦截器插件、委员会席位和风险参数)都会用 SHA-256 生成指纹并存档为命名快照,所以你可以在约 0.5 秒内原子化地回滚到任意历史版本。
它交易哪个交易所、哪些品种?它通过一个可配置的品种池(data/instrument_pool.json)交易 OKX 的永续合约,因此不受限于固定的币种集合。
作者
0xethanq
大小
50.8 MB
星标
422
时长
3个月
提交 · 90 天