Regimen

io.github.RaYYeR220由 GitHub 帳號 RaYYeR220 發布v1.0.0更新於 Oct 24, 2026

Tells you whether a trading strategy's edge is distinguishable from luck.

已驗證Streamable HTTP可網頁執行金融資料與分析

概覽

AI 產生的概覽

Regimen 是一個遠端 MCP 伺服器,用來判斷交易策略的實測優勢能否與運氣區分,以及該優勢在哪些市場情況下成立。

可以做什麼
評估策略淨值曲線的統計顯著性,回傳機率夏普比率、自助法信賴區間,以及達到顯著所需的最短績效紀錄長度,並在提供多次試驗夏普值時給出通縮夏普修正。依波動率、資金費率、未平倉量、持倉、情緒與趨勢狀態等市場情況拆分報酬,並對每個因子做置換檢定。以已知答案的對照樣本執行引擎,顯示其結論在何處可信。列出可用的市場情況因子及其單位、上游來源與分桶方式。
適用情境
在審閱回測或公開績效紀錄時使用,判斷所報夏普比率或勝率是否超出短樣本、偏態樣本所能支撐的範圍;或用來查看策略報酬集中在哪些市場狀態。
執行需求
遠端 Streamable HTTP 端點;使用 inline 資料來源(自行提供淨值曲線)無需驗證。分析 OlaXBT Nexus 策略需要 Nexus API 金鑰,可透過 x-nexus-key 請求標頭逐次提供,或透過 NEXUS_DEMO_KEY 環境變數設定。需要能存取該服務及其上游資料來源的網路。
安裝前請注意
此服務為唯讀,不交易、不持有資金、不簽署任何內容。透過 x-nexus-key 請求標頭送出的 Nexus 金鑰依請求讀取,不持久化也不寫入日誌,但仍是交給第三方服務的憑證。公開的評估以合成策略為基礎,無法證明任何獲利能力;README 說明六項目標中目前有三項未達成。

安裝

在 SourceWeft 中

  1. 開啟 儀表板中的 Regimen,將其新增到工作區。
  2. 為需要使用其工具的對話啟用該服務。

Web executable,透過 Streamable HTTP。 遠端服務在工作區中設定後即可從網頁執行環境執行。

交給代理程式安裝

把這段提示詞貼上到 Claude Code、Codex、Cursor 等代理程式,或 SourceWeft 對話中。代理程式會讀取該伺服器的安裝指南,先向你展示發布者、端點和登入方式,經你同意後再把它新增到你的客戶端。金鑰不會寫進任何命令。

閱讀 https://sourceweft.com/mcp/io.github.RaYYeR220%2Fregimen/install.md,並按其中說明把這個 MCP 伺服器接入我的客戶端。修改任何設定之前,先告訴我它的發布者、端點和登入方式,等我確認。不要把 API 金鑰寫進命令或我會提交的檔案;問我金鑰應從哪裡取得。

檢視代理程式所依據的安裝指南

其他 MCP 客戶端

把它新增到你客戶端的 mcpServers 設定中。

{
  "mcpServers": {
    "regimen": {
      "type": "http",
      "url": "https://regimen-nu.vercel.app/mcp"
    }
  }
}

README

Regimen

A Sharpe ratio is an estimate. Regimen tells you whether it is a fact.

Regimen takes a trading strategy's equity curve and answers two questions an aggregate performance number cannot: is the measured edge distinguishable from luck, and in which market conditions does it actually hold?

It is built for agents as much as for people. Everything is available over a REST API and over MCP, and the most common answer it gives is that the evidence is too thin to support the claim being made. That is the product, not a failure mode.


The problem

A strategy publishes a Sharpe ratio of 2.4 over six weeks and a 58% win rate over 40 trades. Both numbers are real. Neither is evidence.

A Sharpe ratio computed from a short, skewed, fat-tailed sample carries an error bar wide enough to swallow the claim. Forty trades cannot distinguish a 58% edge from a coin. And once a strategy has been re-tuned twenty times, the best configuration looks good for the same reason the tallest of twenty random people is tall.

This is not a niche statistical objection — it is the single most common way capital is lost to a backtest. The mathematics for handling it has existed since 2012 and is almost never applied, because it requires more than dividing a mean by a standard deviation.

Here is real output from the live service, on a curve with an annualised Sharpe of 3.72:

