AVERO

Documentation

AVERO — Operator Console

AVERO is an end-to-end autonomous AI trading platform. A 7-model LLM ensemble, reinforcement learning (PPO), 5 ML classifiers, portfolio rebalancing, and dark pool options flow — all self-hosted with zero API costs.

Architecture Overview

Avero/
———
core/                  # Shared business logic (no FastAPI deps)
  broker.py            # Public.com REST adapter
  broker_paper.py      # Paper trading simulator
  broker_base.py       # Abstract broker interface
  data_feed.py         # Market data (yfinance + synthetic fallback)
  portfolio.py         # Position tracking, P&L, sizing
  risk.py              # RiskManager: drawdown, exposure, circuit breakers
  rebalancer.py        # Portfolio rebalancing engine
  strategy_performance.py # Per-strategy win rate tracking
  options_flow.py      # Options flow (UW → Tradier → synthetic)
  l2_feed.py           # L2 order book
  earnings.py          # Earnings calendar + blackout
  circuit_breaker.py   # API-level circuit breakers
  database.py          # SQLite trade journal
  jwt_manager.py       # JWT auth

engine/                # Strategy & signal layer
  signal_engine.py     # Signal orchestrator (all models + strategies)
  ai_reasoner.py       # GPT-4o + Claude hybrid (7 free models)
  rl_agent.py          # SB3 PPO v6 (39-feature obs space)
  confluence_signal_engine.py # Multi-factor confluence gating
  random_forest_model.py
  knn_model.py
  logistic_scanner.py
  reversal_detector.py
  chart_pattern_analyzer.py
  market_regime.py     # Bull/bear/range/hvol/lvol classifier
  confidence_calibrator.py # Platt/isotonic calibration
  ensemble_voter.py    # Multi-model consensus voting
  backtest_engine.py   # Vectorbt backtesting
  exit_strategy.py     # Consolidated exit strategies

strategies/            # Signal generation (auto-discovered)
  base.py              # BaseStrategy + TradeSignal + @register_strategy
  momentum.py          # Trend-following momentum
  rsi_bounce.py        # RSI oversold reversal
  etf_rotation.py      # Sector ETF momentum rotation
  confluence.py        # Confluence signal wrapper

dashboard/             # FastAPI application
  app.py               # Root app (~4700 lines, all routes)
  auth_routes.py       # JWT auth endpoints
  schemas.py           # Pydantic response models

frontend/              # React SPA (Vite + Tailwind)
  src/
    App.jsx            # Root shell, topbar, 5-tab system
    DashboardTab.jsx   # F-01: equity, positions, circuit breaker, log
    AICommandCenter.jsx # F-02: confidence ring, signal stream
    LiveTradingPanel.jsx # F-03: WS price stream, tick chart
    AISignalChart.jsx  # F-04: 6-model indicator chart, candle chart
    OrderFlowHeatmap.jsx # F-05: D3 canvas heatmap, depth ladder
    OptionsFlowPanel.jsx # F-06: options flow feed
    api.js             # All API helpers
    utils.js           # Formatters
    style.css          # Neural Core design system

Quick Start

# 1. Environment setup
cp .env.example .env
# Edit .env: set PUBLIC_API_KEY, OPENROUTER_API_KEY

# 2. Install dependencies
pip install -r requirements.txt
cd frontend && npm install

# 3. Start the bot
python main.py
# Opens http://localhost:8000

# 4. (Optional) Start Celery workers
celery -A engine.celery_app worker -Q avero.backtest,avero.scan --concurrency=2

Configuration

# Required — Broker
PUBLIC_API_KEY=...
PUBLIC_ACCOUNT_ID=...

# Required — AI
OPENROUTER_API_KEY=...       # Free registration at openrouter.ai

# Optional — Data
UNUSUAL_WHALES_API_KEY=...
TRADIER_API_KEY=...

# Optional — Infrastructure
REDIS_URL=redis://localhost:6379/0
DATABASE_URL=postgresql://user:pass@localhost:5432/avero
JWT_SECRET_KEY=...           # openssl rand -hex 32

5-Tab Consolidated Dashboard

The operator console was consolidated from 10 tabs into 5 streamlined tabs with inline sub-navigation for improved workflow:

TabFileKey Features
F-01 DashboardDashboardTab.jsxEquity curve, positions list (virtualized), circuit breakers, activity log (virtualized), P&L waterfall
F-02 AI CommandAICommandCenter.jsxConfidence ring (SVG), 12-model colors, signal stream, strategy toggle, ensemble reasoning, risk summary
F-03 Live FeedLiveTradingPanel.jsxWS price stream, 60-point rolling chart, market state, symbol grid, tick stream
F-04 AI SignalsAISignalChart.jsx6-model indicator chart, animated candlestick chart, model scores ribbon, price targets, backtest button
F-05 Order FlowOrderFlowHeatmap.jsxD3 canvas heatmap, depth ladder, symbol picker, 50-level book

Plus sub-panels: Options Flow, Chart Pattern Analysis, Strategy Performance, XAI Feature Importance, Report Builder, and Portfolio Rebalancing.

Performance Optimizations

OptimizationImpact
Lazy RL agent loading−124MB memory at rest
React.memo on Card components−60% component re-renders
WS tick debounce (60 → 20 updates/s)−95% unnecessary re-renders
Status cache (1s TTL)−50% redundant API calls
Virtualized position & activity logSmooth 60fps at 10K+ rows

API Endpoints

