morphiq-sdk 0.1.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.
Files changed (39) hide show
  1. morphiq_sdk-0.1.0/.gitignore +15 -0
  2. morphiq_sdk-0.1.0/LICENSE +21 -0
  3. morphiq_sdk-0.1.0/PKG-INFO +245 -0
  4. morphiq_sdk-0.1.0/README.md +209 -0
  5. morphiq_sdk-0.1.0/examples/README.md +112 -0
  6. morphiq_sdk-0.1.0/examples/__init__.py +1 -0
  7. morphiq_sdk-0.1.0/examples/analytics.py +90 -0
  8. morphiq_sdk-0.1.0/examples/analytics_async.py +97 -0
  9. morphiq_sdk-0.1.0/examples/batch_price.py +102 -0
  10. morphiq_sdk-0.1.0/examples/batch_price_async.py +103 -0
  11. morphiq_sdk-0.1.0/examples/chunked_price.py +70 -0
  12. morphiq_sdk-0.1.0/examples/chunked_price_async.py +80 -0
  13. morphiq_sdk-0.1.0/examples/greeks.py +79 -0
  14. morphiq_sdk-0.1.0/examples/greeks_async.py +80 -0
  15. morphiq_sdk-0.1.0/examples/identify_regime.py +107 -0
  16. morphiq_sdk-0.1.0/examples/identify_regime_async.py +108 -0
  17. morphiq_sdk-0.1.0/examples/implied_volatility.py +70 -0
  18. morphiq_sdk-0.1.0/examples/implied_volatility_async.py +77 -0
  19. morphiq_sdk-0.1.0/examples/price_american.py +64 -0
  20. morphiq_sdk-0.1.0/examples/price_async.py +78 -0
  21. morphiq_sdk-0.1.0/examples/price_european.py +64 -0
  22. morphiq_sdk-0.1.0/examples/provider_regime.py +31 -0
  23. morphiq_sdk-0.1.0/examples/quickstart.py +77 -0
  24. morphiq_sdk-0.1.0/examples/tabular_price.py +64 -0
  25. morphiq_sdk-0.1.0/notebooks/README.md +22 -0
  26. morphiq_sdk-0.1.0/notebooks/pricing/options.ipynb +898 -0
  27. morphiq_sdk-0.1.0/notebooks/regime/identification.ipynb +348 -0
  28. morphiq_sdk-0.1.0/notebooks/start-here.ipynb +23 -0
  29. morphiq_sdk-0.1.0/pyproject.toml +76 -0
  30. morphiq_sdk-0.1.0/src/morphiq_sdk/__init__.py +89 -0
  31. morphiq_sdk-0.1.0/src/morphiq_sdk/client.py +469 -0
  32. morphiq_sdk-0.1.0/src/morphiq_sdk/errors.py +102 -0
  33. morphiq_sdk-0.1.0/src/morphiq_sdk/market_data.py +91 -0
  34. morphiq_sdk-0.1.0/src/morphiq_sdk/models.py +442 -0
  35. morphiq_sdk-0.1.0/src/morphiq_sdk/pandas.py +275 -0
  36. morphiq_sdk-0.1.0/src/morphiq_sdk/py.typed +0 -0
  37. morphiq_sdk-0.1.0/src/morphiq_sdk/workflows.py +264 -0
  38. morphiq_sdk-0.1.0/src/morphiq_sdk_yahoo/__init__.py +88 -0
  39. morphiq_sdk-0.1.0/src/morphiq_sdk_yahoo/py.typed +0 -0
