canli-validation-mcp 0.8.1 → 0.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -5
- package/package.json +16 -1
- package/src/schemas.mjs +35 -35
- package/src/server.mjs +17 -1
package/README.md
CHANGED
|
@@ -333,11 +333,11 @@ tokenizers give different absolute counts), in the shape an OpenAI-style client
|
|
|
333
333
|
|
|
334
334
|
| CANLI_TOOLSETS | tools | tokens per turn | of all |
|
|
335
335
|
|---|---|---|---|
|
|
336
|
-
| `all` | 14 | 3,
|
|
337
|
-
| `validate` | 10 | 3,
|
|
338
|
-
| `receipts` | 2 |
|
|
339
|
-
| `company` | 1 |
|
|
340
|
-
| `status` | 1 |
|
|
336
|
+
| `all` | 14 | 3,834 | 100% |
|
|
337
|
+
| `validate` | 10 | 3,166 | 83% |
|
|
338
|
+
| `receipts` | 2 | 312 | 8% |
|
|
339
|
+
| `company` | 1 | 273 | 7% |
|
|
340
|
+
| `status` | 1 | 89 | 2% |
|
|
341
341
|
|
|
342
342
|
Providers cache a tool list that is identical from turn to turn and bill the cached part at a
|
|
343
343
|
fraction of the price (`test/tool-list-stable.test.mjs` keeps each list byte-stable); a smaller list
|
package/package.json
CHANGED
|
@@ -1,7 +1,22 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "canli-validation-mcp",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.9.0",
|
|
4
4
|
"description": "Check whether a backtest is real: deflated Sharpe, CSCV probability of backtest overfitting, minimum track record and backtest length, haircut Sharpe and luck-equivalent trials, as an MCP server. Local mode, hosted endpoint, signed receipts.",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"mcp",
|
|
7
|
+
"mcp-server",
|
|
8
|
+
"model-context-protocol",
|
|
9
|
+
"backtesting",
|
|
10
|
+
"backtest",
|
|
11
|
+
"deflated-sharpe-ratio",
|
|
12
|
+
"probability-of-backtest-overfitting",
|
|
13
|
+
"cscv",
|
|
14
|
+
"sharpe-ratio",
|
|
15
|
+
"overfitting",
|
|
16
|
+
"quantitative-finance",
|
|
17
|
+
"quant",
|
|
18
|
+
"trading"
|
|
19
|
+
],
|
|
5
20
|
"private": false,
|
|
6
21
|
"type": "module",
|
|
7
22
|
"license": "MIT",
|
package/src/schemas.mjs
CHANGED
|
@@ -14,44 +14,44 @@ import { z } from "zod";
|
|
|
14
14
|
export const FIELD_DESCRIPTIONS = Object.freeze({
|
|
15
15
|
observed_sharpe_annualized: "Annualized Sharpe as observed.",
|
|
16
16
|
observations: "Number of return observations.",
|
|
17
|
-
periods_per_year: "
|
|
17
|
+
periods_per_year: "Periods per year: 252 daily, 365 crypto, 52 weekly, 12 monthly.",
|
|
18
18
|
skew: "Skewness of returns; 0 if Normal.",
|
|
19
19
|
non_excess_kurtosis: "Kurtosis, not excess kurtosis; 3 if Normal.",
|
|
20
20
|
effective_independent_trials: "Independent variants tried before choosing this one.",
|
|
21
|
-
cross_trial_sharpe_sd_annualized: "Standard deviation of
|
|
22
|
-
returns: "Periodic returns as fractions (0.01
|
|
23
|
-
matrix: "Returns as fractions
|
|
21
|
+
cross_trial_sharpe_sd_annualized: "Standard deviation of annualized Sharpe across those trials.",
|
|
22
|
+
returns: "Periodic returns as fractions (0.01 = 1%), oldest first; replaces the Sharpe, observations, skew and kurtosis.",
|
|
23
|
+
matrix: "Returns as fractions, one row per period, one column per variant.",
|
|
24
24
|
n_splits: "Even number of blocks, at least 2; default 16.",
|
|
25
25
|
max_combinations: "Most splits evaluated, up to 2000 (default).",
|
|
26
26
|
seed: "Sampling seed; default 42.",
|
|
27
27
|
record: "A canli.paper-evidence.v0 record.",
|
|
28
28
|
sleeve_sharpe: "Annualized Sharpe of one sleeve.",
|
|
29
29
|
average_pairwise_correlation: "Average correlation between sleeves, -1 to 1.",
|
|
30
|
-
sleeves: "Sleeve count,
|
|
31
|
-
target: "Target book Sharpe,
|
|
30
|
+
sleeves: "Sleeve count, for that book's Sharpe.",
|
|
31
|
+
target: "Target book Sharpe, for the sleeves it needs.",
|
|
32
32
|
benchmark_sharpe_annualized: "Annualized Sharpe to beat; default 0.",
|
|
33
33
|
confidence: "Between 0 and 1; default 0.95.",
|
|
34
|
-
record_observations: "Record length so far,
|
|
34
|
+
record_observations: "Record length so far, for its probabilistic Sharpe.",
|
|
35
35
|
label: "Name for the key.",
|
|
36
36
|
receipt_id: "Receipt id from a validation result.",
|
|
37
|
-
receipt_object: "A receipt as get_receipt returns it
|
|
37
|
+
receipt_object: "A receipt as get_receipt returns it, to verify without fetching.",
|
|
38
38
|
cik: "SEC CIK; send cik or ticker.",
|
|
39
39
|
ticker: "Ticker such as AAPL; send ticker or cik.",
|
|
40
40
|
concept: "us-gaap concept such as Assets; omit to list them.",
|
|
41
41
|
limit: "Most observations, newest first; default 40.",
|
|
42
|
-
target_sharpe_annualized: "In-sample annualized Sharpe you would
|
|
43
|
-
backtest_years: "
|
|
44
|
-
bt_trials: "Independent trials (backtests, parameter sets, ideas)
|
|
45
|
-
hc_observations: "
|
|
46
|
-
hc_tests: "
|
|
47
|
-
autocorrelation: "
|
|
48
|
-
other_sharpes: "Annualized
|
|
49
|
-
lt_trials: "Independent trials tried; adds the chance
|
|
50
|
-
lt_skew: "Skewness
|
|
51
|
-
variants: "Optional returns of every variant tried
|
|
52
|
-
returns_file: "Path to a CSV or JSON
|
|
53
|
-
returns_column: "
|
|
54
|
-
variants_file: "Path to a CSV or JSON
|
|
42
|
+
target_sharpe_annualized: "In-sample annualized Sharpe you would call a discovery; default 1.",
|
|
43
|
+
backtest_years: "Backtest length in years, for the most trials it allows.",
|
|
44
|
+
bt_trials: "Independent trials tried (backtests, parameter sets, ideas).",
|
|
45
|
+
hc_observations: "Return observations behind the Sharpe.",
|
|
46
|
+
hc_tests: "Tests run, this one included; gives the Bonferroni and independent-test haircuts.",
|
|
47
|
+
autocorrelation: "Lag-1 autocorrelation of returns, -1 to 1; default 0. Corrects the annualized Sharpe (Lo 2002).",
|
|
48
|
+
other_sharpes: "Annualized Sharpes of the other tests over the same observations; adds Holm and BHY.",
|
|
49
|
+
lt_trials: "Independent trials tried; adds the chance the best reached this Sharpe by luck.",
|
|
50
|
+
lt_skew: "Skewness; below -0.5 the reading warns the counts are too generous.",
|
|
51
|
+
variants: "Optional returns of every variant tried (this one included), one row per period, one column per variant; adds the overfitting check.",
|
|
52
|
+
returns_file: "Path to a CSV or JSON of the returns on this machine (not on the hosted endpoint), instead of returns.",
|
|
53
|
+
returns_column: "Column name or 1-based position, when returns_file has several numeric columns.",
|
|
54
|
+
variants_file: "Path to a CSV or JSON with one numeric column per variant, instead of variants.",
|
|
55
55
|
});
|
|
56
56
|
const d = FIELD_DESCRIPTIONS;
|
|
57
57
|
|
|
@@ -302,20 +302,20 @@ export const REGISTRY_DESCRIPTION_MAX = 100;
|
|
|
302
302
|
// above) what the tool's result cannot be used to claim, so an agent sees this before it ever
|
|
303
303
|
// calls the tool, not only inside the returned envelope.
|
|
304
304
|
export const TOOL_DESCRIPTIONS = Object.freeze({
|
|
305
|
-
get_key: `Issue a free
|
|
306
|
-
validate_deflated_sharpe: `Deflated Sharpe ratio: the probability (0 to 1) that
|
|
307
|
-
audit_backtest: `
|
|
308
|
-
validate_overfitting: `Probability of backtest overfitting (0 to 1) by CSCV: how often the
|
|
309
|
-
validate_paper_evidence: `Whether a paper or simulated performance record meets canli.paper-evidence.v0, with
|
|
310
|
-
validate_backtest_length: `Minimum backtest length
|
|
311
|
-
validate_luck_trials: `How many skill-less strategies a search would
|
|
312
|
-
validate_haircut_sharpe: `Haircut Sharpe
|
|
313
|
-
validate_track_record: `Minimum track record length
|
|
314
|
-
validate_breadth: `
|
|
315
|
-
verify_receipt: `
|
|
316
|
-
get_receipt: `Fetch a stored verdict by receipt id
|
|
317
|
-
service_status: `Whether the validation API is up, with
|
|
318
|
-
company_financial_history: `SEC-reported financial history for one company
|
|
305
|
+
get_key: `Issue a free validation key for this session. Rarely needed: the first validation issues one itself unless CANLI_KEY or local mode is set, and the read tools need none. ${LIMITS_SENTENCES.quotas}`,
|
|
306
|
+
validate_deflated_sharpe: `Deflated Sharpe ratio: the probability (0 to 1) that the selected strategy's Sharpe beats the best that luck gives across the variants tried, with the probabilistic Sharpe and that luck benchmark. Send the seven statistics or a return series. With every variant's returns use validate_overfitting; luck as a trial count, validate_luck_trials; a multiple-testing haircut, validate_haircut_sharpe. ${LIMITS_SENTENCES.notAdmission}`,
|
|
307
|
+
audit_backtest: `One-call audit of a strategy's returns: deflated Sharpe, minimum track record and, with every variant's returns, the probability of backtest overfitting, each the matching validator's result with its own receipt. Point returns_file at the backtest's CSV or JSON instead of pasting long series. Prefer it to calling the validators one by one; one validation per check. ${LIMITS_SENTENCES.notAdmission}`,
|
|
308
|
+
validate_overfitting: `Probability of backtest overfitting (0 to 1) by CSCV: how often the in-sample best variant falls below the out-of-sample median. Needs every variant's returns (periods by variants); with summary statistics only, use validate_deflated_sharpe. ${LIMITS_SENTENCES.notAdmission}`,
|
|
309
|
+
validate_paper_evidence: `Whether a paper or simulated performance record meets canli.paper-evidence.v0, with a JSON pointer per failure. Checks structure and required disclosures, not whether the returns are good. ${LIMITS_SENTENCES.scope}`,
|
|
310
|
+
validate_backtest_length: `Minimum backtest length (years) before the best of N independent trials is not expected to reach a target Sharpe by luck; with backtest_years, the most trials those years allow. For planning a search; once it has a result, use validate_deflated_sharpe. ${LIMITS_SENTENCES.notAdmission}`,
|
|
311
|
+
validate_luck_trials: `How many skill-less strategies a search would need for its best to reach this Sharpe by luck (Monte Carlo), and with a trial count, the chance it did. States luck as the best of N random tries; for the probability the Sharpe is real, use validate_deflated_sharpe. ${LIMITS_SENTENCES.notAdmission}`,
|
|
312
|
+
validate_haircut_sharpe: `Haircut Sharpe for multiple testing (Harvey and Liu 2015): the Sharpe a single test would have needed, by Bonferroni and independent tests, and with the other tests' Sharpes, Holm and BHY. For the probability the Sharpe is real, use validate_deflated_sharpe. ${LIMITS_SENTENCES.notAdmission}`,
|
|
313
|
+
validate_track_record: `Minimum track record length (observations and years) for an observed Sharpe to beat a benchmark at a confidence level; with observations, the record's probabilistic Sharpe so far. For live or paper records; to size a backtest for its trials, use validate_backtest_length. ${LIMITS_SENTENCES.notAdmission}`,
|
|
314
|
+
validate_breadth: `Book Sharpe ceiling from adding sleeves of this quality and correlation, the Sharpe at a sleeve count, and the sleeves a target needs. For portfolio construction; it validates no single strategy. ${LIMITS_SENTENCES.scope}`,
|
|
315
|
+
verify_receipt: `Verify a receipt offline: its Ed25519 signature against the bundled canlicapital.com key, its output hash and its id. Send an id to fetch it first, or the receipt itself. ${LIMITS_SENTENCES.unsigned}`,
|
|
316
|
+
get_receipt: `Fetch a stored verdict by receipt id to re-read it. No key; verify_receipt checks it is genuine. ${LIMITS_SENTENCES.unsigned}`,
|
|
317
|
+
service_status: `Whether the validation API is up, with its quotas; check after a timeout before resubmitting. No key. ${LIMITS_SENTENCES.scope}`,
|
|
318
|
+
company_financial_history: `SEC-reported financial history for one company in the canlicapital.com reference, by cik or ticker: without a concept, the histories available; with one, observations newest first with accession, form, filed date and unit, plus the source's SHA-256. For point-in-time values use canli-fundamentals-mcp. ${COMPANY_REFERENCE_BOUNDARY}`,
|
|
319
319
|
});
|
|
320
320
|
|
|
321
321
|
// Output schemas (0.8.0). Published OPEN: extra fields always pass. A client validates a tool's
|
package/src/server.mjs
CHANGED
|
@@ -19,6 +19,22 @@ import { breadthInput, trackRecordInput, auditBacktestInput, verifyReceiptToolSh
|
|
|
19
19
|
export const DEFAULT_BASE = "https://canlicapital.com";
|
|
20
20
|
export const SERVER_NAME = "canlicapital-validation-mcp";
|
|
21
21
|
export const SERVER_VERSION = JSON.parse(readFileSync(new URL("../package.json", import.meta.url), "utf8")).version;
|
|
22
|
+
// Sent once in initialize; clients such as Claude Code put it in the system prompt, so the model
|
|
23
|
+
// knows the first call to make even when tool definitions are deferred. Byte-stable across runs.
|
|
24
|
+
export const SERVER_INSTRUCTIONS = "Checks whether a backtest's result is real. For one strategy's returns, call audit_backtest, pointing returns_file at the backtest's CSV instead of pasting long series. For a Sharpe found by a search, validate_deflated_sharpe needs how many independent variants were tried and how their Sharpes spread; with every variant's returns, validate_overfitting gives the probability of backtest overfitting. Set CANLI_LOCAL=1 to compute on this machine with no network. Every result says what it does not establish; quote those limits with the number.";
|
|
25
|
+
|
|
26
|
+
// How the server introduces itself in initialize: a readable title, the page that documents it
|
|
27
|
+
// and its icon, so clients and directories that read serverInfo show more than a package name.
|
|
28
|
+
export const SERVER_INFO = Object.freeze({
|
|
29
|
+
name: SERVER_NAME,
|
|
30
|
+
version: SERVER_VERSION,
|
|
31
|
+
title: "Canli Validation",
|
|
32
|
+
websiteUrl: "https://canlicapital.com/developers#ai-assistant",
|
|
33
|
+
icons: [
|
|
34
|
+
{ src: "https://canlicapital.com/icon-512.png", mimeType: "image/png", sizes: ["512x512"] },
|
|
35
|
+
{ src: "https://canlicapital.com/favicon.svg", mimeType: "image/svg+xml", sizes: ["any"] },
|
|
36
|
+
],
|
|
37
|
+
});
|
|
22
38
|
export const REQUEST_TIMEOUT_MS = 30_000;
|
|
23
39
|
|
|
24
40
|
// One place a value fails a zod schema turns into a short, readable message instead of a raw
|
|
@@ -693,7 +709,7 @@ export function registerAll(server, session) {
|
|
|
693
709
|
}
|
|
694
710
|
|
|
695
711
|
export function createServer(session = createSession()) {
|
|
696
|
-
const server = new McpServer({
|
|
712
|
+
const server = new McpServer(SERVER_INFO, { instructions: SERVER_INSTRUCTIONS });
|
|
697
713
|
registerAll(server, session);
|
|
698
714
|
return server;
|
|
699
715
|
}
|