verdict      weakconfidence   92.3% that the true Sharpe exceeds 095% interval [-0.033, +0.462]        zero is still insidetrack record 60 periods; 78 needed for significance at 95%

A dashboard would have printed 3.72 and stopped.

What it does

1. Significance. The Probabilistic Sharpe Ratio — the probability the true Sharpe exceeds a benchmark given the sample's length, skewness and kurtosis. The Minimum Track Record Length — how many periods would be needed before the claim could be made at all. The Deflated Sharpe Ratio — the same statement corrected for how many configurations were tried first. A stationary-bootstrap confidence interval that preserves serial dependence.

2. Regime attribution. Each period's return is joined to the market conditions that held on that UTC date — volatility, funding, open interest, positioning, sentiment, trend state — read point-in-time, so nothing in a bucket could only have been known afterwards. Every factor carries a permutation test: the observed dispersion of performance across buckets is compared against the dispersion produced by randomly reshuffling the regime labels, because slicing a return series eight ways guarantees a flattering subset. Without that p-value a regime map is a data-mining machine.

3. Self-attack. Every analysis can be run against controls whose answer is known in advance: the strategy's own returns with the mean removed (true Sharpe exactly zero, so a correct engine must grade it near 50%), and a simulated population of edgeless strategies matched for length and volatility, so the real result can be placed as a percentile against pure luck. The result is published, including when a control fails.

4. Divergence check. Where a source publishes its own figures, Regimen recomputes them from the equity curve and reports the difference. Differing conventions explain most gaps, but a user quoting a dashboard deserves to know when the curve underneath says otherwise.

Try it, with no credentials

bash
curl -s https://regimen-nu.vercel.app/api/v1/evaluate \  -H 'content-type: application/json' \  -d '{    "selector": {      "source": "inline",      "trackRecord": {        "label": "demo",        "equity": [          {"t": "2026-06-01", "equity": 10000}, {"t": "2026-06-02", "equity": 10180},          {"t": "2026-06-03", "equity": 10090}, {"t": "2026-06-04", "equity": 10310},          {"t": "2026-06-05", "equity": 10240}, {"t": "2026-06-06", "equity": 10450}        ]      }    }  }'

That curve is deliberately too short, and Regimen says so rather than producing a number. verification/README.md has a full-length example that produces a graded verdict, plus the health and deployment-proof checks.

Two surfaces, one engine

REST

MethodPathWhat it answers
POST/api/v1/evaluateIs this track record distinguishable from luck?
POST/api/v1/regime-mapWhich market conditions is the edge concentrated in?
POST/api/v1/self-attackWhy should I believe the verdict?
GET/api/v1/statusUpstream reachability, cache occupancy, demo-key availability.
GET/api/v1/openapi.jsonThe machine-readable contract.
GET/api/healthLiveness and the exact build commit.

Every response is { data, meta } or { error, meta }, where meta carries a request id, the build commit, and which credential mode served the request. Errors carry a stable machine-readable code, a retryable flag, and a remedy written to be actionable by an agent rather than a human reading a stack trace.

MCP

Connect any MCP client to https://regimen-nu.vercel.app/mcp over Streamable HTTP. No authentication is needed for the inline source. For a client configured by file:

json
{ "mcpServers": { "regimen": { "url": "https://regimen-nu.vercel.app/mcp" } } }

To inspect it interactively: npx @modelcontextprotocol/inspector and point it at the same URL.

Tools — regimen_evaluate_track_record, regimen_regime_map, regimen_self_attack, regimen_describe_factors. Each advertises an outputSchema and returns validated structuredContent; each is annotated readOnlyHint because nothing here writes, trades or signs; each takes a detail switch so an agent can ask for the verdict and its reasons rather than every bucket.

Resources — regimen://methodology (the statistics, in full), regimen://evidence-tiers (the exact grading thresholds), and the template regimen://factor/{key}, whose key argument supports completion/complete.

Prompt — validate_strategy, the full review in the right order, with instructions not to lead with the annualised Sharpe.

