Skip to main content

Overview

Autonome uses a multi-variant strategy architecture that allows multiple AI trading personalities to operate in parallel. Each variant represents a distinct trading philosophy, risk tolerance, and decision-making approach optimized for different market regimes.

The Four Variants

Autonome currently supports four strategy variants, each designed for specific market conditions:

Apex (Kelly Engine)

Aggressive 10x leverage strategy using volatility squeezes and VWAP momentum validation

Trendsurfer (Momentum)

Trend-following strategy that rides strong directional moves using ADX filtering and Kijun-Sen trailing stops

Contrarian (Reverter)

Mean reversion specialist that fades extremes in ranging markets when ADX < 25

Sovereign (Adaptive)

Balanced regime-adaptive allocator that blends trend and range strategies based on market conditions

Variant Architecture

Code Organization

The variant system is built on a centralized configuration model:
// Core variant definitions
src/core/shared/variants/index.ts        // SSOT for variant IDs, configs, styling

// Prompt files (each exports SYSTEM_PROMPT and USER_PROMPT)
src/server/features/trading/prompts/
  ├── apex.ts                             // Apex strategy prompts
  ├── trendsurfer.ts                      // Trendsurfer prompts
  ├── contrarian.ts                       // Contrarian prompts
  ├── sovereign.ts                        // Sovereign prompts
  ├── variants.ts                         // Maps variants to prompts
  ├── promptBuilder.ts                    // Assembles prompts with data
  └── promptSections.ts                   // Builds portfolio/performance sections

Single Source of Truth

All variant metadata lives in src/core/shared/variants/index.ts:
export const VARIANT_IDS = [
  "Apex",
  "Trendsurfer", 
  "Contrarian",
  "Sovereign",
] as const;

export const VARIANT_CONFIG: Record<VariantId, VariantConfig> = {
  Apex: {
    id: "Apex",
    label: "Apex (Kelly Engine)",
    description: "Aggressive 10x leverage, VWAP momentum validation, squeeze trading",
    color: "#a855f7",
    bgClass: "bg-purple-500/20",
    textClass: "text-purple-600",
    lightBg: "#faf5ff",
  },
  // ... other variants
};
This configuration is consumed by:
  • Database schema (variant enum)
  • oRPC router schemas (Zod validation)
  • Frontend components (styling, filtering)
  • Seed scripts
  • Export utilities

Prompt System

Each variant has two core components: 1. SYSTEM_PROMPT (Static Instructions)
  • Trading philosophy and identity
  • Decision framework
  • Tool interface documentation
  • Risk management rules
  • Exit plan requirements
  • Response format guidelines
2. USER_PROMPT (Dynamic Data Template)
  • Session metadata (time, invocations, cash)
  • Market intelligence
  • Portfolio snapshot
  • Open positions table
  • Performance overview
  • Mission/instructions
Prompts are built using promptBuilder.ts:buildTradingPrompts():
const { systemPrompt, userPrompt } = buildTradingPrompts({
  account,
  portfolio,
  openPositions,
  exposureSummary,
  performanceMetrics,
  marketIntelligence,
  currentTime,
  variant: "Apex", // or "Trendsurfer", "Contrarian", "Sovereign"
});

Data Provided to AI

All variants receive identical market data and portfolio state, but interpret it differently based on their strategy:

Session Header

Session: 120 min | Interval: 5 min | Invocations: 24 | 2:30 PM IST
Cash: $8,342.15 | Exposure: 45.2%

Market Intelligence

Provided via {{MARKET_INTELLIGENCE}} placeholder:
  • Technical indicators (Bollinger Bands, VWAP, EMA20, ADX, Supertrend, Ichimoku)
  • Volume data (current vs average)
  • Funding rates
  • Price action context

Portfolio Snapshot

Built by promptSections.ts:buildPortfolioSnapshotSection():
portfolio_value: $10,234.56 | available_cash: $5,621.33 | open_positions: 2
cash_utilization_pct: 45.1% | exposure_to_equity_pct: 45.1%
gross_exposure_usd: $4,613.23 | long_exposure: $4,613.23 | short_exposure: $0.00 | net_exposure: $4,613.23
unrealized_pnl: $234.56 | scaled_realized_pnl: $0.00
gross_risk_usd: $128.45 | risk_to_equity_pct: 1.25% | max_single_position_risk_usd: $85.32 | max_single_position_risk_pct: 0.83%

Open Positions

Built by promptSections.ts:buildOpenPositionsSection():
symbol BTCUSDT | side LONG | qty 0.2500 | entry 42150.00 | mark 42380.00 | notional $2,119.00 | leverage 5.00x
unrealized $57.50 | scaled_realized $0.00
risk_usd $85.32 | risk_pct 0.83% | reward_usd $211.50 | reward_pct 2.06% | rr_ratio 2.48
exit_plan: target 42800.00 | stop 41809.00 | invalidation "Close below EMA20" | time_exit "Close if held > 12h" | cooldown_until 2026-03-07T14:35:00Z
intent: signal LONG | confidence 75.0% | decision_status active | last_decision_at 2026-03-07T14:30:00Z

