Skip to main content

Options, scenarios, books and market regimes in Python

Price European and American options, calculate standard-five or all-ten Greeks, solve implied volatility, revalue scenarios and books, explain P&L, solve targets, and identify market regimes from price histories.

morphiq-sdk is a typed Python client for the MorphIQ API, with synchronous and asynchronous calls. Pricing, Greeks, implied volatility and implied Greeks support ordered batches. Runnable examples and interactive notebooks cover option valuation, sensitivity analysis, scenarios, books and market-regime identification.

See the documentation index for all feature guides and the Python API reference for methods, models and errors.

This client targets the MorphIQ API 0.10 surface (API v1 · Beta, contract label 0.1.0): collection:verb routes, option / market / model requests, grouped response metadata and RFC 9457 problem errors. Methods are grouped by collection and spell each operation's canonical id, for example client.options.price(...) for options.price. The SDK is published on PyPI for this contract; SDK 0.2.1 uses the retired API routes. See the 0.10.0 migration guide and model capabilities: BSM/BS1993 support batches up to 100; QdFp and cash-dividend finite difference support single price and IV.

Quickstart

1. Get API access

Start at the MorphIQ Labs developer portal to get your API key, then set it in your terminal:

export MORPHIQ_API_KEY="YOUR_API_KEY"

MorphIQ() reads MORPHIQ_API_KEY automatically and connects to https://api.morphiqlabs.com.

2. Install the SDK

With Python 3.11 or newer:

python3 -m venv .venv
source .venv/bin/activate
python -m pip install morphiq-sdk

3. Make your first API request

Save the following as price_option.py. It prices a European call with spot and strike of 100, one year to expiry, 20% volatility, and a 5% interest rate:

from morphiq_sdk import Market, MorphIQ, Option, OptionsPriceRequest

request = OptionsPriceRequest(
    option=Option(type="call", exercise_style="european", strike=100.0, time_to_expiry_years=1.0),
    market=Market(spot=100.0, risk_free_rate=0.05, dividend_yield=0.0),
    volatility=0.20,
)

with MorphIQ() as client:
    response = client.options.price(request)
    print(response.model_dump_json(indent=2, exclude_unset=True))

Run it in the same terminal where you set your API key:

python price_option.py

This sends one authenticated POST https://api.morphiqlabs.com/v1/options:price request with model: {"id": "auto"} and prints the JSON response. Example response from the recorded synthetic fixture:

{
  "metadata": {
    "request_id": "fr-18eb4d3a08c36fa2-0000000000000002",
    "service_version": "0.10.0",
    "contract": {
      "version": "0.1.0",
      "sha256": "68985d43f276fe525f46fbc9dc650a172f1303298bcc831da59f8cfee2dbb4c8"
    },
    "engines": [
      {
        "name": "morphiq-risk",
        "version": "0.46.1",
        "revision": "1550e4e41b243b8a978677bc5e9b46916c08cb0e"
      }
    ]
  },
  "result": {
    "price": 10.450583572185577,
    "model": {
      "id": "black_scholes_merton",
      "version": "black_scholes_merton/1"
    }
  }
}

Your request ID and engine metadata will reflect the live service. This fixture was recorded in open development mode; authenticated responses also report commercial charges in metadata.billing.charged_cu, the plan in metadata.policy and the budget estimate in metadata.budget. Keep the request ID for support. See the quickstart guide for input units, async usage, configuration and errors.

Scenarios and books

The SDK supports client.options.revalue and client.options.solve_scenario, plus client.books.revalue, client.books.explain and client.books.solve_scenario. The async client exposes the same methods. All five support cost quotation and a per-request CU ceiling. Results preserve partial failures, solver uncertainty, signed positions, strategy membership and expiry/strike P&L attribution.

See the scenario and book guide and the standalone notebooks in notebooks/scenarios/ and notebooks/books/.

Repository examples and notebooks

The executable examples and Docker notebooks live in the repository. Clone it to use either:

git clone https://github.com/MorphIQ-Labs/morphiq-sdk-python.git
cd morphiq-sdk-python

Run the examples

From the repository root, with your Python environment active and API key set:

python -m pip install -e .
python -m examples.quickstart

This sends two requests, for European and American pricing. Run python -m examples.price_async for the async version, or python -m examples.price_european and python -m examples.price_american individually. See the executable cookbook for all examples.

Start a notebook with Docker

With Docker running, from the repository root, set your API key and start the notebook:

export MORPHIQ_API_KEY="YOUR_API_KEY"
docker compose up --build

