astra-quant-agent README

The project's README from github.com/0xethanq/astra-quant-agent. As one markdown file: README.md.

AstraQuant

Self-Hosted OKX Perpetuals AI Quant Decision & Execution System

License Python Vue 3 OKX V5 Version

English · 简体中文 · Live Terminal (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.

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?


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)

Searching Database…

What is this?R20 Quantum Trading System is an autonomous crypto trading agent that uses a committee of multiple LLMs (Claude, GPT-4o, DeepSeek, Gemini, etc.) to analyze the market and propose trades, while a separate deterministic Python layer enforces hard risk rules and executes orders on OKX.
Is the AI actually placing trades, or just suggesting them?The LLM committee only has 'proposal rights' - every order still has to pass a Python-based Fail-Closed physical interceptor layer before it can be placed, checking geometric validity, R:R >= 2.0, the 4H trend veto, and same-direction position caps.
How do I get it running?Instead of a default provider, you configure LLM_BASE_URL/OPENAI_BASE_URL and LLM_API_KEY yourself for whichever model provider you want to use, then start the system against OKX in simulated mode first.
Do I need my own LLM API key and an OKX account?Yes - the system ships with no built-in default relay gateway, so you must explicitly configure your own LLM endpoint/key (OpenAI-compatible, direct provider, or self-hosted relay) and your own OKX account for execution.
Is it safe to switch straight to live trading?No - it defaults to OKX demo/simulated mode and you must explicitly switch it to live, and even then the 17 execution-layer risk gates (confidence threshold, ADX filter, R:R floor, daily-loss circuit breaker, etc.) can force trades into a WAIT state.
What does the self-evolution feature actually do?Every 6 hours the system reviews real closed trades and distills win-rate and profit-factor lessons into an AI_TRADING_MEMORY.md file that feeds back into every future decision, with guardrails against outlier noise and a 7-14 day half-life so stale lessons get phased out.
What is the multi-model investment committee (Council Pro)?You can freely add or remove advisor seats (momentum, risk, quant, macro, sentiment, or custom experts), bind each seat to a different LLM provider and temperature, and let them debate across rounds before a CIO model issues the final structured order.
Can I roll back if a strategy change goes wrong?Each full configuration (prompts, interceptor plugins, committee seats, and risk parameters) is fingerprinted with SHA-256 and archived as a named snapshot, so you can atomically roll back to any past version in about 0.5 seconds.
Which exchange and instruments does it trade?It trades OKX perpetual futures/contracts through a configurable instrument pool (data/instrument_pool.json), so you aren't limited to a fixed set of coins.
Creator
0xethanq
Size
50.8 MB
Stars
422
Age
3mo
Commits · 90 Days