Performance Metrics

Built by promptSections.ts:buildPerformanceOverview():
closed_trade_realized_pnl: $423.45 | trade_count: 12 | win_rate: 58.33%
total_return_since_start: 4.23% | annualized_sharpe_ratio: 1.85
current_drawdown: -2.15% | max_drawdown: -5.42%

Prompt Data Principles

The system follows strict guidelines for prompt construction:
  1. Spoon-feed data: AI should never infer or calculate - provide all metrics explicitly
  2. Explicit labels: Use risk_usd $128.56 not risk $128.56 - no ambiguity
  3. Show zeros: scaled_realized $0.00 is meaningful (no partial closes yet)
  4. Omit N/A: If data doesn’t exist, don’t show it (noise reduction)
  5. No token optimization: Clarity > brevity. Full descriptive labels always
  6. Section separation: Header (session), PORTFOLIO (current state), PERFORMANCE (historical), OPEN POSITIONS (per-position)
  7. No duplication: Each metric lives in exactly one section
Source: promptSections.ts:1-176

Tool Interface

All variants use the same tool interface for portfolio control:
  • createPosition: Open new positions with leverage, stops, targets
  • closePosition: Exit positions
  • updateExitPlan: Modify stops/targets on open positions
  • holding: Explicit no-action with reasoning
Critical Rule: Every response must end with a tool call. If no action is needed, call holding() with reasoning.

Common Constraints

All variants share these core constraints:

Data Source Hierarchy

  1. Manual/Exchange Indicators (Execution): Use for exact entry price, stop loss, and invalidation
  2. Taapi/Binance Indicators (Context): Use for broad trend and market regime (ADX, Supertrend, Ichimoku)

Mandatory Exit Plan

Every position must specify:
  • invalidation_condition: The thesis-killing event (e.g., “Close below VWAP”)
  • invalidation_price: The exact stop-loss price
  • time_exit: Max hold duration (e.g., “Close if held > 12h without profit”)
  • cooldown_minutes: 1-15 minutes to prevent impulsive flips

Cooldown System

Cooldown prevents direction flips. After closing a LONG position, the AI cannot open a SHORT position on the same symbol until cooldown expires (and vice versa). This applies both while holding AND after closing.

Variant Comparison

VariantMax LeverageRisk ProfileBest For
Apex10xExtremely AggressiveHigh-conviction squeezes
Trendsurfer5xModerateStrong trends (ADX > 25)
Contrarian5xModerateRanging markets (ADX < 25)
Sovereign5xBalancedAll market conditions

Adding a New Variant

To add a new trading strategy variant:
  1. Add to SSOT: Update src/core/shared/variants/index.ts
    export const VARIANT_IDS = [
      "Apex",
      "Trendsurfer",
      "Contrarian",
      "Sovereign",
      "YourNewVariant", // Add here
    ] as const;
    
    export const VARIANT_CONFIG: Record<VariantId, VariantConfig> = {
      // ... existing variants
      YourNewVariant: {
        id: "YourNewVariant",
        label: "Your New Variant (Description)",
        description: "Strategy description",
        color: "#hexcolor",
        bgClass: "bg-color-500/20",
        textClass: "text-color-600",
        lightBg: "#hexcolor",
      },
    };
    
  2. Create Prompt File: Add src/server/features/trading/prompts/yournewvariant.ts
    export const SYSTEM_PROMPT = `You are **Autonome YourNewVariant**...
    // Strategy instructions
    `;
    
    export const USER_PROMPT = `
    Session: {{TOTAL_MINUTES}} min | Interval: 5 min | Invocations: {{INVOKATION_TIMES}}
    // Template with placeholders
    `;
    
  3. Register in Variants: Update src/server/features/trading/prompts/variants.ts
    import {
      SYSTEM_PROMPT as SYSTEM_PROMPT_YOURNEWVARIANT,
      USER_PROMPT as USER_PROMPT_YOURNEWVARIANT,
    } from "./yournewvariant";
    
    export const VARIANT_PROMPTS: Record<VariantId, VariantConfig> = {
      // ... existing variants
      YourNewVariant: {
        ...VARIANT_CONFIG.YourNewVariant,
        systemPrompt: SYSTEM_PROMPT_YOURNEWVARIANT,
        userPrompt: USER_PROMPT_YOURNEWVARIANT,
        temperature: 0,
      },
    };
    
  4. Migrate Database: Run bun run db:generate && bun run db:migrate

Next Steps

Apex Strategy

Learn about the aggressive 10x leverage Kelly Engine

Trendsurfer Strategy

Explore the momentum-based trend follower

Contrarian Strategy

Understand the mean reversion specialist

Sovereign Strategy

Discover the balanced adaptive allocator

Build docs developers (and LLMs) love