@@ -0,0 +1,15 @@
1
+ .venv/
2
+ __pycache__/
3
+ *.py[cod]
4
+ *.egg-info/
5
+ .mypy_cache/
6
+ .ruff_cache/
7
+ .pytest_cache/
8
+ .ipynb_checkpoints/
9
+ .coverage
10
+ htmlcov/
11
+ build/
12
+ dist/
13
+ .env
14
+ .env.*
15
+ .DS_Store
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 MorphIQ Labs
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,245 @@
1
+ Metadata-Version: 2.5
2
+ Name: morphiq-sdk
3
+ Version: 0.1.0
4
+ Summary: Option pricing, Greeks, implied volatility and market regime identification through a Python API client
5
+ Project-URL: Homepage, https://developers.morphiqlabs.com
6
+ Project-URL: Documentation, https://github.com/MorphIQ-Labs/morphiq-sdk-python/blob/main/docs/README.md
7
+ Project-URL: Issues, https://github.com/MorphIQ-Labs/morphiq-sdk-python/issues
8
+ Project-URL: Repository, https://github.com/MorphIQ-Labs/morphiq-sdk-python
9
+ Author: MorphIQ Labs
10
+ License-Expression: MIT
11
+ License-File: LICENSE
12
+ Keywords: american-options,derivatives,european-options,finance,greeks,implied-volatility,market-regimes,option-pricing,quantitative,quantitative-finance,regime-identification,volatility
13
+ Classifier: Development Status :: 3 - Alpha
14
+ Classifier: Intended Audience :: Developers
15
+ Classifier: Intended Audience :: Financial and Insurance Industry
16
+ Classifier: Intended Audience :: Science/Research
17
+ Classifier: Programming Language :: Python :: 3
18
+ Classifier: Topic :: Office/Business :: Financial :: Investment
19
+ Classifier: Typing :: Typed
20
+ Requires-Python: >=3.11
21
+ Requires-Dist: httpx<0.29,>=0.28.1
22
+ Requires-Dist: pydantic<3,>=2.10
23
+ Provides-Extra: market-data
24
+ Requires-Dist: pandas<3.1,>=2.2; extra == 'market-data'
25
+ Requires-Dist: yfinance<2,>=1.7; extra == 'market-data'
26
+ Provides-Extra: notebooks
27
+ Requires-Dist: ipykernel<8,>=7.4; extra == 'notebooks'
28
+ Requires-Dist: ipywidgets<9,>=8.1; extra == 'notebooks'
29
+ Requires-Dist: jupyterlab<5,>=4.6; extra == 'notebooks'
30
+ Requires-Dist: matplotlib<4,>=3.10; extra == 'notebooks'
31
+ Requires-Dist: pandas<3.1,>=2.2; extra == 'notebooks'
32
+ Requires-Dist: yfinance<2,>=1.7; extra == 'notebooks'
33
+ Provides-Extra: pandas
34
+ Requires-Dist: pandas<4,>=2.2; extra == 'pandas'
35
+ Description-Content-Type: text/markdown
36
+
37
+ # Option pricing, Greeks, volatility and market regimes in Python
38
+
39
+ Price European and American options, calculate ten Greeks, solve implied
40
+ volatility, and identify market regimes from price histories.
41
+
42
+ `morphiq-sdk` is a typed Python client for the MorphIQ API, with synchronous and
43
+ asynchronous calls. Pricing, Greeks, implied volatility and combined analytics
44
+ support ordered batches. Runnable examples and interactive notebooks cover option
45
+ valuation, sensitivity analysis and market-regime identification.
46
+
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
+ [Python API reference](https://github.com/MorphIQ-Labs/morphiq-sdk-python/blob/main/docs/API.md) for methods, models and errors.
49
+
50
+ ## Quickstart
51
+
52
+ ### 1. Get API access
53
+
54
+ Start at the [MorphIQ Labs developer portal](https://developers.morphiqlabs.com)
55
+ to get your API key, then set it in your terminal:
56
+
57
+ ```sh
58
+ export MORPHIQ_API_KEY="YOUR_API_KEY"
59
+ ```
60
+
61
+ `MorphIQ()` reads `MORPHIQ_API_KEY` automatically and connects to
62
+ `https://api.morphiqlabs.com`.
63
+
64
+ ### 2. Install the SDK
65
+
66
+ With Python 3.11 or newer:
67
+
68
+ ```sh
69
+ python3 -m venv .venv
70
+ source .venv/bin/activate
71
+ python -m pip install morphiq-sdk
72
+ ```
73
+
74
+ ### 3. Make your first API request
75
+
76
+ Save the following as `price_option.py`. It prices a European call with spot and
77
+ strike of 100, one year to expiry, 20% volatility, and a 5% interest rate:
78
+
79
+ ```python
80
+ from morphiq_sdk import MorphIQ, PriceRequest
81
+
82
+ request = PriceRequest(
83
+ exercise_style="european",
84
+ option_type="call",
85
+ spot=100.0,
86
+ strike=100.0,
87
+ time_to_expiry_years=1.0,
88
+ risk_free_rate=0.05,
89
+ dividend_yield=0.0,
90
+ volatility=0.20,
91
+ )
92
+
93
+ with MorphIQ() as client:
94
+ response = client.price(request)
95
+ print(response.model_dump_json(indent=2, exclude_unset=True))
96
+ ```
97
+
98
+ Run it in the same terminal where you set your API key:
99
+
100
+ ```sh
101
+ python price_option.py
102
+ ```
103
+
104
+ This sends one authenticated `POST https://api.morphiqlabs.com/v1/price` request
105
+ and prints the JSON response. Example response from the recorded synthetic fixture:
106
+
107
+ ```json
108
+ {
109
+ "result": {
110
+ "price": 10.450583572185538,
111
+ "exercise_style": "european",
112
+ "option_type": "call",
113
+ "pricing_model": "black_scholes_merton",
114
+ "model_version": "black_scholes_merton/1"
115
+ },
116
+ "metadata": {
117
+ "request_id": "fixture-european",
118
+ "api_version": "v1",
119
+ "engine_version": "0.39.1",
120
+ "engines": [
121
+ {
122
+ "name": "morphiq-risk",
123
+ "version": "0.39.1",
124
+ "revision": "b4c29d492ff96dddf9b25f745d2be4d253202164"
125
+ }
126
+ ],
127
+ "units_charged": 1,
128
+ "compute_schedule_version": "2026-09-11"
129
+ }
130
+ }
131
+ ```
132
+
133
+ Your request ID and engine metadata will reflect the live service. This fixture
134
+ was recorded in open development mode; authenticated responses may also report
135
+ commercial charges in `metadata.fcu_charged`. Keep the request ID for support.
136
+ See [the quickstart guide](https://github.com/MorphIQ-Labs/morphiq-sdk-python/blob/main/docs/QUICKSTART.md)
137
+ for input units, async usage, configuration and errors.
138
+
139
+ ## Repository examples and notebooks
140
+
141
+ The executable examples and Docker notebooks live in the repository. Clone it
142
+ to use either:
143
+
144
+ ```sh
145
+ git clone https://github.com/MorphIQ-Labs/morphiq-sdk-python.git
146
+ cd morphiq-sdk-python
147
+ ```
148
+
149
+ ### Run the examples
150
+
151
+ From the repository root, with your Python environment active and API key set:
152
+
153
+ ```sh
154
+ python -m pip install -e .
155
+ python -m examples.quickstart
156
+ ```
157
+
158
+ This sends two requests, for European and American pricing. Run
159
+ `python -m examples.price_async` for the async version, or
160
+ `python -m examples.price_european` and `python -m examples.price_american`
161
+ individually. See the
162
+ [executable cookbook](https://github.com/MorphIQ-Labs/morphiq-sdk-python/blob/main/examples/README.md)
163
+ for all examples.
164
+
165
+ ### Start a notebook with Docker
166
+
167
+ With Docker running, from the repository root, set your API key and start
168
+ the notebook:
169
+
170
+ ```sh
171
+ export MORPHIQ_API_KEY="YOUR_API_KEY"
172
+ docker compose up --build
173
+ ```
174
+
175
+ Open the local token-authenticated URL printed by Jupyter to reach Start Here.
176
+ Choose an analysis workspace and run all cells once to display its controls:
177
+
178
+ - [Option pricing](https://github.com/MorphIQ-Labs/morphiq-sdk-python/blob/main/notebooks/pricing/options.ipynb): European/American and model
179
+ dropdowns, call/put selection, editable assumptions, automatic Yahoo daily/intraday underlying prices,
180
+ a valuation comparison table, a price-and-Greeks panel, an implied-volatility solver,
181
+ combined premium analysis, a session CU total and a spot-sensitivity chart.
182
+ - [Regime analysis](https://github.com/MorphIQ-Labs/morphiq-sdk-python/blob/main/notebooks/regime/identification.ipynb): ticker selection,
183
+ Yahoo daily/intraday price history, latest regime assessment, score charts and provenance.
184
+
185
+ Compose passes your API key into the container; if unset, the workspace prompts
186
+ for it. Setup and control changes make no MorphIQ requests. Pricing loads Yahoo prices automatically
187
+ on setup and when the ticker or interval changes. In regime, **Analyze regime** loads
188
+ Yahoo history and displays the complete assessment in one click. Click **Price option**
189
+ or **Price + Greeks**, **Solve IV**, **Analyze premium** or **Analyze regime** for one
190
+ request. **Spot sensitivity** submits nine scenarios in one batch request. Yahoo data remains in memory.
191
+ Dependencies are installed at build time, and notebook edits persist in a named volume.
192
+
193
+ Stop with Ctrl-C, then `docker compose down`; the workspace is retained. If port
194
+ 8888 is occupied, use `MORPHIQ_NOTEBOOK_PORT=8889 docker compose up --build`.
195
+ See [notebook instructions](https://github.com/MorphIQ-Labs/morphiq-sdk-python/blob/main/docs/NOTEBOOKS.md) for networking and persistence.
196
+
197
+ ## Development
198
+
199
+ From a repository checkout, use Python 3.11 or newer. CI checks Python 3.11 and 3.14.
200
+
201
+ ```sh
202
+ python3 -m venv .venv
203
+ source .venv/bin/activate
204
+ python -m pip install --require-hashes -r requirements-dev.txt
205
+ python -m pip install --no-build-isolation -e .
206
+ python -m ruff check .
207
+ python -m ruff format --check .
208
+ python -m mypy
209
+ python -m pytest -q
210
+ python scripts/generate_notebook.py --check
211
+ python scripts/check_package.py
212
+ ```
213
+
214
+ Versions are managed through reviewed release PRs; no version environment variable
215
+ is needed. `check_package.py` builds an sdist and a wheel from that sdist, then
216
+ installs the wheel in a fresh environment outside the checkout. Routine tests use local fixture replay and need
217
+ no real credentials; native API integration is opt-in. See
218
+ [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).
219
+
220
+ Clients make no automatic retries and do not follow redirects. A timeout
221
+ may leave work charged. Missing `fcu_charged` means unreported, not zero; internal
222
+ `units_charged` is not a commercial CU charge.
223
+
224
+ The SDK preserves server results, numerical diagnostics, request IDs, engine
225
+ provenance and commercial Compute Units (CU). Numerical engines, model selection,
226
+ policy decisions and charging remain server-owned. The client will not duplicate
227
+ pricing engines or calculate authoritative customer charges.
228
+
229
+ ## Project layout
230
+
231
+ ```text
232
+ src/morphiq_sdk/ Installable, typed Python package
233
+ scripts/ Development and package verification
234
+ examples/ Runnable pricing, Greeks, IV, analytics, batch and regime examples
235
+ notebooks/ Quickstart and standalone feature notebooks
236
+ contracts/ Reviewed OpenAPI snapshot, digest and source provenance
237
+ docker/ Non-root notebook startup and workspace seeding
238
+ docs/ Usage guides and contract documentation
239
+ .github/ CI and pull request template
240
+ ```
241
+
242
+ ## License
243
+
244
+ The SDK, examples and notebooks are licensed under the
245
+ [MIT License](https://github.com/MorphIQ-Labs/morphiq-sdk-python/blob/main/LICENSE).
@@ -0,0 +1,209 @@
1
+ # Option pricing, Greeks, volatility and market regimes in Python
2
+
3
+ Price European and American options, calculate ten Greeks, solve implied
4
+ volatility, and identify market regimes from price histories.
5
+
6
+ `morphiq-sdk` is a typed Python client for the MorphIQ API, with synchronous and
7
+ asynchronous calls. Pricing, Greeks, implied volatility and combined analytics
8
+ support ordered batches. Runnable examples and interactive notebooks cover option
9
+ valuation, sensitivity analysis and market-regime identification.
10
+
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
+ [Python API reference](https://github.com/MorphIQ-Labs/morphiq-sdk-python/blob/main/docs/API.md) for methods, models and errors.
13
+
14
+ ## Quickstart
15
+
16
+ ### 1. Get API access
17
+
18
+ Start at the [MorphIQ Labs developer portal](https://developers.morphiqlabs.com)
19
+ to get your API key, then set it in your terminal:
20
+
21
+ ```sh
22
+ export MORPHIQ_API_KEY="YOUR_API_KEY"
23
+ ```
24
+
25
+ `MorphIQ()` reads `MORPHIQ_API_KEY` automatically and connects to
26
+ `https://api.morphiqlabs.com`.
27
+
28
+ ### 2. Install the SDK
29
+
30
+ With Python 3.11 or newer:
31
+
32
+ ```sh
33
+ python3 -m venv .venv
34
+ source .venv/bin/activate
35
+ python -m pip install morphiq-sdk
36
+ ```
37
+
38
+ ### 3. Make your first API request
39
+
40
+ Save the following as `price_option.py`. It prices a European call with spot and
41
+ strike of 100, one year to expiry, 20% volatility, and a 5% interest rate:
42
+
43
+ ```python
44
+ from morphiq_sdk import MorphIQ, PriceRequest
45
+
46
+ request = PriceRequest(
47
+ exercise_style="european",
48
+ option_type="call",
49
+ spot=100.0,
50
+ strike=100.0,
51
+ time_to_expiry_years=1.0,
52
+ risk_free_rate=0.05,
53
+ dividend_yield=0.0,
54
+ volatility=0.20,
55
+ )
56
+
57
+ with MorphIQ() as client:
58
+ response = client.price(request)
59
+ print(response.model_dump_json(indent=2, exclude_unset=True))
60
+ ```
61
+
62
+ Run it in the same terminal where you set your API key:
63
+
64
+ ```sh
65
+ python price_option.py
66
+ ```
67
+
68
+ This sends one authenticated `POST https://api.morphiqlabs.com/v1/price` request
69
+ and prints the JSON response. Example response from the recorded synthetic fixture:
70
+
71
+ ```json
72
+ {
73
+ "result": {
74
+ "price": 10.450583572185538,
75
+ "exercise_style": "european",
76
+ "option_type": "call",
77
+ "pricing_model": "black_scholes_merton",
78
+ "model_version": "black_scholes_merton/1"
79
+ },
80
+ "metadata": {
81
+ "request_id": "fixture-european",
82
+ "api_version": "v1",
83
+ "engine_version": "0.39.1",
84
+ "engines": [
85
+ {
86
+ "name": "morphiq-risk",
87
+ "version": "0.39.1",
88
+ "revision": "b4c29d492ff96dddf9b25f745d2be4d253202164"
89
+ }
90
+ ],
91
+ "units_charged": 1,
92
+ "compute_schedule_version": "2026-09-11"
93
+ }
94
+ }
95
+ ```
96
+
97
+ Your request ID and engine metadata will reflect the live service. This fixture
98
+ was recorded in open development mode; authenticated responses may also report
99
+ commercial charges in `metadata.fcu_charged`. Keep the request ID for support.
100
+ See [the quickstart guide](https://github.com/MorphIQ-Labs/morphiq-sdk-python/blob/main/docs/QUICKSTART.md)
101
+ for input units, async usage, configuration and errors.
102
+
103
+ ## Repository examples and notebooks
104
+
105
+ The executable examples and Docker notebooks live in the repository. Clone it
106
+ to use either:
107
+
108
+ ```sh
109
+ git clone https://github.com/MorphIQ-Labs/morphiq-sdk-python.git
110
+ cd morphiq-sdk-python
111
+ ```
112
+
113
+ ### Run the examples
114
+
115
+ From the repository root, with your Python environment active and API key set:
116
+
117
+ ```sh
118
+ python -m pip install -e .
119
+ python -m examples.quickstart
120
+ ```
121
+
122
+ This sends two requests, for European and American pricing. Run
123
+ `python -m examples.price_async` for the async version, or
124
+ `python -m examples.price_european` and `python -m examples.price_american`
125
+ individually. See the
126
+ [executable cookbook](https://github.com/MorphIQ-Labs/morphiq-sdk-python/blob/main/examples/README.md)
127
+ for all examples.
128
+
129
+ ### Start a notebook with Docker
130
+
131
+ With Docker running, from the repository root, set your API key and start
132
+ the notebook:
133
+
134
+ ```sh
135
+ export MORPHIQ_API_KEY="YOUR_API_KEY"
136
+ docker compose up --build
137
+ ```
138
+
139
+ Open the local token-authenticated URL printed by Jupyter to reach Start Here.
140
+ Choose an analysis workspace and run all cells once to display its controls:
141
+
142
+ - [Option pricing](https://github.com/MorphIQ-Labs/morphiq-sdk-python/blob/main/notebooks/pricing/options.ipynb): European/American and model
143
+ dropdowns, call/put selection, editable assumptions, automatic Yahoo daily/intraday underlying prices,
144
+ a valuation comparison table, a price-and-Greeks panel, an implied-volatility solver,
145
+ combined premium analysis, a session CU total and a spot-sensitivity chart.
146
+ - [Regime analysis](https://github.com/MorphIQ-Labs/morphiq-sdk-python/blob/main/notebooks/regime/identification.ipynb): ticker selection,
147
+ Yahoo daily/intraday price history, latest regime assessment, score charts and provenance.
148
+
149
+ Compose passes your API key into the container; if unset, the workspace prompts
150
+ for it. Setup and control changes make no MorphIQ requests. Pricing loads Yahoo prices automatically
151
+ on setup and when the ticker or interval changes. In regime, **Analyze regime** loads
152
+ Yahoo history and displays the complete assessment in one click. Click **Price option**
153
+ or **Price + Greeks**, **Solve IV**, **Analyze premium** or **Analyze regime** for one
154
+ request. **Spot sensitivity** submits nine scenarios in one batch request. Yahoo data remains in memory.
155
+ Dependencies are installed at build time, and notebook edits persist in a named volume.
156
+
157
+ Stop with Ctrl-C, then `docker compose down`; the workspace is retained. If port
158
+ 8888 is occupied, use `MORPHIQ_NOTEBOOK_PORT=8889 docker compose up --build`.
159
+ See [notebook instructions](https://github.com/MorphIQ-Labs/morphiq-sdk-python/blob/main/docs/NOTEBOOKS.md) for networking and persistence.
160
+
161
+ ## Development
162
+
163
+ From a repository checkout, use Python 3.11 or newer. CI checks Python 3.11 and 3.14.
164
+
165
+ ```sh
166
+ python3 -m venv .venv
167
+ source .venv/bin/activate
168
+ python -m pip install --require-hashes -r requirements-dev.txt
169
+ python -m pip install --no-build-isolation -e .
170
+ python -m ruff check .
171
+ python -m ruff format --check .
172
+ python -m mypy
173
+ python -m pytest -q
174
+ python scripts/generate_notebook.py --check
175
+ python scripts/check_package.py
176
+ ```
177
+
178
+ Versions are managed through reviewed release PRs; no version environment variable
179
+ is needed. `check_package.py` builds an sdist and a wheel from that sdist, then
180
+ installs the wheel in a fresh environment outside the checkout. Routine tests use local fixture replay and need
181
+ no real credentials; native API integration is opt-in. See
182
+ [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).
183
+
184
+ Clients make no automatic retries and do not follow redirects. A timeout
185
+ may leave work charged. Missing `fcu_charged` means unreported, not zero; internal
186
+ `units_charged` is not a commercial CU charge.
187
+
188
+ The SDK preserves server results, numerical diagnostics, request IDs, engine
189
+ provenance and commercial Compute Units (CU). Numerical engines, model selection,
190
+ policy decisions and charging remain server-owned. The client will not duplicate
191
+ pricing engines or calculate authoritative customer charges.
192
+
193
+ ## Project layout
194
+
195
+ ```text
196
+ src/morphiq_sdk/ Installable, typed Python package
197
+ scripts/ Development and package verification
198
+ examples/ Runnable pricing, Greeks, IV, analytics, batch and regime examples
199
+ notebooks/ Quickstart and standalone feature notebooks
200
+ contracts/ Reviewed OpenAPI snapshot, digest and source provenance
201
+ docker/ Non-root notebook startup and workspace seeding
202
+ docs/ Usage guides and contract documentation
203
+ .github/ CI and pull request template
204
+ ```
205
+
206
+ ## License
207
+
208
+ The SDK, examples and notebooks are licensed under the
209
+ [MIT License](https://github.com/MorphIQ-Labs/morphiq-sdk-python/blob/main/LICENSE).
@@ -0,0 +1,112 @@
1
+ # Executable cookbook
2
+
3
+ Get your API key from the
4
+ [MorphIQ Labs developer portal](https://developers.morphiqlabs.com). After
5
+ [installing the SDK](../docs/QUICKSTART.md), clone the repository to get these
6
+ scripts and run them from its root:
7
+
8
+ ```sh
9
+ git clone https://github.com/MorphIQ-Labs/morphiq-sdk-python.git
10
+ cd morphiq-sdk-python
11
+ python -m pip install -e .
12
+ export MORPHIQ_API_KEY="YOUR_API_KEY"
13
+ python examples/quickstart.py
14
+ ```
15
+
16
+ The other examples use the same environment settings:
17
+
18
+ ```sh
19
+ python examples/price_european.py
20
+ python examples/price_american.py
21
+ python examples/price_async.py
22
+ python examples/greeks.py
23
+ python examples/greeks_async.py
24
+ python examples/implied_volatility.py
25
+ python examples/implied_volatility_async.py
26
+ python examples/analytics.py
27
+ python examples/analytics_async.py
28
+ python examples/batch_price.py
29
+ python examples/batch_price_async.py
30
+ ```
31
+
32
+ Each connects to `https://api.morphiqlabs.com` and reads `MORPHIQ_API_KEY`, or
33
+ prompts for the key with masked input. Set `MORPHIQ_API_BASE_URL` only to use a
34
+ local or controlled test service.
35
+ Run `unset MORPHIQ_API_KEY` when finished.
36
+ Each option example is self-contained: it constructs the appropriate typed request,
37
+ calls the SDK and reads the operation-specific result, model identity, request/engine
38
+ provenance and reported commercial CU charges. The error handlers show API failure
39
+ details and distinguish unknown charges after transport failures. Scripts exit
40
+ with a nonzero status on request-level failure and do not retry. An accepted
41
+ batch can contain per-item errors, which its example prints alongside successes.
42
+
43
+ The quickstart uses one sync client for two explicit option requests; the async
44
+ script awaits them sequentially. Imports make no requests. You can copy a script
45
+ outside this repository and run it with the SDK installed.
46
+
47
+ See [the quickstart](../docs/QUICKSTART.md) and [all feature guides](../docs/README.md).
48
+ Start Here links to the interactive workspaces; the standalone scripts remain the
49
+ SDK usage demonstrations.
50
+
51
+ The Greeks examples submit `GreeksRequest` to `client.greeks()` and display the
52
+ price plus all ten derivatives, with the same model/charge evidence and error
53
+ handling. Values use annual time units and unit volatility/rate bases. See
54
+ [the Greeks guide](../docs/GREEKS.md).
55
+
56
+ The implied-volatility examples pass an explicit option premium to
57
+ `client.implied_volatility()` and print IV, residual with its basis, iterations,
58
+ fallback usage and provenance. See [the IV guide](../docs/IMPLIED_VOLATILITY.md).
59
+
60
+ The analytics examples submit one `AnalyticsRequest` to `client.analytics()` to
61
+ solve IV and evaluate price and Greeks at that solved volatility. They report the
62
+ combined response's commercial charge once. See [combined analytics](../docs/ANALYTICS.md).
63
+
64
+ The batch examples submit two explicit pricing requests in one call, preserve
65
+ ordered item outcomes, and count the response charge once. See
66
+ [batch operations and 429 handling](../docs/BATCH.md).
67
+
68
+ The [chunked pricing examples](../docs/WORKFLOWS.md) prepare five synthetic spot
69
+ scenarios and send three sequential batch requests. They retain partial results
70
+ and exact reported CU subtotals if a request fails, without retries:
71
+
72
+ ```sh
73
+ python examples/chunked_price.py
74
+ python examples/chunked_price_async.py
75
+ python examples/chunked_price_async.py --max-concurrency 2
76
+ ```
77
+
78
+ The async example defaults to sequential execution. The optional flag bounds
79
+ simultaneous requests; it does not change chunk size or retry failed requests.
80
+
81
+ ## Regime and optional price data
82
+
83
+ These examples download Yahoo history; they require the optional data extra:
84
+
85
+ ```sh
86
+ python -m pip install -e '.[market-data]'
87
+ export MORPHIQ_API_KEY="YOUR_API_KEY"
88
+ python examples/identify_regime.py
89
+ python examples/identify_regime_async.py
90
+ python examples/provider_regime.py
91
+ ```
92
+
93
+ Each script submits one regime request. The first two prompt for a ticker and
94
+ support a masked key prompt; the provider example uses SPY and requires the
95
+ exported key. See [regime interpretation](../docs/REGIME.md) and
96
+ [provider interfaces](../docs/PRICE_PROVIDERS.md). Data stays in memory; no CSV
97
+ intermediate is required. The provider example lets errors propagate; it does not
98
+ retry. These scripts do not make Yahoo a core SDK dependency.
99
+
100
+ ## Optional tabular analysis
101
+
102
+ The [tabular pricing example](tabular_price.py) sends five synthetic spot scenarios
103
+ in three sequential requests and displays separate result and charge tables:
104
+
105
+ ```sh
106
+ python -m pip install -e '.[pandas]'
107
+ export MORPHIQ_API_KEY="YOUR_API_KEY"
108
+ python examples/tabular_price.py
109
+ ```
110
+
111
+ See [the pandas adapter guide](../docs/PANDAS.md) for partial results, identifiers,
112
+ units and exact charge totals. Pandas is optional and conversion makes no API calls.
@@ -0,0 +1 @@
1
+ """Executable cookbook examples; importing them never calls the API."""