Skip to main content

stratify-mcp

Python client for Stratify — real 1-minute NIFTY options data, honest backtests (out-of-sample, walk-forward, deflated Sharpe, all reported alongside the number, not instead of it).

pip install stratify-mcp

Quickstart

from stratify_mcp import StratifyClient

# One-time: create an account and get a key. The key is shown once -- save it.
signup = StratifyClient.signup("you@example.com")
client = StratifyClient(api_key=signup["api_key"])

result = client.run_backtest({
    "legs": [
        {"side": "sell", "type": "CE", "strike": {"delta_near": 0.2}},
        {"side": "sell", "type": "PE", "strike": {"delta_near": 0.2}},
    ],
    # The reason for the trade, not just the trade.
    "entry": {"cadence": "weekly", "dte": 3, "time": "09:30",
              "when": {"vix": {"gte": 15}}},
    # Managed while it is open: take profit, and roll the tested side if it doubles.
    "rules": [
        {"when": {"pnl_pct_of_credit": {"gte": 0.6}}, "then": "close"},
        {"when": {"leg_mark_mult": {"gte": 2.0, "leg": 0}},
         "then": {"roll": {"legs": [0], "to": {"delta_near": 0.2}}}, "max_times": 2},
    ],
    "portfolio": {"stop_after_losses": 3, "resume_after_days": 30},
})

print(result.summary["total_pnl_rupees"], result.summary["max_drawdown_rupees"])
print(result.summary["ratios"])       # sharpe, profit_factor, calmar (only above 30 trades)
print(result.honesty)          # out-of-sample split, walk-forward folds, deflated Sharpe
result.trades                  # pandas.DataFrame, one row per trade
result.equity_curve            # pandas.DataFrame
print(result.report_url)       # shareable page with the full chart and every trade

Already have a key? Skip signup():

client = StratifyClient(api_key="sk_live_...")

Why a Python client at all, when it's just JSON-RPC

There's no separate REST endpoint for run_backtest — every tool is reached through one POST /mcp speaking MCP JSON-RPC 2.0. This package exists so you don't hand-roll that envelope: client.run_backtest(...) is a real function call, errors come back as Python exceptions you can except, and results come back as pandas.DataFrames instead of raw JSON, because that's what you're actually going to do with a table of trades.

Errors

from stratify_mcp import AuthenticationError, QuotaExceededError, ToolRefusalError

try:
    result = client.run_backtest(spec)
except AuthenticationError:
    ...  # bad or revoked key
except QuotaExceededError as e:
    ...  # e.limit, e.retry_after_seconds
except ToolRefusalError as e:
    ...  # the server read your spec and refused it -- str(e) says why

Methods

Method Returns
run_backtest(spec, lots=1, detail="standard") BacktestResult
get_backtest(backtest_id, detail=None) BacktestResult
describe_coverage() dict — symbols, date range, structures, gates, biases, cost model
explain_methodology(topic=None) dict
list_strategies(order="consistency", limit=None) dict — {"strategies": [...], "bar": {...}, ...}, this account's strategies that held up out-of-sample
search(query) / fetch(id) dict
StratifyClient.signup(email) (staticmethod) dict — includes api_key, shown once

detail on run_backtest/get_backtest: "summary" (aggregates only, cheapest), "standard" (default — equity curve, breakdowns, first 25 trades), "full" (every stored trade).

BacktestResult

Property Type
.summary dict
.honesty dict
.interpretation str
.trades pandas.DataFrame
.equity_curve pandas.DataFrame
.qualified / .why_not_qualified bool / str | None
.backtest_id / .report_url str
.warnings list[str]
.to_dict() the complete raw payload

Development

pip install -e ".[dev]"
pytest

Tests run against a mocked transport and need no live server or API key.

License

MIT.

Metadata

Release files for stratify-mcp 0.1.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for stratify-mcp 0.1.2
File Size Uploaded
stratify_mcp-0.1.2.tar.gz 12.9 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for stratify-mcp 0.1.2
File Interpreter ABI Platform
stratify_mcp-0.1.2-py3-none-any.whl Python 3 none any Details

Total release size: 23.2 kB

Release files / stratify_mcp-0.1.2.tar.gz

Download URL stratify_mcp-0.1.2.tar.gz
Size 12.9 kB
Tags Source
SHA-256 checksum
How to use checksums
2ea73265413d290a12839b6e62f236e6b2df77cfb9f6215e3c9aa90b3c1f4493
BLAKE2b-256 checksum
How to use checksums
503bdb6b6dc3a4e4c4df192b453139c7cac04c31963bf12ff02f6cb64ea6256b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 15, 2026.

Transparency log

Release files / stratify_mcp-0.1.2-py3-none-any.whl

Download URL stratify_mcp-0.1.2-py3-none-any.whl
Size 10.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
d0ae8972e3d42b9374c22a273ba7025c067a5c47f138a04acfdd522ecbe7c0be
BLAKE2b-256 checksum
How to use checksums
51af937fe8130ba55179d13dbe6b1cc9478a27bb7eb01c03c9b8222051664896
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 15, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

0.1.2 This release

2 release files

0.1.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page