Trade Logic

Complete Trade Lifecycle

1

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

2

Signal Generation

For each symbol, all enabled strategies run in parallel:

  • Each strategy evaluates the current market state

  • Confluences are gathered and scored

  • Signals that meet minimum confidence proceed

  • Signals that fail minimum confidence or R:R are discarded

3

Signal Aggregation

When the Master System is active, signals from multiple strategies are aggregated:

  • Same-direction signals are merged (highest confidence wins, details combined)

  • Opposing signals cancel each other

  • The aggregated signal must still meet quality thresholds

4

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)

5

AI Validation

If enabled, the signal is sent to Claude AI with full context. The AI may:

  • APPROVE — Signal proceeds unchanged

  • ADJUST — Signal proceeds with modified parameters (e.g., smaller size, wider SL)

  • REJECT — Signal is discarded

6

Risk Validation

Before execution:

  • Correlation Guard checks portfolio exposure

  • Position count check (max simultaneous positions)

  • Daily loss limit check

  • Account balance minimum check

  • Feature Gate tier validation

7

Execution

The trade is placed on Hyperliquid:

  1. Price rounded to 5 significant figures (Hyperliquid requirement)

  2. Position size calculated from risk parameters

  3. Market order placed for entry

  4. Stop Loss order placed immediately after fill

  5. Position registered in the tracking system

  6. Telegram notification sent

  7. Trailing stop system initialized

  8. Thesis Monitor snapshot captured

8

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

9

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

10

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

circle-info

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.