Architecture

High-Level Flow

Market Data (Hyperliquid API)


┌─────────────────────────┐
│   OHLCV + Order Book    │◄──── Coinglass On-Chain Data
│   Multi-Timeframe       │      (OI, Funding, LSR, Liquidations)
└─────────┬───────────────┘


┌─────────────────────────┐
│  Market Regime Detector │ ──► 9 States (Strong Trend, Ranging, Volatile...)
│  + Adaptive Parameters  │
└─────────┬───────────────┘


┌─────────────────────────┐
│  Strategy Engine         │ ──► 13+ Strategies run in parallel
│  (Confluence-based)      │     Each generates scored signals
└─────────┬───────────────┘


┌─────────────────────────┐
│  Signal Quality Pipeline │
│  ┌───────────────┐      │
│  │ Tier 2 Quality│      │ ──► Quality filters, R:R validation
│  │ ML Filter     │      │ ──► Gradient Boosted decision
│  │ Correlation   │      │ ──► Portfolio exposure check
│  │ Tiered Conf.  │      │ ──► Confidence erosion protection
│  │ Entry Timing  │      │ ──► Candle close, chase detection
│  └───────────────┘      │
└─────────┬───────────────┘


┌─────────────────────────┐
│  AI Validation           │ ──► Claude AI evaluates thesis
│  (ECTRA AI v2.0)         │     APPROVE / ADJUST / REJECT
└─────────┬───────────────┘


┌─────────────────────────┐
│  Risk Manager            │ ──► Position sizing, leverage calc
│  + Feature Gate          │     Tier-based access control
└─────────┬───────────────┘


┌─────────────────────────┐
│  Execution Engine        │ ──► Hyperliquid order placement
│  (execute.py)            │     5-sig-fig price rounding
└─────────┬───────────────┘


┌─────────────────────────┐
│  Position Management     │
│  ┌───────────────┐      │
│  │ ATR Trailing   │      │ ──► Volatility-based trail
│  │ Smart S/R     │      │ ──► Ichimoku + Pivot S/R trail
│  │ CG Trailing   │      │ ──► Coinglass-intelligence trail
│  │ Thesis Monitor│      │ ──► Continuous thesis validation
│  └───────────────┘      │
└─────────┬───────────────┘


┌─────────────────────────┐
│  Telegram + Persistence  │ ──► Alerts, commands, trade journal
│  + Trading Metrics       │     SQLite state persistence
└─────────────────────────┘

Module Map (64 Files)

Core Engine

Module
Purpose

main.py

Master orchestrator — scan loop, signal routing, position monitoring

execute.py

Hyperliquid API wrapper — orders, positions, market data, MTF OHLCV

config_v9.py

Configuration — strategy modes, risk parameters, credentials (XOR-encrypted)

risk_manager.py

Position sizing, leverage calculation, trailing stop phases

master_system.py

Multi-strategy signal aggregation and unified execution

Strategy Modules

Module
Strategy
Category

strat_smc.py

Smart Money V2

SMC / Order Blocks / FVG

strat_orderflow.py

Order Flow

CVD Divergence / Volume

strat_of_mtf.py

Order Flow MTF ⭐

Flagship MTF strategy

strat_scalp.py

Enhanced Scalping

Multi-condition scoring

strat_session.py

Session Liquidity

Session high/low sweeps

strat_pattern.py

Chart Pattern

Classical pattern recognition

strat_sniper.py

Scalp Sniper

High-frequency OB/FVG/Sweep

strat_smc_mtf.py

Smart Money MTF

SMC with HTF bias

strat_confluent.py

Confluent

Multi-strategy agreement

strat_diversified.py

4 Diversified Strategies

MR, Momentum, Funding, LiqCascade

Analysis & Intelligence

Module
Purpose

regime.py

9-state market regime detection + adaptive parameter system

order_flow.py

Real-time WebSocket order flow + OHLCV-derived flow analysis

zones.py

Premium/Discount zones + MTF pattern confirmation

structure.py

Swing point detection, market structure (HH/HL/LH/LL)

indicators.py

Core technical indicator calculations

institutional.py

Liquidation level estimation

correlation.py

Cross-asset correlation and portfolio exposure

microstructure.py

Spread, depth, liquidity regime analysis

session_filter.py

Session-based filtering + regime TP/SL adjustment

coinglass.py

Coinglass helper (internal strategy use)

coinglass_integration.py

Full Coinglass API integration (v2.0 Institutional Pro)

AI & Machine Learning

Module
Purpose

ectra_ai_v2.py

AI signal validation, news sentiment, performance learning

ectra_ai_chat.py

Interactive AI trading assistant (GUI dialog)

ectra_news_monitor.py

Real-time news monitoring with AI sentiment

ectra_strategy_builder.py

AI-powered custom strategy creation

ectra_indicator_database.py

1,870-line indicator reference for AI context

ml_filter.py

ML feature extraction + gradient boosted signal filter

Risk & Quality

Module
Purpose

tier2_quality.py

Signal quality enhancement filters

tier3_risk.py

Tier 3 advanced risk management

tier4_analyzers.py

News, breadth, volume profile, smart money analysis

tiered_confidence.py

Confidence erosion protection (soft/hard classification)

thesis_monitor.py

Post-entry thesis validity monitoring

entry_timing.py

Candle close, chase detection, sweep confirmation

mr_time_decay.py

Mean Reversion-specific exponential time decay

trading_metrics.py

Profit factor, R:R tracking, performance analytics

Trailing Stop Systems

Module
Purpose

atr_trailing.py

ATR-based trailing stop (5 modes)

smart_trailing.py

S/R + Ichimoku Cloud trailing (6 phases)

smart_cg_trailing.py

Coinglass-intelligence trailing (6 phases)

Interface & Infrastructure

Module
Purpose

gui_app.py

PyQt6 desktop GUI with live dashboard

settings_dialog.py

GUI settings configuration dialog

telegram_bot.py

Telegram alerts, commands, license admin

vectra_persistence.py

SQLite trade journal and state persistence

vectra_backtest_engine.py

Institutional backtesting (Monte Carlo, Walk-Forward)

vectra_backtest_panel.py

GUI backtesting panel

license_validator.py

License key validation

license_generator.py

License key generation (admin)

snipe_entry_v2.py

Precision wick capture module

zone_entry_module.py

Reusable zone entry + pending order system

analysis.py

Technical analysis utilities

verify_setup.py

System verification on first run

build_exe.py

Windows executable builder

Data Flow Philosophy

VECTRA follows a strict Pipeline Architecture where data flows through increasingly selective filters.

1

Raw Data

Market data from exchange + on-chain data from Coinglass.

2

Regime Classification

Determine what type of market we are in.

3

Signal Generation

Multiple strategies generate scored candidates.

4

Quality Pipeline

Signals pass through 5+ quality filters.

5

AI Validation

Independent AI review of the trade thesis.

6

Risk Check

Portfolio-level exposure and sizing validation.

7

Execution

Precise order placement with tick-size compliance.

8

Active Management

Triple trailing + thesis monitoring until exit.

Each layer can reject the signal. A trade only executes if it survives every filter. This multi-gate approach dramatically reduces the number of trades while ensuring each executed trade has the highest possible probability of success.

Defensive Design Principles

Every external call (exchange API, Coinglass API, AI API, WebSocket) is wrapped in try/except blocks with graceful fallback behavior. If Coinglass is unavailable, the bot continues with technical analysis only. If the AI API fails, the signal proceeds with a confidence penalty. If the WebSocket disconnects, order flow falls back to OHLCV-derived estimates.

The system is designed to never crash from external failures and to always degrade gracefully.