Skip to main content

What We’re Building

A strategy that augments traditional technical indicators with AI-powered operators:
  • Traditional layer — RSI and SMA crossover for base signal
  • AI layer — LLM scores market conditions, web search provides sentiment
  • Gate pattern — Only call expensive AI operators when volatility is high (cost control)
  • Signal fusion — Combine technical and AI signals into final weights
This tutorial introduces ClyptQ’s unique semantic operators — LLM scoring and web search that run inside the trading loop.
Semantic operators are ephemeral — they only execute in paper and live modes, not in backtest. In backtest, they return neutral values (0.0). This is by design: LLM outputs are non-deterministic and would make backtests unreproducible.

Step 1: Setup

Step 2: Traditional Indicators

Build the base technical signal (same pattern as First Strategy):

Step 3: Volatility Gate

The gate controls when expensive AI operators run. High volatility = uncertain market = AI analysis is most valuable:
How the gate works:
  • ATR > 2% → gate outputs 1.0 (open) → AI operators execute
  • ATR ≤ 2% → gate outputs 0.0 (closed) → AI operators skip (return cached or neutral values)
This controls API costs: AI only runs when the market is volatile enough to benefit from additional analysis.

Step 4: LLM Scorer

The LLMScorer sends indicator values to an LLM and receives a [-1, 1] trading signal:
Parameters explained:
  • inputs — The indicator values sent to the LLM as numeric context
  • input_names — Human-readable names used in the prompt (e.g., “RSI: 72.3, SMA_Crossover: 0.8”)
  • model — LLM model to use (deepseek-v3, gemini-flash, gpt-4o, etc.)
  • call_interval — Only call the LLM every N ticks. Between calls, the last score is reused
Output: [-1.0, 1.0] where -1 = strong sell, 0 = neutral, +1 = strong buy.
The LLM receives a formatted prompt with the indicator values and returns a numeric score. The default prompt asks for a trading signal based on the technical indicators. You can customize both system_prompt and user_prompt_template.

Step 5: Web Search + Sentiment

Fetch market news and parse sentiment:
WebSearchOperator:
  • query_template — Uses {symbol} placeholder (e.g., “cryptocurrency BTC/USDT market news”)
  • gate_input — When gate is closed (0.0), search is skipped entirely (no API cost)
  • cache_results — Caches results to avoid redundant searches
  • cache_ttl — Cache duration in seconds
SentimentParser:
  • Takes text from WebSearchOperator output
  • Returns [-1.0, 1.0] sentiment score
  • model="rule-based" uses keyword matching (no API calls — good for cost-sensitive strategies)

Step 6: Signal Fusion

Combine technical and AI signals with explicit weights:
In backtest mode, llm_score and sentiment return 0.0 (neutral), so the backtest effectively runs on technical signals only. In paper/live, the AI signals augment the technical base.

Step 7: Portfolio Accounting + Intention

Step 8: Run

Backtest (technical signals only)

Paper & Live Trading

After backtesting, submit your strategy to the platform. Paper and live trading run on the dashboard — semantic operators (LLM scoring, web search) activate automatically in paper and live modes. They are skipped during backtest because they require real-time data and produce non-reproducible results.
Paper and live trading are not available in notebook cells. Submit your strategy and manage execution from the dashboard.

The Complete Graph

Cost Control Strategies

Gate conditions

Combine gates

call_interval optimization

Between calls, the previous score is reused. For slow-moving signals, call_interval=60 reduces costs by 98% with minimal signal degradation.

Semantic Operators

LLMScorer, WebSearch, and SentimentParser reference

Control Operators

ConditionalGate, GateOr, GateAnd reference

Semantic Operators (Competitive)

Why LLM-in-the-loop is unique to ClyptQ

Backtest to Live

Deploy this strategy from paper to live