Metadata-Version: 2.1
Name: mathema-mcp
Version: 1.6.0
Summary: Mathema MCP Python bindings (prebuilt _mcp + dict-style Mcp*)
Home-page: https://help.mathema.com.cn/
Project-URL: Homepage, https://help.mathema.com.cn/
Project-URL: Documentation, https://help.mathema.com.cn/
Requires-Python: >=3.9
Provides-Extra: data
Requires-Dist: numpy>=1.19; extra == "data"
Requires-Dist: pandas>=1.3; extra == "data"
Description-Content-Type: text/markdown

# mathema-mcp

Python pricing library for Mathema MCP. Build market objects and trades from dicts, then compute prices and Greeks.
pip installs **one** wheel for your OS and Python version. Excel is not included.

Docs: [https://help.mathema.com.cn/](https://help.mathema.com.cn/)

## Features

- Build calendars, rates/credit/FX curves, and volatility surfaces, then attach them to options, swaps, and bonds
- Load the same objects from a standard market-data snapshot (JSON): [mcp_marketdata](https://github.com/MDTSH/mcp_marketdata)
- Vanilla closed-form, barrier/digital, American, and path-dependent structures (Monte Carlo)
- Volatility: implied surfaces, historical vol, LocalVol, Heston
- Greeks and related risk measures

User API: `mcp.tools` / `mcp.tool.tools_main`. Underlying classes: `mcp.wrapper`.

## Market-data objects

| Layer | Objects | Role |
|-------|---------|------|
| Conventions | `McpCalendar`, `McpSchedule`, `McpRateConvention` | Holidays, payment schedules, rate conventions |
| Rates curves | `McpYieldCurve` / `McpYieldCurve2`, `McpSwapCurve`, `McpForwardCurve`, `McpParametricCurve` | Discount, zero, swap, forward |
| Bond curves | `McpBondCurve`, `McpBondSpreadCurve` | Bond discount and spread |
| FX curves | `McpFXForwardPointsCurve` / `2`, `McpXccyBasisCurve` | Forward points, cross-currency basis |
| Credit curves | `McpCreditCurve` | Hazard rates, default probabilities |
| Curve building blocks | Overnight / Bill / FRA / Swap / Bond `*CurveData` | Instruments used to bootstrap a curve |
| Volatility | `McpVolSurface`, `McpFXVolSurface`, `McpMktVolSurface` (and `*2`) | Equity/commodity, FX, and quoted market surfaces |
| Rates volatility | `McpSwaptionCube`, `McpCapVolStripping` | Swaption cube, cap stripping |
| Vol models | `McpHistVols`, `McpLocalVol`, `McpHestonModel` | Historical, Dupire, stochastic vol |
| Snapshots | `McpRawMarketManager`, `McpMarketDataJsonReader`, `McpLiveMarketDataStore` | Standard JSON → the objects above |

## Asset coverage

The same option shapes (vanilla / barrier / digital / double-digital / Asian) attach to FX, equity, and commodity.

| Asset | Coverage |
|-------|----------|
| **FX** | Spot, forward, NDF, swap; vanilla/barrier/digital/Asian; strategies; structured forwards |
| **Rates** | IRS, basis swap, cross-currency swap; deposits/loans, FRA; cap/floor, swaption |
| **Credit** | CDS, CLN; discounting on a credit curve |
| **Bonds** | Fixed, amortizing, callable; repo, securities lending, bill discount; bond forward/future; ABS tranches |
| **Equity** | Spot, future, fund; vanilla/barrier/digital; snowball, phoenix, autocall, range accrual |
| **Commodity** | Futures, options; commodity lending |
| **TRS** | Equity TRS, bond TRS |

Convertible bonds are priced on the structured-product path.

## Install

```bash
pip install mathema-mcp
```

For table-style APIs (`FixedLegs` / `McpPayoff` and similar):

```bash
pip install "mathema-mcp[data]"
```

Or install a downloaded wheel:

```bash
pip install path/to/mathema_mcp-1.6.0-cp39-cp39-win_amd64.whl
```

## Usage

The main entry is **dict arguments**, not SWIG positional args:

```python
from mcp.tools import McpCalendar, McpVersion
from mcp.tool.tools_main import McpYieldCurve
from mcp.utils.enums import DayCounter, Frequency, InterpolatedVariable, InterpolationMethod

print(McpVersion())
cal = McpCalendar()
yc = McpYieldCurve({
    "ReferenceDate": "2024-12-13",
    "Tenors": ["1M", "1Y"],
    "ZeroRates": [0.03, 0.035],
    "Calendar": cal,
    "DayCounter": DayCounter.Act365Fixed,
    "Frequency": Frequency.Continuous,
    "Variable": InterpolatedVariable.SIMPLERATES,
    "InterpolationMethod": InterpolationMethod.LINEARINTERPOLATION,
})
```

Dict construction does **not** require numpy or pandas. Those are only needed for the table APIs (`[data]`).

## Supported wheels

| Platform | Python | Tag |
|----------|--------|-----|
| Windows x64 | 3.9–3.13 | `win_amd64` |
| Linux x64 (glibc ≥ 2.28) | 3.9–3.13 | `manylinux_2_28_x86_64` |

## Runtime

Public wheels are built **without CUDA**. A local CUDA toolkit or runtime is not required.
Structured products use CPU multithreading. GPU Monte Carlo is not included.
