Trade Logic
Complete Trade Lifecycle
Market Scan
Every scan cycle (30s to 5min depending on tier), VECTRA:
Fetches OHLCV data for all configured symbols at all required timeframes
Fetches Coinglass on-chain data (if enabled)
Detects current market regime for each symbol
Checks existing positions for trailing stop updates and thesis validity
Quality Pipeline
The surviving signal passes through the post-generation pipeline:
Tier 2 Quality Enhancement
Tiered Confidence Modifiers (OI, whale, taker, HTF, BTC correlation)
Entry Timing (candle close, chase, sweep, session)
Microstructure (spread, depth, liquidity)
ML Filter (gradient boosted prediction)
Execution
The trade is placed on Hyperliquid:
Price rounded to 5 significant figures (Hyperliquid requirement)
Position size calculated from risk parameters
Market order placed for entry
Stop Loss order placed immediately after fill
Position registered in the tracking system
Telegram notification sent
Trailing stop system initialized
Thesis Monitor snapshot captured
Position Management
While the position is open:
Trailing Stop Updates — Every scan cycle, the active trailing system evaluates whether to move the SL
Thesis Monitor — Continuously checks if the entry rationale is still valid
News Monitor — Watches for relevant news that might affect the position
CG Intelligence — Monitors on-chain data for warning signs
Exit
The position can close through:
Take Profit — Price reached TP level
Stop Loss — Price hit SL (initial or trailed)
Trailing Exit — Trailed SL caught up to price
Thesis Invalidation — Thesis Monitor triggered exit
CG Exit — CG intelligence detected adverse conditions
Time Decay — Strategy-specific time limits (e.g., MR 6h maximum)
Manual Close — User command via Telegram or GUI
Emergency — Daily loss limit or account minimum triggered
Post-Trade
After closing:
PnL calculated (including funding fees paid/received)
Trade recorded in SQLite persistence
Trading metrics updated (profit factor, win rate, R:R)
AI learning system updated with outcome
ML filter updated with trade result
Telegram notification with full PnL summary
Adaptive parameters adjusted based on outcome
Defensive Design
Every external call in the entire pipeline is wrapped in try/except with fallback behavior. The system is designed to never crash from:
Exchange API failures → Retry with exponential backoff
Coinglass unavailability → Continue with technical analysis only
AI API failure → Proceed with confidence penalty
WebSocket disconnect → Fall back to OHLCV-derived flow
Data corruption → Default values and logging
This ensures VECTRA runs 24/7 without human intervention.