morphiq-sdk 0.2.0__tar.gz → 0.3.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {morphiq_sdk-0.2.0 → morphiq_sdk-0.3.0}/PKG-INFO +56 -41
- {morphiq_sdk-0.2.0 → morphiq_sdk-0.3.0}/README.md +55 -40
- {morphiq_sdk-0.2.0 → morphiq_sdk-0.3.0}/examples/README.md +58 -13
- {morphiq_sdk-0.2.0 → morphiq_sdk-0.3.0}/examples/batch_price.py +49 -32
- {morphiq_sdk-0.2.0 → morphiq_sdk-0.3.0}/examples/batch_price_async.py +49 -32
- morphiq_sdk-0.3.0/examples/book_explain.py +85 -0
- morphiq_sdk-0.3.0/examples/book_revalue.py +85 -0
- morphiq_sdk-0.3.0/examples/book_solve.py +81 -0
- {morphiq_sdk-0.2.0 → morphiq_sdk-0.3.0}/examples/chunked_price.py +37 -20
- {morphiq_sdk-0.2.0 → morphiq_sdk-0.3.0}/examples/chunked_price_async.py +39 -20
- {morphiq_sdk-0.2.0 → morphiq_sdk-0.3.0}/examples/greeks.py +31 -17
- {morphiq_sdk-0.2.0 → morphiq_sdk-0.3.0}/examples/greeks_async.py +31 -17
- {morphiq_sdk-0.2.0 → morphiq_sdk-0.3.0}/examples/identify_regime.py +66 -25
- {morphiq_sdk-0.2.0 → morphiq_sdk-0.3.0}/examples/identify_regime_async.py +66 -25
- morphiq_sdk-0.2.0/examples/analytics.py → morphiq_sdk-0.3.0/examples/implied_greeks.py +33 -20
- morphiq_sdk-0.2.0/examples/analytics_async.py → morphiq_sdk-0.3.0/examples/implied_greeks_async.py +27 -20
- {morphiq_sdk-0.2.0 → morphiq_sdk-0.3.0}/examples/implied_volatility.py +31 -17
- {morphiq_sdk-0.2.0 → morphiq_sdk-0.3.0}/examples/implied_volatility_async.py +25 -17
- morphiq_sdk-0.2.0/examples/pricing_models.py → morphiq_sdk-0.3.0/examples/list_models.py +7 -3
- morphiq_sdk-0.3.0/examples/option_revalue.py +48 -0
- morphiq_sdk-0.3.0/examples/option_solve.py +50 -0
- {morphiq_sdk-0.2.0 → morphiq_sdk-0.3.0}/examples/price_american.py +31 -17
- morphiq_sdk-0.3.0/examples/price_async.py +97 -0
- {morphiq_sdk-0.2.0 → morphiq_sdk-0.3.0}/examples/price_european.py +31 -17
- {morphiq_sdk-0.2.0 → morphiq_sdk-0.3.0}/examples/provider_regime.py +6 -5
- morphiq_sdk-0.3.0/examples/quickstart.py +96 -0
- morphiq_sdk-0.3.0/examples/rate_card_quote.py +105 -0
- morphiq_sdk-0.3.0/examples/solver_app/README.md +29 -0
- morphiq_sdk-0.3.0/examples/solver_app/app.js +121 -0
- morphiq_sdk-0.3.0/examples/solver_app/app.py +215 -0
- morphiq_sdk-0.3.0/examples/solver_app/index.html +72 -0
- morphiq_sdk-0.3.0/examples/solver_app/style.css +2 -0
- morphiq_sdk-0.2.0/examples/greeks_standard.py → morphiq_sdk-0.3.0/examples/standard_greeks.py +32 -18
- {morphiq_sdk-0.2.0 → morphiq_sdk-0.3.0}/examples/tabular_price.py +27 -14
- {morphiq_sdk-0.2.0 → morphiq_sdk-0.3.0}/notebooks/README.md +17 -4
- morphiq_sdk-0.3.0/notebooks/books/explain.ipynb +31 -0
- morphiq_sdk-0.3.0/notebooks/books/revalue.ipynb +31 -0
- morphiq_sdk-0.3.0/notebooks/books/solve.ipynb +31 -0
- {morphiq_sdk-0.2.0 → morphiq_sdk-0.3.0}/notebooks/cost/quotation.ipynb +38 -22
- {morphiq_sdk-0.2.0 → morphiq_sdk-0.3.0}/notebooks/pricing/models.ipynb +17 -5
- {morphiq_sdk-0.2.0 → morphiq_sdk-0.3.0}/notebooks/pricing/options.ipynb +182 -86
- {morphiq_sdk-0.2.0 → morphiq_sdk-0.3.0}/notebooks/pricing/standard-five.ipynb +41 -14
- {morphiq_sdk-0.2.0 → morphiq_sdk-0.3.0}/notebooks/regime/identification.ipynb +110 -28
- morphiq_sdk-0.3.0/notebooks/scenarios/revalue.ipynb +31 -0
- morphiq_sdk-0.3.0/notebooks/scenarios/solve.ipynb +31 -0
- morphiq_sdk-0.3.0/notebooks/start-here.ipynb +23 -0
- {morphiq_sdk-0.2.0 → morphiq_sdk-0.3.0}/pyproject.toml +1 -1
- morphiq_sdk-0.3.0/src/morphiq_sdk/__init__.py +346 -0
- morphiq_sdk-0.3.0/src/morphiq_sdk/client.py +1021 -0
- {morphiq_sdk-0.2.0 → morphiq_sdk-0.3.0}/src/morphiq_sdk/errors.py +16 -14
- morphiq_sdk-0.3.0/src/morphiq_sdk/models.py +1619 -0
- {morphiq_sdk-0.2.0 → morphiq_sdk-0.3.0}/src/morphiq_sdk/pandas.py +23 -23
- {morphiq_sdk-0.2.0 → morphiq_sdk-0.3.0}/src/morphiq_sdk/workflows.py +15 -17
- morphiq_sdk-0.2.0/examples/cost_quote.py +0 -77
- morphiq_sdk-0.2.0/examples/price_async.py +0 -78
- morphiq_sdk-0.2.0/examples/quickstart.py +0 -77
- morphiq_sdk-0.2.0/notebooks/start-here.ipynb +0 -23
- morphiq_sdk-0.2.0/src/morphiq_sdk/__init__.py +0 -123
- morphiq_sdk-0.2.0/src/morphiq_sdk/client.py +0 -714
- morphiq_sdk-0.2.0/src/morphiq_sdk/models.py +0 -603
- {morphiq_sdk-0.2.0 → morphiq_sdk-0.3.0}/.gitignore +0 -0
- {morphiq_sdk-0.2.0 → morphiq_sdk-0.3.0}/LICENSE +0 -0
- {morphiq_sdk-0.2.0 → morphiq_sdk-0.3.0}/examples/__init__.py +0 -0
- {morphiq_sdk-0.2.0 → morphiq_sdk-0.3.0}/src/morphiq_sdk/market_data.py +0 -0
- {morphiq_sdk-0.2.0 → morphiq_sdk-0.3.0}/src/morphiq_sdk/py.typed +0 -0
- {morphiq_sdk-0.2.0 → morphiq_sdk-0.3.0}/src/morphiq_sdk_yahoo/__init__.py +0 -0
- {morphiq_sdk-0.2.0 → morphiq_sdk-0.3.0}/src/morphiq_sdk_yahoo/py.typed +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.5
|
|
2
2
|
Name: morphiq-sdk
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.3.0
|
|
4
4
|
Summary: Option pricing, Greeks, implied volatility and market regime identification through a Python API client
|
|
5
5
|
Project-URL: Homepage, https://developers.morphiqlabs.com
|
|
6
6
|
Project-URL: Documentation, https://github.com/MorphIQ-Labs/morphiq-sdk-python/blob/main/docs/README.md
|
|
@@ -40,17 +40,21 @@ Price European and American options, calculate standard-five or all-ten Greeks,
|
|
|
40
40
|
volatility, and identify market regimes from price histories.
|
|
41
41
|
|
|
42
42
|
`morphiq-sdk` is a typed Python client for the MorphIQ API, with synchronous and
|
|
43
|
-
asynchronous calls. Pricing, Greeks, implied volatility and
|
|
43
|
+
asynchronous calls. Pricing, Greeks, implied volatility and implied Greeks
|
|
44
44
|
support ordered batches. Runnable examples and interactive notebooks cover option
|
|
45
45
|
valuation, sensitivity analysis and market-regime identification.
|
|
46
46
|
|
|
47
47
|
See the [documentation index](https://github.com/MorphIQ-Labs/morphiq-sdk-python/blob/main/docs/README.md) for all feature guides and the
|
|
48
48
|
[Python API reference](https://github.com/MorphIQ-Labs/morphiq-sdk-python/blob/main/docs/API.md) for methods, models and errors.
|
|
49
49
|
|
|
50
|
-
This client targets API **
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
50
|
+
This client targets the MorphIQ API **0.10.0** contract (**API v1 · Beta**,
|
|
51
|
+
contract label `0.1.0`): `collection:verb` routes, `option` / `market` / `model`
|
|
52
|
+
requests, grouped response metadata and RFC 9457 problem errors. Methods are
|
|
53
|
+
grouped by collection and spell each operation's canonical id, for example
|
|
54
|
+
`client.options.price(...)` for `options.price`. SDK 0.2.1 on PyPI targets the
|
|
55
|
+
earlier contract; this client is unreleased until the next SDK release. See the
|
|
56
|
+
[0.10.0 migration guide](https://github.com/MorphIQ-Labs/morphiq-sdk-python/blob/main/docs/API_0_10_ADOPTION.md)
|
|
57
|
+
and [model capabilities](https://github.com/MorphIQ-Labs/morphiq-sdk-python/blob/main/docs/MODELS.md): BSM/BS1993 support batches
|
|
54
58
|
up to 100; QdFp and cash-dividend finite difference support single price and IV.
|
|
55
59
|
|
|
56
60
|
## Quickstart
|
|
@@ -83,21 +87,16 @@ Save the following as `price_option.py`. It prices a European call with spot and
|
|
|
83
87
|
strike of 100, one year to expiry, 20% volatility, and a 5% interest rate:
|
|
84
88
|
|
|
85
89
|
```python
|
|
86
|
-
from morphiq_sdk import MorphIQ,
|
|
87
|
-
|
|
88
|
-
request =
|
|
89
|
-
exercise_style="european",
|
|
90
|
-
|
|
91
|
-
spot=100.0,
|
|
92
|
-
strike=100.0,
|
|
93
|
-
time_to_expiry_years=1.0,
|
|
94
|
-
risk_free_rate=0.05,
|
|
95
|
-
dividend_yield=0.0,
|
|
90
|
+
from morphiq_sdk import Market, MorphIQ, Option, OptionsPriceRequest
|
|
91
|
+
|
|
92
|
+
request = OptionsPriceRequest(
|
|
93
|
+
option=Option(type="call", exercise_style="european", strike=100.0, time_to_expiry_years=1.0),
|
|
94
|
+
market=Market(spot=100.0, risk_free_rate=0.05, dividend_yield=0.0),
|
|
96
95
|
volatility=0.20,
|
|
97
96
|
)
|
|
98
97
|
|
|
99
98
|
with MorphIQ() as client:
|
|
100
|
-
response = client.price(request)
|
|
99
|
+
response = client.options.price(request)
|
|
101
100
|
print(response.model_dump_json(indent=2, exclude_unset=True))
|
|
102
101
|
```
|
|
103
102
|
|
|
@@ -107,41 +106,56 @@ Run it in the same terminal where you set your API key:
|
|
|
107
106
|
python price_option.py
|
|
108
107
|
```
|
|
109
108
|
|
|
110
|
-
This sends one authenticated `POST https://api.morphiqlabs.com/v1/price`
|
|
111
|
-
and prints the JSON response. Example
|
|
109
|
+
This sends one authenticated `POST https://api.morphiqlabs.com/v1/options:price`
|
|
110
|
+
request with `model: {"id": "auto"}` and prints the JSON response. Example
|
|
111
|
+
response from the recorded synthetic fixture:
|
|
112
112
|
|
|
113
113
|
```json
|
|
114
114
|
{
|
|
115
115
|
"metadata": {
|
|
116
|
-
"request_id": "fr-
|
|
117
|
-
"
|
|
118
|
-
"
|
|
116
|
+
"request_id": "fr-18eb4d3a08c36fa2-0000000000000002",
|
|
117
|
+
"service_version": "0.10.0",
|
|
118
|
+
"contract": {
|
|
119
|
+
"version": "0.1.0",
|
|
120
|
+
"sha256": "68985d43f276fe525f46fbc9dc650a172f1303298bcc831da59f8cfee2dbb4c8"
|
|
121
|
+
},
|
|
119
122
|
"engines": [
|
|
120
123
|
{
|
|
121
124
|
"name": "morphiq-risk",
|
|
122
|
-
"version": "0.
|
|
123
|
-
"revision": "
|
|
125
|
+
"version": "0.46.1",
|
|
126
|
+
"revision": "1550e4e41b243b8a978677bc5e9b46916c08cb0e"
|
|
124
127
|
}
|
|
125
|
-
]
|
|
126
|
-
"units_charged": 1,
|
|
127
|
-
"compute_schedule_version": "2026-09-11"
|
|
128
|
+
]
|
|
128
129
|
},
|
|
129
130
|
"result": {
|
|
130
|
-
"price": 10.
|
|
131
|
-
"
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
131
|
+
"price": 10.450583572185577,
|
|
132
|
+
"model": {
|
|
133
|
+
"id": "black_scholes_merton",
|
|
134
|
+
"version": "black_scholes_merton/1"
|
|
135
|
+
}
|
|
135
136
|
}
|
|
136
137
|
}
|
|
137
138
|
```
|
|
138
139
|
|
|
139
140
|
Your request ID and engine metadata will reflect the live service. This fixture
|
|
140
|
-
was recorded in open development mode; authenticated responses
|
|
141
|
-
commercial charges in `metadata.
|
|
141
|
+
was recorded in open development mode; authenticated responses also report
|
|
142
|
+
commercial charges in `metadata.billing.charged_cu`, the plan in
|
|
143
|
+
`metadata.policy` and the budget estimate in `metadata.budget`. Keep the request
|
|
144
|
+
ID for support.
|
|
142
145
|
See [the quickstart guide](https://github.com/MorphIQ-Labs/morphiq-sdk-python/blob/main/docs/QUICKSTART.md)
|
|
143
146
|
for input units, async usage, configuration and errors.
|
|
144
147
|
|
|
148
|
+
## Scenarios and books
|
|
149
|
+
|
|
150
|
+
The SDK supports `client.options.revalue` and `client.options.solve_scenario`,
|
|
151
|
+
plus `client.books.revalue`, `client.books.explain` and `client.books.solve_scenario`.
|
|
152
|
+
The async client exposes the same methods. All five support cost quotation and a
|
|
153
|
+
per-request CU ceiling. Results preserve partial failures, solver uncertainty,
|
|
154
|
+
signed positions, strategy membership and expiry/strike P&L attribution.
|
|
155
|
+
|
|
156
|
+
See the [scenario and book guide](https://github.com/MorphIQ-Labs/morphiq-sdk-python/blob/main/docs/SCENARIOS.md)
|
|
157
|
+
and the standalone notebooks in `notebooks/scenarios/` and `notebooks/books/`.
|
|
158
|
+
|
|
145
159
|
## Repository examples and notebooks
|
|
146
160
|
|
|
147
161
|
The executable examples and Docker notebooks live in the repository. Clone it
|
|
@@ -184,7 +198,7 @@ Choose an analysis workspace and run all cells once to display its controls:
|
|
|
184
198
|
- [Option pricing](https://github.com/MorphIQ-Labs/morphiq-sdk-python/blob/main/notebooks/pricing/options.ipynb): European/American and model
|
|
185
199
|
dropdowns, call/put selection, editable assumptions, automatic Yahoo daily/intraday underlying prices,
|
|
186
200
|
a valuation comparison table, a price-and-Greeks panel, an implied-volatility solver,
|
|
187
|
-
|
|
201
|
+
implied-Greeks premium analysis, a session CU total and a spot-sensitivity chart.
|
|
188
202
|
- [Regime analysis](https://github.com/MorphIQ-Labs/morphiq-sdk-python/blob/main/notebooks/regime/identification.ipynb): ticker selection,
|
|
189
203
|
Yahoo daily/intraday price history, latest regime assessment, score charts and provenance.
|
|
190
204
|
|
|
@@ -224,10 +238,11 @@ no real credentials; native API integration is opt-in. See
|
|
|
224
238
|
[CONTRIBUTING.md](https://github.com/MorphIQ-Labs/morphiq-sdk-python/blob/main/CONTRIBUTING.md) and [RELEASE.md](https://github.com/MorphIQ-Labs/morphiq-sdk-python/blob/main/RELEASE.md).
|
|
225
239
|
|
|
226
240
|
Clients make no automatic retries and do not follow redirects. A timeout
|
|
227
|
-
may leave work charged. Only `
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
241
|
+
may leave work charged. Only `metadata.billing.quoted_cu` and
|
|
242
|
+
`metadata.billing.charged_cu` report commercial CUs. A missing `charged_cu` means
|
|
243
|
+
unreported, not zero. Optional members are omitted by the API, never sent as
|
|
244
|
+
null. Response enums may gain values: the SDK keeps an unknown value as a plain
|
|
245
|
+
string and an unknown variant as an `Unrecognized` model instead of failing.
|
|
231
246
|
|
|
232
247
|
The SDK preserves server results, numerical diagnostics, request IDs, engine
|
|
233
248
|
provenance and commercial Compute Units (CU). Numerical engines, model selection,
|
|
@@ -239,7 +254,7 @@ pricing engines or calculate authoritative customer charges.
|
|
|
239
254
|
```text
|
|
240
255
|
src/morphiq_sdk/ Installable, typed Python package
|
|
241
256
|
scripts/ Development and package verification
|
|
242
|
-
examples/ Runnable pricing, Greeks, IV,
|
|
257
|
+
examples/ Runnable pricing, Greeks, IV, implied-Greeks, batch and regime examples
|
|
243
258
|
notebooks/ Quickstart and standalone feature notebooks
|
|
244
259
|
contracts/ Reviewed OpenAPI snapshot, digest and source provenance
|
|
245
260
|
docker/ Non-root notebook startup and workspace seeding
|
|
@@ -252,4 +267,4 @@ docs/ Usage guides and contract documentation
|
|
|
252
267
|
The SDK, examples and notebooks are licensed under the
|
|
253
268
|
[MIT License](https://github.com/MorphIQ-Labs/morphiq-sdk-python/blob/main/LICENSE).
|
|
254
269
|
|
|
255
|
-
See [
|
|
270
|
+
See [the rate card and request quotes](docs/RATE_CARD.md) for zero-CU discovery, conditional quotes, and the optional `max_cu` execution ceiling.
|
|
@@ -4,17 +4,21 @@ Price European and American options, calculate standard-five or all-ten Greeks,
|
|
|
4
4
|
volatility, and identify market regimes from price histories.
|
|
5
5
|
|
|
6
6
|
`morphiq-sdk` is a typed Python client for the MorphIQ API, with synchronous and
|
|
7
|
-
asynchronous calls. Pricing, Greeks, implied volatility and
|
|
7
|
+
asynchronous calls. Pricing, Greeks, implied volatility and implied Greeks
|
|
8
8
|
support ordered batches. Runnable examples and interactive notebooks cover option
|
|
9
9
|
valuation, sensitivity analysis and market-regime identification.
|
|
10
10
|
|
|
11
11
|
See the [documentation index](https://github.com/MorphIQ-Labs/morphiq-sdk-python/blob/main/docs/README.md) for all feature guides and the
|
|
12
12
|
[Python API reference](https://github.com/MorphIQ-Labs/morphiq-sdk-python/blob/main/docs/API.md) for methods, models and errors.
|
|
13
13
|
|
|
14
|
-
This client targets API **
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
14
|
+
This client targets the MorphIQ API **0.10.0** contract (**API v1 · Beta**,
|
|
15
|
+
contract label `0.1.0`): `collection:verb` routes, `option` / `market` / `model`
|
|
16
|
+
requests, grouped response metadata and RFC 9457 problem errors. Methods are
|
|
17
|
+
grouped by collection and spell each operation's canonical id, for example
|
|
18
|
+
`client.options.price(...)` for `options.price`. SDK 0.2.1 on PyPI targets the
|
|
19
|
+
earlier contract; this client is unreleased until the next SDK release. See the
|
|
20
|
+
[0.10.0 migration guide](https://github.com/MorphIQ-Labs/morphiq-sdk-python/blob/main/docs/API_0_10_ADOPTION.md)
|
|
21
|
+
and [model capabilities](https://github.com/MorphIQ-Labs/morphiq-sdk-python/blob/main/docs/MODELS.md): BSM/BS1993 support batches
|
|
18
22
|
up to 100; QdFp and cash-dividend finite difference support single price and IV.
|
|
19
23
|
|
|
20
24
|
## Quickstart
|
|
@@ -47,21 +51,16 @@ Save the following as `price_option.py`. It prices a European call with spot and
|
|
|
47
51
|
strike of 100, one year to expiry, 20% volatility, and a 5% interest rate:
|
|
48
52
|
|
|
49
53
|
```python
|
|
50
|
-
from morphiq_sdk import MorphIQ,
|
|
51
|
-
|
|
52
|
-
request =
|
|
53
|
-
exercise_style="european",
|
|
54
|
-
|
|
55
|
-
spot=100.0,
|
|
56
|
-
strike=100.0,
|
|
57
|
-
time_to_expiry_years=1.0,
|
|
58
|
-
risk_free_rate=0.05,
|
|
59
|
-
dividend_yield=0.0,
|
|
54
|
+
from morphiq_sdk import Market, MorphIQ, Option, OptionsPriceRequest
|
|
55
|
+
|
|
56
|
+
request = OptionsPriceRequest(
|
|
57
|
+
option=Option(type="call", exercise_style="european", strike=100.0, time_to_expiry_years=1.0),
|
|
58
|
+
market=Market(spot=100.0, risk_free_rate=0.05, dividend_yield=0.0),
|
|
60
59
|
volatility=0.20,
|
|
61
60
|
)
|
|
62
61
|
|
|
63
62
|
with MorphIQ() as client:
|
|
64
|
-
response = client.price(request)
|
|
63
|
+
response = client.options.price(request)
|
|
65
64
|
print(response.model_dump_json(indent=2, exclude_unset=True))
|
|
66
65
|
```
|
|
67
66
|
|
|
@@ -71,41 +70,56 @@ Run it in the same terminal where you set your API key:
|
|
|
71
70
|
python price_option.py
|
|
72
71
|
```
|
|
73
72
|
|
|
74
|
-
This sends one authenticated `POST https://api.morphiqlabs.com/v1/price`
|
|
75
|
-
and prints the JSON response. Example
|
|
73
|
+
This sends one authenticated `POST https://api.morphiqlabs.com/v1/options:price`
|
|
74
|
+
request with `model: {"id": "auto"}` and prints the JSON response. Example
|
|
75
|
+
response from the recorded synthetic fixture:
|
|
76
76
|
|
|
77
77
|
```json
|
|
78
78
|
{
|
|
79
79
|
"metadata": {
|
|
80
|
-
"request_id": "fr-
|
|
81
|
-
"
|
|
82
|
-
"
|
|
80
|
+
"request_id": "fr-18eb4d3a08c36fa2-0000000000000002",
|
|
81
|
+
"service_version": "0.10.0",
|
|
82
|
+
"contract": {
|
|
83
|
+
"version": "0.1.0",
|
|
84
|
+
"sha256": "68985d43f276fe525f46fbc9dc650a172f1303298bcc831da59f8cfee2dbb4c8"
|
|
85
|
+
},
|
|
83
86
|
"engines": [
|
|
84
87
|
{
|
|
85
88
|
"name": "morphiq-risk",
|
|
86
|
-
"version": "0.
|
|
87
|
-
"revision": "
|
|
89
|
+
"version": "0.46.1",
|
|
90
|
+
"revision": "1550e4e41b243b8a978677bc5e9b46916c08cb0e"
|
|
88
91
|
}
|
|
89
|
-
]
|
|
90
|
-
"units_charged": 1,
|
|
91
|
-
"compute_schedule_version": "2026-09-11"
|
|
92
|
+
]
|
|
92
93
|
},
|
|
93
94
|
"result": {
|
|
94
|
-
"price": 10.
|
|
95
|
-
"
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
95
|
+
"price": 10.450583572185577,
|
|
96
|
+
"model": {
|
|
97
|
+
"id": "black_scholes_merton",
|
|
98
|
+
"version": "black_scholes_merton/1"
|
|
99
|
+
}
|
|
99
100
|
}
|
|
100
101
|
}
|
|
101
102
|
```
|
|
102
103
|
|
|
103
104
|
Your request ID and engine metadata will reflect the live service. This fixture
|
|
104
|
-
was recorded in open development mode; authenticated responses
|
|
105
|
-
commercial charges in `metadata.
|
|
105
|
+
was recorded in open development mode; authenticated responses also report
|
|
106
|
+
commercial charges in `metadata.billing.charged_cu`, the plan in
|
|
107
|
+
`metadata.policy` and the budget estimate in `metadata.budget`. Keep the request
|
|
108
|
+
ID for support.
|
|
106
109
|
See [the quickstart guide](https://github.com/MorphIQ-Labs/morphiq-sdk-python/blob/main/docs/QUICKSTART.md)
|
|
107
110
|
for input units, async usage, configuration and errors.
|
|
108
111
|
|
|
112
|
+
## Scenarios and books
|
|
113
|
+
|
|
114
|
+
The SDK supports `client.options.revalue` and `client.options.solve_scenario`,
|
|
115
|
+
plus `client.books.revalue`, `client.books.explain` and `client.books.solve_scenario`.
|
|
116
|
+
The async client exposes the same methods. All five support cost quotation and a
|
|
117
|
+
per-request CU ceiling. Results preserve partial failures, solver uncertainty,
|
|
118
|
+
signed positions, strategy membership and expiry/strike P&L attribution.
|
|
119
|
+
|
|
120
|
+
See the [scenario and book guide](https://github.com/MorphIQ-Labs/morphiq-sdk-python/blob/main/docs/SCENARIOS.md)
|
|
121
|
+
and the standalone notebooks in `notebooks/scenarios/` and `notebooks/books/`.
|
|
122
|
+
|
|
109
123
|
## Repository examples and notebooks
|
|
110
124
|
|
|
111
125
|
The executable examples and Docker notebooks live in the repository. Clone it
|
|
@@ -148,7 +162,7 @@ Choose an analysis workspace and run all cells once to display its controls:
|
|
|
148
162
|
- [Option pricing](https://github.com/MorphIQ-Labs/morphiq-sdk-python/blob/main/notebooks/pricing/options.ipynb): European/American and model
|
|
149
163
|
dropdowns, call/put selection, editable assumptions, automatic Yahoo daily/intraday underlying prices,
|
|
150
164
|
a valuation comparison table, a price-and-Greeks panel, an implied-volatility solver,
|
|
151
|
-
|
|
165
|
+
implied-Greeks premium analysis, a session CU total and a spot-sensitivity chart.
|
|
152
166
|
- [Regime analysis](https://github.com/MorphIQ-Labs/morphiq-sdk-python/blob/main/notebooks/regime/identification.ipynb): ticker selection,
|
|
153
167
|
Yahoo daily/intraday price history, latest regime assessment, score charts and provenance.
|
|
154
168
|
|
|
@@ -188,10 +202,11 @@ no real credentials; native API integration is opt-in. See
|
|
|
188
202
|
[CONTRIBUTING.md](https://github.com/MorphIQ-Labs/morphiq-sdk-python/blob/main/CONTRIBUTING.md) and [RELEASE.md](https://github.com/MorphIQ-Labs/morphiq-sdk-python/blob/main/RELEASE.md).
|
|
189
203
|
|
|
190
204
|
Clients make no automatic retries and do not follow redirects. A timeout
|
|
191
|
-
may leave work charged. Only `
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
205
|
+
may leave work charged. Only `metadata.billing.quoted_cu` and
|
|
206
|
+
`metadata.billing.charged_cu` report commercial CUs. A missing `charged_cu` means
|
|
207
|
+
unreported, not zero. Optional members are omitted by the API, never sent as
|
|
208
|
+
null. Response enums may gain values: the SDK keeps an unknown value as a plain
|
|
209
|
+
string and an unknown variant as an `Unrecognized` model instead of failing.
|
|
195
210
|
|
|
196
211
|
The SDK preserves server results, numerical diagnostics, request IDs, engine
|
|
197
212
|
provenance and commercial Compute Units (CU). Numerical engines, model selection,
|
|
@@ -203,7 +218,7 @@ pricing engines or calculate authoritative customer charges.
|
|
|
203
218
|
```text
|
|
204
219
|
src/morphiq_sdk/ Installable, typed Python package
|
|
205
220
|
scripts/ Development and package verification
|
|
206
|
-
examples/ Runnable pricing, Greeks, IV,
|
|
221
|
+
examples/ Runnable pricing, Greeks, IV, implied-Greeks, batch and regime examples
|
|
207
222
|
notebooks/ Quickstart and standalone feature notebooks
|
|
208
223
|
contracts/ Reviewed OpenAPI snapshot, digest and source provenance
|
|
209
224
|
docker/ Non-root notebook startup and workspace seeding
|
|
@@ -216,4 +231,4 @@ docs/ Usage guides and contract documentation
|
|
|
216
231
|
The SDK, examples and notebooks are licensed under the
|
|
217
232
|
[MIT License](https://github.com/MorphIQ-Labs/morphiq-sdk-python/blob/main/LICENSE).
|
|
218
233
|
|
|
219
|
-
See [
|
|
234
|
+
See [the rate card and request quotes](docs/RATE_CARD.md) for zero-CU discovery, conditional quotes, and the optional `max_cu` execution ceiling.
|
|
@@ -23,8 +23,9 @@ python examples/greeks.py
|
|
|
23
23
|
python examples/greeks_async.py
|
|
24
24
|
python examples/implied_volatility.py
|
|
25
25
|
python examples/implied_volatility_async.py
|
|
26
|
-
python examples/
|
|
27
|
-
python examples/
|
|
26
|
+
python examples/standard_greeks.py
|
|
27
|
+
python examples/implied_greeks.py
|
|
28
|
+
python examples/implied_greeks_async.py
|
|
28
29
|
python examples/batch_price.py
|
|
29
30
|
python examples/batch_price_async.py
|
|
30
31
|
```
|
|
@@ -48,21 +49,32 @@ See [the quickstart](../docs/QUICKSTART.md) and [all feature guides](../docs/REA
|
|
|
48
49
|
Start Here links to the interactive workspaces; the standalone scripts remain the
|
|
49
50
|
SDK usage demonstrations.
|
|
50
51
|
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
52
|
+
Every request is built from the same parts: an `Option` (type, exercise style,
|
|
53
|
+
strike, time to expiry), a `Market` (spot, rates, optional cash dividends), a
|
|
54
|
+
`volatility` or a `market_price`, and a `ModelSelection`. Methods are grouped by
|
|
55
|
+
the API's collections and spell its canonical operation ids: `client.options.price()`
|
|
56
|
+
is `options.price` (`POST /v1/options:price`). Results report the resolved
|
|
57
|
+
`model.id` and its exact `model.version`; a charge is read from
|
|
58
|
+
`metadata.billing.charged_cu`.
|
|
59
|
+
|
|
60
|
+
The Greeks examples submit `OptionsGreeksRequest` to `client.options.greeks()` and
|
|
61
|
+
display the price plus all ten derivatives, with the same model/charge evidence and error
|
|
62
|
+
handling. Values use annual time units and unit volatility/rate bases. The
|
|
63
|
+
standard-Greeks example calls `client.options.standard_greeks()` for the price and
|
|
64
|
+
delta, gamma, theta, vega and rho. See [the Greeks guide](../docs/GREEKS.md).
|
|
55
65
|
|
|
56
66
|
The implied-volatility examples pass an explicit option premium to
|
|
57
|
-
`client.implied_volatility()` and print IV, residual with its basis, iterations,
|
|
67
|
+
`client.options.implied_volatility()` and print IV, residual with its basis, iterations,
|
|
58
68
|
fallback usage and provenance. See [the IV guide](../docs/IMPLIED_VOLATILITY.md).
|
|
59
69
|
|
|
60
|
-
The
|
|
61
|
-
solve IV and evaluate price and
|
|
62
|
-
|
|
70
|
+
The implied-Greeks examples submit one `OptionsImpliedGreeksRequest` to
|
|
71
|
+
`client.options.implied_greeks()` to solve IV from a premium and evaluate price and
|
|
72
|
+
all ten Greeks at that solved volatility. They report the combined response's
|
|
73
|
+
commercial charge once. See [implied Greeks](../docs/IMPLIED_GREEKS.md).
|
|
63
74
|
|
|
64
|
-
The batch examples submit two explicit pricing requests in one
|
|
65
|
-
ordered item outcomes, and count the
|
|
75
|
+
The batch examples submit two explicit pricing requests as `items` in one
|
|
76
|
+
`client.options.batch_price()` call, preserve ordered item outcomes, and count the
|
|
77
|
+
response charge once. See
|
|
66
78
|
[batch operations and 429 handling](../docs/BATCH.md).
|
|
67
79
|
|
|
68
80
|
The [chunked pricing examples](../docs/WORKFLOWS.md) prepare five synthetic spot
|
|
@@ -90,7 +102,7 @@ python examples/identify_regime_async.py
|
|
|
90
102
|
python examples/provider_regime.py
|
|
91
103
|
```
|
|
92
104
|
|
|
93
|
-
Each script submits one
|
|
105
|
+
Each script submits one `client.series.identify_regime()` request. The first two prompt for a ticker and
|
|
94
106
|
support a masked key prompt; the provider example uses SPY and requires the
|
|
95
107
|
exported key. See [regime interpretation](../docs/REGIME.md) and
|
|
96
108
|
[provider interfaces](../docs/PRICE_PROVIDERS.md). Data stays in memory; no CSV
|
|
@@ -110,3 +122,36 @@ python examples/tabular_price.py
|
|
|
110
122
|
|
|
111
123
|
See [the pandas adapter guide](../docs/PANDAS.md) for partial results, identifiers,
|
|
112
124
|
units and exact charge totals. Pandas is optional and conversion makes no API calls.
|
|
125
|
+
|
|
126
|
+
## Model catalog and rate card
|
|
127
|
+
|
|
128
|
+
```sh
|
|
129
|
+
python examples/list_models.py
|
|
130
|
+
python examples/rate_card_quote.py
|
|
131
|
+
python examples/rate_card_quote.py --batch --execute
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
`list_models.py` calls the public `client.models.list()` without a key or charge
|
|
135
|
+
and prints each model's canonical operation ids and validity contracts.
|
|
136
|
+
`rate_card_quote.py` reads your rate card with `client.rate_card.get()` and quotes
|
|
137
|
+
the exact request it would execute with `client.rate_card.quote()`; both are
|
|
138
|
+
utility requests. `--execute` then sends one pricing request with the quoted
|
|
139
|
+
total as its `max_cu` ceiling. See [the rate card guide](../docs/RATE_CARD.md).
|
|
140
|
+
|
|
141
|
+
## Option scenarios and books
|
|
142
|
+
|
|
143
|
+
Each script uses synthetic inputs and sends one calculation when run. All request
|
|
144
|
+
construction and the complete returned result are visible; missing charges stay
|
|
145
|
+
unreported. Set `MORPHIQ_API_KEY`, then run:
|
|
146
|
+
|
|
147
|
+
```sh
|
|
148
|
+
python examples/option_revalue.py
|
|
149
|
+
python examples/option_solve.py
|
|
150
|
+
python examples/book_revalue.py
|
|
151
|
+
python examples/book_explain.py
|
|
152
|
+
python examples/book_solve.py
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
[The guide](../docs/SCENARIOS.md) explains targets, units, coverage, signed values
|
|
156
|
+
and quotation. The [local solver app](solver_app/README.md) separates Quote and
|
|
157
|
+
Solve into explicit actions with a single-use quote and retained receipts.
|
|
@@ -9,9 +9,14 @@ from getpass import getpass
|
|
|
9
9
|
|
|
10
10
|
from morphiq_sdk import (
|
|
11
11
|
APIError,
|
|
12
|
-
|
|
12
|
+
BatchFailure,
|
|
13
|
+
BatchSuccess,
|
|
14
|
+
Market,
|
|
15
|
+
ModelSelection,
|
|
13
16
|
MorphIQ,
|
|
14
|
-
|
|
17
|
+
Option,
|
|
18
|
+
OptionsBatchPriceRequest,
|
|
19
|
+
OptionsPriceRequest,
|
|
15
20
|
RateLimitError,
|
|
16
21
|
ResponseError,
|
|
17
22
|
TransportError,
|
|
@@ -23,29 +28,37 @@ def main() -> None:
|
|
|
23
28
|
api_key = os.environ.get("MORPHIQ_API_KEY") or getpass("MorphIQ API key: ")
|
|
24
29
|
|
|
25
30
|
# The order of this list defines the index used in each response outcome.
|
|
26
|
-
request =
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
31
|
+
request = OptionsBatchPriceRequest(
|
|
32
|
+
items=[
|
|
33
|
+
OptionsPriceRequest(
|
|
34
|
+
option=Option(
|
|
35
|
+
type="call",
|
|
36
|
+
exercise_style="european",
|
|
37
|
+
strike=100.0,
|
|
38
|
+
time_to_expiry_years=1,
|
|
39
|
+
),
|
|
40
|
+
market=Market(
|
|
41
|
+
spot=100.0,
|
|
42
|
+
risk_free_rate=0.05,
|
|
43
|
+
dividend_yield=0,
|
|
44
|
+
),
|
|
37
45
|
volatility=0.2,
|
|
46
|
+
model=ModelSelection(id="auto"),
|
|
38
47
|
),
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
+
OptionsPriceRequest(
|
|
49
|
+
option=Option(
|
|
50
|
+
type="put",
|
|
51
|
+
exercise_style="american",
|
|
52
|
+
strike=105.0,
|
|
53
|
+
time_to_expiry_years=0.5,
|
|
54
|
+
),
|
|
55
|
+
market=Market(
|
|
56
|
+
spot=100.0,
|
|
57
|
+
risk_free_rate=0.05,
|
|
58
|
+
dividend_yield=0.01,
|
|
59
|
+
),
|
|
48
60
|
volatility=0.2,
|
|
61
|
+
model=ModelSelection(id="bjerksund_stensland_1993"),
|
|
49
62
|
),
|
|
50
63
|
]
|
|
51
64
|
)
|
|
@@ -53,14 +66,14 @@ def main() -> None:
|
|
|
53
66
|
try:
|
|
54
67
|
# The client uses https://api.morphiqlabs.com and closes its connection pool here.
|
|
55
68
|
with MorphIQ(api_key=api_key) as client:
|
|
56
|
-
response = client.
|
|
69
|
+
response = client.options.batch_price(request)
|
|
57
70
|
except APIError as error:
|
|
58
71
|
if isinstance(error, RateLimitError):
|
|
59
72
|
print("Rate limited. Retry-After:", error.retry_after, file=sys.stderr)
|
|
60
73
|
print("No automatic retry or batch splitting.", file=sys.stderr)
|
|
61
|
-
print(f"HTTP {error.status_code}: {error.code}: {error.
|
|
74
|
+
print(f"HTTP {error.status_code}: {error.code}: {error.detail}", file=sys.stderr)
|
|
62
75
|
print(f"Request ID: {error.request_id}", file=sys.stderr)
|
|
63
|
-
charged = error.metadata.
|
|
76
|
+
charged = error.metadata.charged_cu if error.metadata else None
|
|
64
77
|
print(
|
|
65
78
|
f"Commercial CU charged: {charged if charged is not None else 'not reported'}",
|
|
66
79
|
file=sys.stderr,
|
|
@@ -72,7 +85,7 @@ def main() -> None:
|
|
|
72
85
|
"No complete response; execution and charges may be unknown. No retry."
|
|
73
86
|
) from None
|
|
74
87
|
except ResponseError as error:
|
|
75
|
-
charged = error.metadata.
|
|
88
|
+
charged = error.metadata.charged_cu if error.metadata else None
|
|
76
89
|
print(
|
|
77
90
|
f"Commercial CU charged: {charged if charged is not None else 'not reported'}",
|
|
78
91
|
file=sys.stderr,
|
|
@@ -82,19 +95,23 @@ def main() -> None:
|
|
|
82
95
|
) from None
|
|
83
96
|
|
|
84
97
|
for item in response.results:
|
|
85
|
-
if item
|
|
98
|
+
if isinstance(item, BatchSuccess):
|
|
86
99
|
print(
|
|
87
100
|
f"Item {item.index}: price={item.result.price}; "
|
|
88
|
-
f"model={item.result.
|
|
101
|
+
f"model={item.result.model.id} ({item.result.model.version})"
|
|
89
102
|
)
|
|
103
|
+
elif isinstance(item, BatchFailure):
|
|
104
|
+
print(f"Item {item.index}: {item.error.code}: {item.error.detail}")
|
|
90
105
|
else:
|
|
91
|
-
|
|
106
|
+
# A newer outcome status this SDK does not know; keep it unhandled.
|
|
107
|
+
print(f"Item {item.index}: unrecognized status {item.status}")
|
|
92
108
|
# One metadata block and one commercial charge cover the entire batch.
|
|
93
109
|
print(f"Request ID: {response.metadata.request_id}")
|
|
94
|
-
for engine in response.metadata.engines:
|
|
110
|
+
for engine in response.metadata.engines or []:
|
|
95
111
|
print(f"Engine: {engine.name} {engine.version} ({engine.revision})")
|
|
96
|
-
#
|
|
97
|
-
|
|
112
|
+
# The charge is metadata.billing.charged_cu; missing means unreported, not zero.
|
|
113
|
+
billing = response.metadata.billing
|
|
114
|
+
charged = billing.charged_cu if billing is not None else None
|
|
98
115
|
print("Commercial CU charged:", charged if charged is not None else "not reported")
|
|
99
116
|
|
|
100
117
|
|