canli-mcp / No lookahead

How do I test a stock factor without lookahead bias?

canli-backtest-mcp's pit_factor builds a factor from SEC filings using only what had been filed by each date, so an annual figure filed in February cannot reach a January decision. For Apple and Microsoft, gross margin from January to March 2024 came back as a file ready for backtest_signal, free with no key.

Price: $0 to run. Updated 2026-11-02. Free and MIT-licensed, with no account and no API key. Or run claude mcp add canli -- npx -y canli-mcp in Claude Code.

Ask it

Build a gross-margin factor for Apple and Microsoft using only what had been filed by each date.

The agent finds the tool through canli-mcp's find_tool and runs it through run_tool. This is the call:

{
  "name": "pit_factor",
  "arguments": {
    "factor": "gross_margin",
    "tickers": [
      "AAPL",
      "MSFT"
    ],
    "start": "2024-01-01",
    "end": "2024-03-31"
  }
}

What came back

Recorded from canli-mcp 0.16.1 on 2026-11-02, with no API key set. The model read 757 characters.

The result pit_factor sent back
{
  "ref": "r1",
  "factor": "gross_margin",
  "meaning": "gross profit / revenue, same fiscal year",
  "file": "/tmp/canli-pit-xtipDO/gross_margin.csv",
  "dates": 3,
  "tickers": 2,
  "first_date": "2024-01-01",
  "last_date": "2024-03-01",
  "coverage": {
    "min": 2,
    "median": 2,
    "max": 2
  },
  "matched": {
    "AAPL": "Apple Inc.",
    "MSFT": "MICROSOFT CORPORATION"
  },
  "next": "backtest_signal with signal_file /tmp/canli-pit-xtipDO/gross_margin.csv and your prices_file; lag_days 1 or more.",
  "limits": [
    "Values are what companies reported to the SEC in XBRL, as filed by each date; a company that files late, files outside XBRL or changes its t…",
    "Ticker symbols are resolved to today's SEC assignment; a ticker reused by another company maps to the current holder, so check the matched n…"
  ]
}

Prices, filings and statistics are as the sources published them on that day; run the call again for today's. Nothing here is investment advice.

The tools behind the answer

From canli-mcp's tool index
ToolPackWhat it does
pit_factorbacktestBuild a factor from SEC filings for a list of tickers, monthly from start to end, using only what had been filed by each date (restatements invisible until filed). Writes a signal CSV for backtest_signal. Values are what companies reported to the SEC in XBRL, as filed by each date; a company that files late, files outside XBRL or changes its tags can be missing.
backtest_signalbacktestBacktest a signal against your prices: rank, long and short quantiles, rebalance, trading only on what was known lag_days earlier, costs on actual trades. Every reply holds the result against the crises its dates cover and lists the ones it does not. With capital_usd and dollar_volume_file, orders fill only as far as the market traded, pay square-root impact, and the reply shows the Sharpe at each size the market can take. Pass ledger to judge the best of a search against all of it. A backtest measures one path of history under these costs; it does not establish that the signal will keep working.

Add canli-mcp

Claude Code
claude mcp add canli -- npx -y canli-mcp
Cursor, Claude Desktop or any MCP client
{ "mcpServers": { "canli": { "command": "npx", "args": ["-y", "canli-mcp"] } } }
claude.ai, ChatGPT or any client that takes a URL
https://canlicapital.com/mcp/canli

Everything canli-mcp does · How it compares with other finance MCP servers

Related questions