---
title: "Strategy Backtester"
method: POST
path: "/backtest"
tags: ["Analytics"]
---

# Strategy Backtester

`POST /backtest`

## Request

- Base URL: `https://nzxplorer.co.nz/api/v1`
- URL: `https://nzxplorer.co.nz/api/v1/backtest`
- Auth: one of:
  - API key in header `X-API-Key`
  - API key in query parameter `api_key`

Backtest any screener filter combination against historical NZX data. 6 weighting methods: equal, market-cap, inverse market-cap, Mean-Variance Optimization (MVO), Black-Litterman (broker consensus views), Hierarchical Risk Parity (HRP). Annual rebalancing using financial_metrics + stock_prices. Returns equity curve, period-by-period holdings, risk-adjusted statistics (Sharpe, Sortino, max drawdown), and portfolio optimization results (efficient frontier, optimal weights). Supports price or total return (dividend-adjusted). Benchmark: FNZ ETF (Smartshares NZ Top 50). 7 statistically validated factors (|t|>2.0): P/B ratio, earnings yield, net profit growth, net debt/EBITDA, EV/EBITDA, P/E ratio, net margin.

## Request body

- object
  - `filters` object[], required: Array of {metric, operator, value} filters (same format as screener presets)
  - `startYear` integer: Backtest start year (default: current year - 5, min: 2016)
  - `endYear` integer: Backtest end year (default: current year)
  - `adjustForAnnouncement` 'true' | 'false': Delay rebalancing to actual annual results announcement dates, eliminating look-ahead bias (default: false)

## Response `200`

Strategy Backtester

- Envelope: Standard API response envelope
  - `data` unknown
  - `meta` object
    - `api_version` string
    - `timestamp` string, date-time
    - `format` 'standard' | 'llm' | 'fdc3' | 'toon'
    - `endpoint` string

## Other responses

- `401`: Missing or invalid API key
- `429`: Rate limit exceeded
- `500`: Internal server error

---

[API](https://skmtc.dev/nzxplorer/apis/nzxplorer-api.md) · [All operations](https://skmtc.dev/nzxplorer/apis/nzxplorer-api/llms.txt) · [OpenAPI document](https://skmtc.dev/nzxplorer/apis/nzxplorer-api/revisions/f3b95341783a?raw)