Open the local token-authenticated URL printed by Jupyter to reach Start Here. Choose an analysis workspace and run all cells once to display its controls:

  • Option pricing: European/American and model dropdowns, call/put selection, editable assumptions, automatic Yahoo daily/intraday underlying prices, a valuation comparison table, a price-and-Greeks panel, an implied-volatility solver, implied-Greeks premium analysis, a session CU total and a spot-sensitivity chart.
  • Regime analysis: ticker selection, Yahoo daily/intraday price history, latest regime assessment, score charts and provenance.

Compose passes your API key into the container; if unset, the workspace prompts for it. Setup and control changes make no MorphIQ requests. Pricing loads Yahoo prices automatically on setup and when the ticker or interval changes. In regime, Analyze regime loads Yahoo history and displays the complete assessment in one click. Click Price option or Price + Greeks, Solve IV, Analyze premium or Analyze regime for one request. Spot sensitivity submits nine scenarios in one batch request. Yahoo data remains in memory. Dependencies are installed at build time, and notebook edits persist in a named volume.

Stop with Ctrl-C, then docker compose down; the workspace is retained. If port 8888 is occupied, use MORPHIQ_NOTEBOOK_PORT=8889 docker compose up --build. See notebook instructions for networking and persistence.

Development

From a repository checkout, use Python 3.11 or newer. CI checks Python 3.11 and 3.14.

python3 -m venv .venv
source .venv/bin/activate
python -m pip install --require-hashes -r requirements-dev.txt
python -m pip install --no-build-isolation -e .
python -m ruff check .
python -m ruff format --check .
python -m mypy
python -m pytest -q
python scripts/generate_notebook.py --check
python scripts/check_package.py

Versions are managed through reviewed release PRs; no version environment variable is needed. check_package.py builds an sdist and a wheel from that sdist, then installs the wheel in a fresh environment outside the checkout. Routine tests use local fixture replay and need no real credentials; native API integration is opt-in. See CONTRIBUTING.md and RELEASE.md.

Clients make no automatic retries and do not follow redirects. A timeout may leave work charged. Only metadata.billing.quoted_cu and metadata.billing.charged_cu report commercial CUs. A missing charged_cu means unreported, not zero. Optional members are omitted by the API, never sent as null. Response enums may gain values: the SDK keeps an unknown value as a plain string and an unknown variant as an Unrecognized model instead of failing.

The SDK preserves server results, numerical diagnostics, request IDs, engine provenance and commercial Compute Units (CU). Numerical engines, model selection, policy decisions and charging remain server-owned. The client will not duplicate pricing engines or calculate authoritative customer charges.

Project layout

src/morphiq_sdk/    Installable, typed Python package
scripts/           Development and package verification
examples/          Runnable pricing, Greeks, IV, implied-Greeks, batch and regime examples
notebooks/         Quickstart and standalone feature notebooks
contracts/         Reviewed OpenAPI snapshot, digest and source provenance
docker/            Non-root notebook startup and workspace seeding
docs/              Usage guides and contract documentation
.github/           CI and pull request template

License

The SDK, examples and notebooks are licensed under the MIT License.

See the rate card and request quotes for zero-CU discovery, conditional quotes, and the optional max_cu execution ceiling.

Metadata

Release files for morphiq-sdk 0.3.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 morphiq-sdk 0.3.1
File Size Uploaded Provenance Actions
morphiq_sdk-0.3.1.tar.gz 78.5 kB With provenance Details for morphiq_sdk-0.3.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for morphiq-sdk 0.3.1
File Interpreter ABI Platform Actions
morphiq_sdk-0.3.1-py3-none-any.whl Python 3 none any Details for morphiq_sdk-0.3.1-py3-none-any.whl

Total release size: 115.8 kB

Release files / morphiq_sdk-0.3.1.tar.gz

Download URL morphiq_sdk-0.3.1.tar.gz
Size 78.5 kB
Tags Source
SHA-256 checksum
How to use checksums
6c50d329ce42086ea1557d31a8529244148ce017871e8ebe81d4e75c7eca01e9
BLAKE2b-256 checksum
How to use checksums
eee4cf608fbcfe6750379d8cc3e9d43f5cb6673b5945ab18c55b7b2c17ef63ab
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 25, 2026.

Transparency log

Release files / morphiq_sdk-0.3.1-py3-none-any.whl

Download URL morphiq_sdk-0.3.1-py3-none-any.whl
Size 37.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
500704de5fe70ac1b428f5cc719e565265f823b3e56b08d60ab273c323a9bf99
BLAKE2b-256 checksum
How to use checksums
f23a1573f326efaa8491cb034674d49065b73abbe36af20c0a02de03aa9332cc
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 25, 2026.

Transparency log

Security for morphiq-sdk 0.3.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 morphiq_sdk-0.3.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 25, 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