mcpField
C
Canli Backtest

Canli Backtest

Local
canlicapital.comFinance5Updated 3d ago

About Canli Backtest

Canli Backtest is an MCP server for quantitative researchers and agents that builds point-in-time SEC factors and backtests signals on user-provided prices. It enforces lagged, lookahead-free trading, charges costs on turnover, and records variants in a trial ledger.

Key features

  1. 01Point-in-time SEC factor generation
  2. 02Cross-sectional signal backtests
  3. 03Enforced lookahead prevention
  4. 04Turnover-based trading costs
  5. 05Variant tracking with a trial ledger

Use cases

  1. 01Build factors from SEC filings
  2. 02Test signals on supplied price data
  3. 03Compare backtest variants with search adjustment

MCP support

It exposes factor discovery, point-in-time factor generation, and signal backtesting tools to MCP clients. It runs locally over stdio; prices, signals, and ledgers stay on the machine.

Configuration

Local server config is the same for every client. Copy it into your client’s MCP config file.

mcp.json · Universal config
{
"mcpServers": {
"arhancanli-canli-backtest": {
"command": "npx",
"args": [
"-y",
"canli-backtest-mcp"
]
}
}
}
Run commandnpx -y canli-backtest-mcp

Local servers need a runtime on your machine (e.g. Node.js 18+). Config file locations differ by client; see your client’s docs.

Packages
npmcanli-backtest-mcp0.3.0

Tools

3

Saved tool list · updated 4d ago

This tool takes no parameters.

Details

From the project README

canli-backtest-mcp

Backtests an AI agent can trust. An MCP server that builds point-in-time factors from SEC filings, runs cross-sectional backtests of any signal on your own prices with no lookahead (enforced in code), charges costs on the actual trades, and records every variant in a trial ledger, so the best of a search is judged against the whole search instead of alone.

Local stdio only: your prices, signals and ledgers never leave your machine.

Why

Three mistakes make most agent-run backtests look better than they are:

  1. Lookahead. Using a number before it was public: an annual figure in January that was filed in February, or a value that was later restated. pit_factor only uses what had been filed with the SEC by each date, as it stood then; backtest_signal only trades on signal rows dated at least lag_days trading days earlier, and stops if anything reaches past that.
  2. Free trading. Ignoring turnover. Positions drift with prices between rebalances, and costs are charged on the trades from those drifted positions to the new targets.
  3. Counting only the winner. An agent tries 200 variants and reports the best. With ledger, every run is recorded (in canli-validation-mcp's hash-chained ledger), and each reply gives the best run's deflated Sharpe after counting all of them, and the Sharpe that luck alone reaches.

Tools

toolwhat it does
list_factorsThe factors pit_factor builds and what each measures.
pit_factorA factor (roa, gross_margin, operating_margin, revenue_growth, asset_growth, accruals, or level:<measure>) for your tickers, monthly, as known on each date. Writes a signal CSV.
backtest_signalRank on the signal, long the top quantile (and short the bottom), rebalance weekly, monthly, quarterly or every N days, with lag_days, cost_bps and an optional ledger.

Quick start

npx -y canli-backtest-mcp

Claude Code:

claude mcp add canli-backtest -- npx -y canli-backtest-mcp

Then ask: "Build roa for these 200 tickers from 2015 to 2024, backtest it monthly on prices.csv with 10 bps costs, try quantiles 0.1, 0.2 and 0.3 in the ledger 'roa-search', and tell me whether the best one survives the search."

Files

Both files are CSV with a date column (YYYY-MM-DD) and one column per ticker:

  • prices: closing prices, one row per trading day. Bring your own; adjust for splits and dividends if you want total returns. The server does not supply prices (vendor licences forbid passing them on).
  • signal: one row per date the values became known. pit_factor writes this; your own signal works too, as long as each row is dated by when it was available.

Empty cells are missing values, never zero.

What a result does not establish

  • Prices are yours: survivorship, splits, dividends and data errors in them pass straight into the result.
  • A backtest measures one path of history under these costs; it does not establish that the signal keeps working.
  • Costs are a flat rate per unit traded; market impact, short-borrow fees and financing are not charged unless included in cost_bps.
  • SEC values are what companies reported in XBRL, as filed; late filers, non-XBRL filers and tag changes can be missing.

Configuration

variabledefaultmeaning
CANLI_LEDGER_DIR~/.canli/ledgerswhere ledgers are kept (shared with canli-validation-mcp)
CANLI_CACHE_DIR~/.cache/canli-fundamentalsSEC data cache

Part of the Canli Capital MCP family

canli-validation-mcp (validators and the trial ledger), canli-fundamentals-mcp (SEC fundamentals point in time), canli-research-mcp (the open research record). Source: github.com/arhancanli/canlicapital. MIT licensed. Built by Arhan Canli.

Comments

Markdown supported

New to MCP?

From what the protocol is to installing your first server, these answers cover most first questions.

An open protocol that defines how AI applications connect to external tools and data in a uniform way. Clients talk to the model; MCP servers provide tools, resources and prompt templates. They exchange standard messages, so one server can be reused by many clients.