Skip to main content

MacroStress

English | Русский | 中文

CI MIT Python 3.12+

MacroStress answers one question: how much does a portfolio lose under a given macroeconomic scenario? An analyst or an agent names paths for a few macro variables (say, the policy rate at 21 % for the next year) and the shocks behind them. A macro model estimated on history (a BVAR or an MS-VAR) completes consistent paths for the other variables, satellite models turn those paths into drivers (equity prices, bond spreads, industry overdue shares, housing prices), and every position is repriced along the same draws. The output is a loss distribution with $P_5$, $P_{50}$, $P_{95}$, ES95 and the scenario price $\mathrm{dist}(s)$. The method is described in docs/concept/scenario-formalization.en.md.

The server speaks MCP, so any client can drive it: Claude Desktop, Cursor, Claude Code. A DeepSeek Harness plugin in dsh/ adds three skills and a workspace snapshot for the agent prompt. All state lives in one workspace/ directory; there is no web app, no database, and no scheduler.

What it does

Part What it does
Series Monthly series from MOEX, the Bank of Russia, Rosstat, and FRED, with the release date of every value
Macro model A plugin: the shipped BVAR (bvar.sv), MS-VAR (msvar.markov) or any other; the core keeps the variables registry, the panel and the version store
Drivers Object catalogs, the satellite bundle — one model per quantity, assigned by declaration or explicitly — out-of-sample checks, driver paths on the macro draws
Scenario A $(N, C, D, O)$ file with impacts $O$ on any level, validation and paths: the conditional forecast and the drivers on the same draws
Positions Equity, bond, credit or deposit, housing
Run and report The conditional forecast of the target indicators and the portfolio along the same paths, with $P_5$, $P_{50}$, $P_{95}$, ES95, and the scenario price
Extensions A new asset type, macro model or satellite is a plugin: python -m mst.plugin new --kind position|satellite|macro, contract checks, a demo run
DSH plugin Scenario from the corpus, report, drivers; the prompt section built from workspace.json

MCP tools: jobs, series, corpus, scenario, run, portfolio, model. The reference is in docs/reference/tools.en.md.

Install

Python 3.12 or newer and uv are enough.

git clone https://github.com/LeoLourson/MacroStress-DSH
cd MacroStress-DSH
uv sync
uv run macrostress --workspace C:/data/macrostress

The server speaks over stdio and prints only errors; it waits for a client. Configuration for Claude Desktop, Cursor, and any other MCP client is in docs/howto/mcp.en.md. The DeepSeek Harness plugin is covered in docs/howto/install.en.md.

First session

Once a client is connected, it sees seven tools. Long operations start jobs: a tool returns a job at once, and jobs shows the progress.

  1. jobs(action="state") — what is in the workspace: model versions, corpus index, jobs.
  2. series(action="update") — download the macro series. FRED needs a key in FRED_API_KEY.
  3. jobs(action="status", id=...) and jobs(action="log", id=...) — wait for the job.
  4. model(kind="macro", action="estimate", as_of="2026-10-29") — estimate the macro model (bvar.sv, the only one installed; model_id names another) on the data known at that date. The version is a hash.
  5. series(action="update", quantity="share_price") — find the objects of a quantity and download their series; the same for bond_spread, overdue_share, housing_price_primary, housing_price_secondary.
  6. model(kind="satellites", action="estimate", version=<macro hash>) — assemble the satellite bundle of that macro version: every quantity is estimated by the model assigned to it (hier.gibbs by default; assignment names another).
  7. model(kind="satellites", action="describe", version=<hash>) — which drivers passed the out-of-sample check and why the rest were rejected.
  8. corpus(action="search", query=..., as_of=...) — fragments known at the date; corpus(action="index") rebuilds the index as a job.
  9. scenario(action="save", id=..., spec={...}) — save a scenario; scenario(action="validate", id=...) — list everything that blocks the calculation.
  10. portfolio(action="save", id=..., spec={...}) — save a portfolio; portfolio(action="check", id=..., scenario=...) — check it against the scenario.
  11. run(action="start", scenario=..., portfolio=..., draws=..., seed=..., targets=...) — start a run; run(action="result", id=...) — read the conditional forecast of the target indicators ($P_5$/$P_{50}$/$P_{95}$ by month) and the portfolio report with the scenario price $\mathrm{dist}(s)$ and coverage.
  12. model(kind="macro", action="backtest", as_of=...) — the episode check: CRPS, band coverage, admission and the equal-weight aggregate by level and horizon on historical events (mst.metrics); the command line adds the two-standard-error decision, the scenario usefulness, the wild intervals and the portfolio tail.

Documentation

Every document exists in English (*.en.md) and Russian (*.md); the index is docs/README.en.md.

Every package folder has its own README that names its files.

Development

uv sync
uv run pytest -q -m "not slow"
uv run ruff check .

The slow tests estimate the BVAR and take minutes; the night workflow runs the full suite. CI runs the fast suite on Linux and Windows with Python 3.12 and 3.13.

Status

0.2.0, beta. Interfaces may change before 1.0. The data sources are the Russian market (MOEX, the Bank of Russia, Rosstat) plus FRED for global series.

Contributing and license

Contributing rules and the release process are in CONTRIBUTING.md; vulnerabilities go through SECURITY.md. The code is MIT-licensed, see LICENSE. Series from MOEX, the Bank of Russia, Rosstat, FRED, and BIS are not part of this repository: you load them under the terms of each source, and the license does not cover that data. Citations are described in CITATION.cff.

Metadata

Release files for macrostress 1.0.1

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

Source distribution (sdist)

Source distribution for macrostress 1.0.1
File Size Uploaded Provenance Actions
macrostress-1.0.1.tar.gz 351.1 kB With provenance Details for macrostress-1.0.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for macrostress 1.0.1
File Interpreter ABI Platform Actions
macrostress-1.0.1-py3-none-any.whl Python 3 none any Details for macrostress-1.0.1-py3-none-any.whl

Total release size: 775.4 kB

Release files / macrostress-1.0.1.tar.gz

Download URL macrostress-1.0.1.tar.gz
Size 351.1 kB
Tags Source
SHA-256 checksum
How to use checksums
56def57613f79428f83f3cf2d45ec662f27978a02d55e35c175be6f21705ebbe
BLAKE2b-256 checksum
How to use checksums
5ff0aa723d6adb78281c067d4aa7dd0fcdf07dfe93309bb580e6c3d9a07c9eb6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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 Nov 1, 2026.

Transparency log

Release files / macrostress-1.0.1-py3-none-any.whl

Download URL macrostress-1.0.1-py3-none-any.whl
Size 424.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
f22cfb2c065c70e6b35713f60ac5ce3d8fb9a80883f2863878e330dde4abe6b4
BLAKE2b-256 checksum
How to use checksums
1c28c231b98ed1462c96c25dd814cfad9cf482ff38ded15610467264ff504c33
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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 Nov 1, 2026.

Transparency log

Security for macrostress 1.0.1

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.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for macrostress-1.0.1.tar.gz

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 Nov 1, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

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