⚠ MVP PreviewReport a Bug

Backtesting

Strategy expressions

Compose entry and exit rules with reusable signal keys.

What it is

Backtesting expressions let you combine multiple signal keys into one boolean entry or exit rule, such as momentum plus trend confirmation in the same strategy.

When to use it

  • Moving from single-indicator ideas to more realistic trade rules.
  • Separating signal computation from the expression that uses those keys.
  • Prototyping strategies you may later automate in production.

REST example

python
import os
import requests

response = requests.post(
  'https://api.financedata.com/v1/backtests/run',
  headers={
      'Content-Type': 'application/json',
      'X-API-Key': os.environ['FDA_KEY'],
  },
  json={
      'name': 'Trend plus pullback',
      'symbols': ['AAPL'],
      'start_date': '2024-01-01',
      'end_date': '2025-01-01',
      'initial_capital': 10000,
      'strategy': {
          'entry': {
              'condition': 'SMA_20 > SMA_50 and RSI_14 < 35',
              'signal_names': ['SMA_20', 'SMA_50', 'RSI_14'],
          },
          'exit': {
              'condition': 'RSI_14 > 60 or SMA_20 < SMA_50',
          },
          'position_size': 1.0,
          'commission': 0.001,
      },
  },
  timeout=30,
)
response.raise_for_status()
print(response.json())

MCP example

Tool call body

{
"name": "submit_backtest",
"arguments": {
  "name": "Trend plus pullback",
  "symbols": ["AAPL"],
  "start_date": "2024-01-01",
  "end_date": "2025-01-01",
  "initial_capital": 10000,
  "entry_condition": "SMA_20 > SMA_50 and RSI_14 < 35",
  "entry_signal_names": ["SMA_20", "SMA_50", "RSI_14"],
  "exit_condition": "RSI_14 > 60 or SMA_20 < SMA_50"
}
}

Agent prompt that triggers it

Backtest a strategy that only buys pullbacks in an uptrend and exits on either momentum recovery or trend failure.