Trading Systems Skill Graph
Knowledge distilled from 14+ open-source trading libraries into native
agent-utilities patterns. This skill graph provides structured reference
for all aspects of automated trading.
1. Exchange Backend Architecture
Pattern: Protocol-Based Backend Abstraction (CONCEPT:EX-AHE.harness.ee)
Every exchange backend implements the ExchangeBackend Protocol:
| Method |
Purpose |
connect() |
Initialize connection (API keys, websockets) |
submit_order(symbol, side, qty, type, limit_price) |
Submit order with risk guard pre-check |
cancel_order(order_id) |
Cancel pending order |
get_positions() |
List all open positions |
get_account() |
Account summary (equity, cash, buying power) |
get_quote(symbol) |
Current bid/ask/last/volume |
get_historical(symbol, period, interval) |
OHLCV data |
Backend Selection
from emerald_exchange.backends import create_backend, TradingMode
# Paper (default, always safe)
backend = create_backend("paper", {}, TradingMode.PAPER)
# Alpaca (FREE paper trading for equities + crypto)
backend = create_backend("alpaca", {
"api_key": "...", "api_secret": "...",
"base_url": "https://paper-api.alpaca.markets"
}, TradingMode.PAPER)
# CCXT (100+ crypto exchanges)
backend = create_backend("binance", {
"api_key": "...", "api_secret": "..."
}, TradingMode.PAPER)
2. Risk Management (OS-5.1)
Pre-Trade Validation (CONCEPT:EX-AHE.harness.ee-6)
Every order passes through RiskGuard.pre_trade_check() before submission:
- Kill switch check: Is trading halted?
- Live mode check: Does live trading require human approval?
- Position sizing: Kelly criterion with configurable cap (default 2%)
- Cash sufficiency: Can the portfolio afford this trade?
Circuit Breakers (CONCEPT:EX-AHE.harness.ee-15)
| Trigger |
Threshold |
Action |
| Portfolio drawdown |
10% from peak |
Auto-halt all trading |
| Daily loss |
3% of equity |
Auto-halt all trading |
| Regime shift |
KS-test > 0.1 |
Auto-halt all trading |
Kelly Criterion (CONCEPT:EX-AHE.harness.ee-14)
# Half-Kelly with 2% cap
f = RiskGuard.kelly_criterion(
win_rate=0.6, # 60% win rate
win_loss_ratio=2.0, # Winners 2x losers
half_kelly=True, # Conservative
max_risk=0.02, # Never exceed 2%
)
3. Signal Generation & Fusion
Alpha Factor Pipeline
- Feature Engineering: Technical indicators, fundamental ratios, alternative data
- IC/IR Scoring: Information Coefficient and Information Ratio ranking
- Regime Detection: HMM-based market state classification (Bull/Bear/Sideways/Crisis)
- Bayesian Fusion: Combine multiple signal sources with uncertainty weighting
Market Regimes
- Bull: Positive momentum, low volatility — increase equity exposure
- Bear: Negative momentum, rising volatility — reduce exposure, hedge
- Sideways: Range-bound — mean reversion strategies, options selling
- Crisis: High correlation, extreme volatility — risk-off, kill switch ready
4. Strategy Lifecycle (CONCEPT:AU-AHE.assimilation.trading-ecosystem-spec)
Draft → Backtest → Paper → Live
↑ ↑ ↑
│ │ └── Human approval REQUIRED
│ └── Minimum 30-day paper validation
└── Minimum 2-year backtest with walk-forward
Promotion Gates
| Stage |
Requirements |
| Draft → Backtest |
Hypothesis documented in KG, debate completed |
| Backtest → Paper |
Sharpe > 1.0, max drawdown < 15%, 2yr minimum |
| Paper → Live |
30-day paper profit, risk officer approval, human sign-off |
5. Portfolio Optimization
Supported Optimizers
- Mean-Variance (MVO): Classic Markowitz with shrinkage estimators
- Risk Parity: Equal risk contribution across assets
- Black-Litterman: Bayesian combination of market equilibrium + views
- Hierarchical Risk Parity (HRP): Cluster-based allocation
Rebalancing Schedule
- Tactical: Weekly (Monday 9AM ET) via
portfolio-rebalance workflow
- Strategic: Monthly review with Brinson attribution analysis
1---2name: trading-systems3description: Comprehensive trading systems skill-graph covering exchange backends, risk management, algorithmic strategy design, portfolio optimization, and market microstructure. Distilled from open-source trading libraries (qlib, freqtrade, TradingAgents, FinRL, CCXT) into native agent-utilities patterns.4---56# Trading Systems Skill Graph78Knowledge distilled from 14+ open-source trading libraries into native9agent-utilities patterns. This skill graph provides structured reference10for all aspects of automated trading.1112## 1. Exchange Backend Architecture1314### Pattern: Protocol-Based Backend Abstraction (CONCEPT:EX-AHE.harness.ee)1516Every exchange backend implements the `ExchangeBackend` Protocol:1718| Method | Purpose |19|--------|---------|20| `connect()` | Initialize connection (API keys, websockets) |21| `submit_order(symbol, side, qty, type, limit_price)` | Submit order with risk guard pre-check |22| `cancel_order(order_id)` | Cancel pending order |23| `get_positions()` | List all open positions |24| `get_account()` | Account summary (equity, cash, buying power) |25| `get_quote(symbol)` | Current bid/ask/last/volume |26| `get_historical(symbol, period, interval)` | OHLCV data |2728### Backend Selection2930```python31from emerald_exchange.backends import create_backend, TradingMode3233# Paper (default, always safe)34backend = create_backend("paper", {}, TradingMode.PAPER)3536# Alpaca (FREE paper trading for equities + crypto)37backend = create_backend("alpaca", {38 "api_key": "...", "api_secret": "...",39 "base_url": "https://paper-api.alpaca.markets"40}, TradingMode.PAPER)4142# CCXT (100+ crypto exchanges)43backend = create_backend("binance", {44 "api_key": "...", "api_secret": "..."45}, TradingMode.PAPER)46```4748## 2. Risk Management (OS-5.1)4950### Pre-Trade Validation (CONCEPT:EX-AHE.harness.ee-6)5152Every order passes through `RiskGuard.pre_trade_check()` before submission:53541. **Kill switch check**: Is trading halted?552. **Live mode check**: Does live trading require human approval?563. **Position sizing**: Kelly criterion with configurable cap (default 2%)574. **Cash sufficiency**: Can the portfolio afford this trade?5859### Circuit Breakers (CONCEPT:EX-AHE.harness.ee-15)6061| Trigger | Threshold | Action |62|---------|-----------|--------|63| Portfolio drawdown | 10% from peak | Auto-halt all trading |64| Daily loss | 3% of equity | Auto-halt all trading |65| Regime shift | KS-test > 0.1 | Auto-halt all trading |6667### Kelly Criterion (CONCEPT:EX-AHE.harness.ee-14)6869```python70# Half-Kelly with 2% cap71f = RiskGuard.kelly_criterion(72 win_rate=0.6, # 60% win rate73 win_loss_ratio=2.0, # Winners 2x losers74 half_kelly=True, # Conservative75 max_risk=0.02, # Never exceed 2%76)77```7879## 3. Signal Generation & Fusion8081### Alpha Factor Pipeline821. **Feature Engineering**: Technical indicators, fundamental ratios, alternative data832. **IC/IR Scoring**: Information Coefficient and Information Ratio ranking843. **Regime Detection**: HMM-based market state classification (Bull/Bear/Sideways/Crisis)854. **Bayesian Fusion**: Combine multiple signal sources with uncertainty weighting8687### Market Regimes88- **Bull**: Positive momentum, low volatility — increase equity exposure89- **Bear**: Negative momentum, rising volatility — reduce exposure, hedge90- **Sideways**: Range-bound — mean reversion strategies, options selling91- **Crisis**: High correlation, extreme volatility — risk-off, kill switch ready9293## 4. Strategy Lifecycle (CONCEPT:AU-AHE.assimilation.trading-ecosystem-spec)9495```96Draft → Backtest → Paper → Live97 ↑ ↑ ↑98 │ │ └── Human approval REQUIRED99 │ └── Minimum 30-day paper validation100 └── Minimum 2-year backtest with walk-forward101```102103### Promotion Gates104| Stage | Requirements |105|-------|-------------|106| Draft → Backtest | Hypothesis documented in KG, debate completed |107| Backtest → Paper | Sharpe > 1.0, max drawdown < 15%, 2yr minimum |108| Paper → Live | 30-day paper profit, risk officer approval, human sign-off |109110## 5. Portfolio Optimization111112### Supported Optimizers113- **Mean-Variance (MVO)**: Classic Markowitz with shrinkage estimators114- **Risk Parity**: Equal risk contribution across assets115- **Black-Litterman**: Bayesian combination of market equilibrium + views116- **Hierarchical Risk Parity (HRP)**: Cluster-based allocation117118### Rebalancing Schedule119- **Tactical**: Weekly (Monday 9AM ET) via `portfolio-rebalance` workflow120- **Strategic**: Monthly review with Brinson attribution analysis