MethodPathDescription
GET/healthLiveness probe
GET/readyReadiness probe
GET/api/v1/statusBot state, P&L, positions, mode
GET/api/v1/system/healthComprehensive system health
GET/metricsPrometheus scrape endpoint
GET/api/v1/tradesRecent trade history
GET/api/v1/training/metricsRL training stats
GET/api/v1/orderbook/{symbol}L2 order book snapshot
GET/api/v1/options-flowOptions flow feed
GET/api/v1/signals/{symbol}Signal history + exit levels
GET/api/v1/confluence/signal/{symbol}Confluence signal engine
GET/api/v1/strategy-performancePer-strategy win rate, PF, calibration
GET/api/v1/rebalance/analyzeDrift analysis
POST/api/v1/rebalance/previewPreview rebalance orders
POST/api/v1/rebalance/executeExecute rebalance trades
GET/api/v1/broker-modeCurrent mode + paper stats
POST/api/v1/broker-modeSwitch live/paper
POST/api/v1/chart-pattern/analyzeGPT-4o Vision chart analysis
GET/api/v1/workers-routesList all routes
POST/api/emergency-stopHalt + liquidate
POST/control/startStart trading bot
POST/control/stopStop trading bot
WS/ws/pricesLive price tick stream (1 Hz)
POST/api/auth/tokenGet access token

WebSocket

ws://localhost:8000/ws/prices

# Receives JSON tick data:
{
  "symbol": "SPY",
  "price": 543.21,
  "change": 2.34,
  "change_pct": 0.43,
  "timestamp": "2026-05-26T14:30:00Z",
  "volume": 1234567
}

The WebSocket feed uses exponential backoff (1s → 30s), reset on successful connect. Mock fallback when server is unavailable.

Signal Engine

The signal_engine.py orchestrates all models and strategies into a unified signal pipeline:

Market Data (yfinance)
  |
  +--> Strategies: momentum, rsi_bounce, etf_rotation, confluence
  |     (iloc[-2] — last closed bar only)
  |
  +--> ML Models: RF, KNN, Logistic Regression
  |     (confidence threshold: 80%)
  |
  +--> RL Agent (PPO)
  |     (lazy-loaded, inference mode)
  |
  +--> LLM Ensemble (7 models, weighted vote)
  |     (min confidence: 75)
  |
  +--> Confluence Gate (3+ factor confirmation)
  |     (volume filter: 1.5x average)
  |
  +--> Weighted Consensus → Trade Signal

Consensus rules: Minimum 2-strategy agreement, minimum confidence score 75, confluence requires 3+ confirming factors, volume must exceed 1.5x average.

7-Model AI Ensemble

ModelWeightProvider
Nemotron 3 Super20%NVIDIA
DeepSeek V4 Flash20%DeepSeek
Gemma 4 26B15%Google
Trinity Large Thinking15%Cognitive Computations
Nemotron 3 Nano Omni10%NVIDIA
Big Pickle10%Big Pickle
OpenCode10%OpenCode

Zero API cost — all models accessed via OpenRouter free tier.

RL Agent (PPO)

MetricValue
AlgorithmPPO (Stable-Baselines3)
Observation Space39 features (OHLCV + self-awareness + regime)
Action SpaceDiscrete(3): HOLD / BUY / SELL
Total Timesteps Trained892,661
Symbols Trained117
Best Episode Reward+47.3
Policy Network[256, 128] MLP
Memory Footprint0MB at rest (lazy-loaded)

ML Models

ModelSamplesF1
Random Forest (Classifier)12,8470.61
RF Regressor12,847MSE: 0.018
KNN Classifier4510.59
KNN Regressor451MSE: 0.021
Logistic Regression1,8250.54
Chart Pattern (KNN)3200.49
Reversal Detector (CNN)7200.52

Risk Management

The system uses a 6-guard circuit breaker hierarchy with auto-recovery:

GuardThresholdAction
Intraday Drawdown−1.5% NAV90-minute pause, auto-resume
Circuit Breaker (Broker)5 failuresHALT all trading
Position Cap8 concurrentReject new entry
Single Position Risk2.5% NAVScale down or reject
Sector Concentration40%Block additional entries
VaR (95%, 1-day)−3.1% P95Reduce sizes 25%

Broker Mode

One-click toggle between live trading (Public.com) and paper trading (simulated $100K account):

# Current mode
GET /api/v1/broker-mode
{ "mode": "paper", "paper_balance": 100000.00, "paper_pnl": 2431.72 }

# Switch mode
POST /api/v1/broker-mode
{ "mode": "live" }

# Reset paper account
POST /api/v1/broker-mode/reset-paper

Portfolio Rebalancing

The rebalancer.py engine provides automated drift detection and order generation:

Options Flow

Dark pool options analytics with 3-source fallback chain: Unusual Whales API (primary) → Tradier API (fallback) → Synthetic generation. Per-entry provenance tracking via source field.

Anti-Repaint Guarantee

All trading decisions use only completed/cancelled bars (iloc[-2]). Zero lookahead bias:

ComponentBar Used
Momentum strategyiloc[-2]
RSI Bounce strategyiloc[-2], -3, -4
ETF Rotationiloc[-2]
Confluence engineiloc[-2] (ALL reads)
AI Reasoner contextiloc[-2]
AI Signal Generatordf.iloc[:-1]
RL Agent (inference)RL_INFERENCE env guard
Market Regimeiloc[-2]

Testing

# Python
pytest                         # Full suite (107+ tests)
pytest tests/test_broker.py    # Single file
ruff check .                   # Lint
ruff format .                  # Format

# Frontend
cd frontend
npm run build                  # Production build

# E2E
cd e2e
npx playwright test

Docker

# Development stack
docker-compose up -d

# Production stack (PostgreSQL + Redis + Celery + Nginx)
docker-compose -f docker-compose.prod.yml up -d

# Build image
docker build -t avero:latest .