Architecture

                    REST  /api/v1/*            MCP  /mcp                          │                        │                          └────────────┬───────────┘                                       │                            engine/  significance · regime · self-attack                                       │                            stats/   PSR · DSR · MinTRL · bootstrap ·                                     conditional attribution · Wilson                                       │                            sources/ ── adapter interface ──┐                                       │                     │                              olaxbt-nexus              inline                          (18 tools, point-in-time)  (bring your own curve)

The engine is written against a domain model — a track record, a regime series — and never against a vendor's response shape. A data source is a thin adapter that produces those two things. That is why the same analysis serves an OlaXBT Nexus strategy and a curve pasted in from a spreadsheet, and why adding a venue is an adapter rather than a rewrite.

OlaXBT Nexus is the live data source. The adapter reads the strategy's equity curve, trades and published metrics, and reads eight market-condition factors per date with an explicit as_of, which is what makes the regime attribution free of lookahead. Rate limiting and caching live in the client, not at call sites: a Builder-tier key allows 80 requests a minute and a regime map wants hundreds of point-in-time reads, so calls are paced under a token bucket and every immutable past-dated read is cached.

Testing

bash
pnpm test          # the full suitepnpm typecheck     # strict, with noUncheckedIndexedAccesspnpm eval          # the graded evaluation; writes EVAL.md

The statistics core carries 370 tests. Known-answer cases for PSR, MinTRL, the Deflated Sharpe Ratio, skewness, kurtosis, Wilson intervals and drawdown were generated independently of this implementation and carry their arithmetic in a comment. A negative-control test across 20 seeds confirms a zero-mean series clears 95% confidence on 2 of 20 runs — the nominal size — while the matching positive-mean series clears it on 20 of 20.

What the evaluation found

EVAL.md is a pre-registered graded evaluation: 82 synthetic strategies with known ground truth, scored on false-positive rate, power, correct refusals on degenerate input, calibration, and regime detection. The suite and its targets were fixed before the engine was ever run against them.

It currently fails three of its six targets, and the failures are published rather than tuned away. They are worth reading, because they are the honest limits of the method:

  • False positives 5.6% (2/36), target ≤5%. Both failures are the same mechanism: a negatively-skewed return distribution on a short window whose crash component simply has not arrived yet. The non-normality correction is driven by the sample third and fourth moments, and at 40–60 observations those carry almost no information — so the exact pattern the correction exists to catch ("sells volatility, hasn't blown up yet") is the one it walks into. The engine now says so explicitly in its own reasoning whenever a sample is too short for those moments to mean anything. Note that 2 of 36 is also within Monte Carlo noise of the nominal 5%; the mechanism is the finding, not the overshoot.
  • Restraint 66.7% (10/15), target ≥90%. In five cases a genuine but unprovable edge was graded as proven, because luck pushed the observed Sharpe far above the true one. The engine is directionally right in all five and still granting more confidence than the sample size supports.
  • Regime detection 25% (1/4) at p ≤ 0.05, target ≥75%. The evaluation caught a real design flaw here: the permutation test originally ran on the best-minus-worst Sharpe spread, which sees only two buckets and inflates with the number of buckets. On a planted effect it could not separate signal from the null at all — planted spread 0.493 against a null control's 0.491. It was replaced with an observation-weighted between-bucket variance, which moved the planted cases' p-values from 0.022/0.073/0.092/0.229 to 0.010/0.054/0.069/0.275 while the unplanted controls stayed quiet (0.18–0.91). That is a material improvement and still short of the target, so the target stands as missed.

Regime false positives are 0/4 and degenerate inputs are refused 8/8.

MCP conformance

npx @modelcontextprotocol/conformance@alpha server --url <url>

Against a local build: 36 checks pass, 23 fail. Passing: protocol negotiation, ping, tools/list, resources/list, prompts/list, and DNS-rebinding protection. Every failure is a scenario that exercises the suite's own reference-server fixtures — named test tools, sampling, logging, image and audio content, resource subscriptions — none of which Regimen implements. The raw counts are printed here rather than summarised as a pass, because a conformance claim that hides its denominator is worth nothing.

Note that the DNS-rebinding scenario reports failure against any non-localhost URL by construction (it states so in its own description), so it is meaningful only when run against a local build.

Running locally

bash
pnpm installpnpm dev        # http://localhost:3000

No credentials are needed for the inline source. To analyse an OlaXBT Nexus strategy, supply a key per request in the x-nexus-key header, or set one in the environment.

VariableRequiredWhat it does
NEXUS_DEMO_KEYnoAn OlaXBT Nexus API key used when a caller supplies none, so a reviewer can exercise the Nexus-backed endpoints without an account. Responses report meta.mode: "demo" when it is in use.
REVIEW_COMMITnoOverrides the commit reported by /api/health. Only needed when self-hosting outside a git-aware build; otherwise the platform's build metadata is used, which is what keeps the reported commit honest.

Keys are read per request, never persisted, and never logged. Where a key must be identified — for rate limiting and cache partitioning — only a non-reversible fingerprint is used.

Honest limits

  • A regime map reads at most 45 dates per request. Each date costs five point-in-time reads and the upstream allows 80 a minute. Past dates are immutable and cached, so repeating the call widens coverage; a single request will not.
  • Upstream point-in-time coverage ends before the present. Conditions for very recent dates may be unavailable, and those periods are reported as unmatched rather than filled in.
  • The Deflated Sharpe Ratio only appears when trial Sharpes are supplied. Regimen cannot know how many configurations you tried, and it will not guess — it says the ratio was not computed and why.
  • Tercile bucket edges depend on the sample. Factors with a conventional scale use edges fixed in advance; the rest are split into terciles of their own observed range, which is disclosed per factor.
  • Annualised figures are approximations when equity points are unevenly spaced. Regimen infers the period from the median spacing, flags irregularity, and grades on per-period figures rather than annualised ones.
  • The evaluation is modelled, not live. It measures the engine against synthetic strategies with known truth. It does not demonstrate profitability of anything.

Not in scope

Regimen does not trade, hold funds, custody keys, or sign anything. It does not inspect smart contracts, score wallets or transactions, detect scams, or perform security, audit or compliance analysis of any kind. It reads a track record and reports what the evidence supports.

License

MIT — see LICENSE.

來源:README.md,提交 c5c3a0b

工具

4

regimen_describe_factors

Describe regime factors

List the market-condition factors Regimen slices performance by, with units, the upstream operation each is read from, and how it is bucketed. Call this when you need to know which factor keys exist or how to explain a bucket to a user. Takes no arguments, reaches no network, never changes.

無需輸入參數。

regimen_evaluate_track_record

Evaluate a track record

Answer whether a trading strategy’s measured performance is distinguishable from luck. Returns the Probabilistic Sharpe Ratio (the probability the true Sharpe beats a benchmark, corrected for sample length, skew and fat tails), a bootstrap confidence interval, and the Minimum Track Record Length — how long the record would have to run before the claim could be made at all. Use this whenever someone quotes a Sharpe ratio, a win rate or a return and you need to know whether the number means anything. It will frequently say the evidence is too thin; that is the intended answer, not a failure.

輸入參數detailselector必填confidencetrialSharpesbenchmarkSharpe

regimen_regime_map

Map performance to market regimes

Break a strategy’s returns down by the market conditions that held on each date — volatility, funding, open interest, positioning, sentiment, trend state — and report performance per bucket. Each factor also gets a permutation test: the observed best-to-worst spread is compared against spreads produced by randomly reshuffling the regime labels, so a flattering subset cannot pass itself off as a regime effect. Use this after regimen_evaluate_track_record when you need to know WHERE an edge comes from, or whether it is a bet on conditions that could end.

輸入參數detailmaxDatesselector必填minSample

regimen_self_attack

Attack the verdict

Run Regimen’s own analysis against controls whose answer is known in advance: the strategy’s returns with the edge mathematically removed, and a simulated population of strategies with no edge at all. Returns whether the engine correctly found nothing in them, and where the real strategy’s confidence sits among pure-luck strategies of the same length and volatility. Use this when a user is entitled to ask why they should believe the verdict, or before quoting a result as evidence.

輸入參數selector必填simulations

版本歷史

1
  1. v1.0.0最新Sep 19, 2026

評分

已滿足適用檢查項的 100%

該評分衡量此收錄條目的完整程度,依據註冊中心條目、端點與公開來源計算得出。它不是對伺服器本身的評價,也不表示伺服器安全或目前可用:可連通性是帶日期的檢查結果,評分也不包含安裝量或使用者評價。

  • 近 30 天內可連通必需25 分
  • 已宣告認證方式必需10 分
  • 已列出工具必需15 分
  • 描述必需15 分
  • 圖示10 分
  • 文件15 分
  • 授權條款10 分