Catalog/quant-backtest

Quant

Backtest a trading strategy API

Backtest a rules-based strategy over a price series (SMA/EMA crossover, RSI, buy-and-hold, or your own signals) — look-ahead-bias-safe, with transaction costs — and get total/annualized return, Sharpe, max drawdown, win rate, trade count, equity curve, and a buy-and-hold benchmark. Answers 'backtest an SMA crossover', 'how would this strategy have performed', 'equity curve and sharpe for these signals'.

Price$0.03per request
MethodPOST
Route/v1/quant/backtest
StatusLive
MIME typeapplication/json
Rate limit60/minute
CacheNo cache
quantbackteststrategytradingsharpeequity-curvesignals
API URLhttps://x402.hexl.dev/v1/quant/backtest
Integration docs
Example request
{
  "prices": [
    100,
    101,
    102,
    101,
    103,
    105,
    104,
    106,
    108,
    107
  ],
  "strategy": "sma_cross",
  "fast": 2,
  "slow": 4
}
Example response
{
  "strategy": "sma_cross",
  "periods": 10,
  "totalReturn": 0.045,
  "sharpeRatio": 1.2,
  "maxDrawdown": -0.02,
  "trades": 3,
  "buyHoldReturn": 0.07,
  "vsBuyHold": -0.025,
  "equityCurve": [
    1,
    1.01
  ]
}
Input schema
{
  "type": "object",
  "required": [
    "prices",
    "strategy"
  ],
  "properties": {
    "prices": {
      "type": "array",
      "items": {
        "type": "number"
      }
    },
    "strategy": {
      "type": "string",
      "enum": [
        "sma_cross",
        "ema_cross",
        "rsi",
        "buy_hold",
        "signals"
      ]
    },
    "fast": {
      "type": "number"
    },
    "slow": {
      "type": "number"
    },
    "period": {
      "type": "number"
    },
    "oversold": {
      "type": "number"
    },
    "overbought": {
      "type": "number"
    },
    "signals": {
      "type": "array",
      "items": {
        "type": "number"
      }
    },
    "feeBps": {
      "type": "number",
      "default": 0
    },
    "allowShort": {
      "type": "boolean",
      "default": false
    },
    "periodsPerYear": {
      "type": "number",
      "default": 252
    }
  }
}
Output schema
{
  "type": "object",
  "additionalProperties": true
}