API v1 · Beta
What happens if the underlying moves $5?
Send a base option and the changes you want to explore. The API returns a full model reprice at each point, its change from the base price, and optional position P&L.
This endpoint requires a deployment containing scenario evaluation and an account with price-batch access. The examples use synthetic inputs. Set your key using the quickstart; set MORPHIQ_API_URL=http://127.0.0.1:8080 for a local development service. Cost quotes require a protected fixture with a commercial schedule; open admission does not provide quotes. Do not infer live availability from this documentation.
One move, explicit assumptions
curl --fail-with-body --request POST "${MORPHIQ_API_URL:-https://api.morphiqlabs.com}/v1/scenarios:evaluate" \
--header "Authorization: Bearer $MORPHIQ_API_KEY" \
--header 'Content-Type: application/json' \
--data '{
"contract": {
"exercise_style": "european",
"pricing_model": "black_scholes_merton",
"option_type": "call",
"spot": 100,
"strike": 100,
"time_to_expiry_years": 1,
"risk_free_rate": 0.05,
"dividend_yield": 0,
"volatility": 0.2
},
"scenarios": [
{
"spot_change": 5
}
],
"position": {
"quantity": 1,
"multiplier": 100
}
}'spot_change: 5 means five quote-currency units, not five percent. Volatility, time to expiry, rates, yield, strike and option direction remain fixed. Each point starts from the original contract; points do not accumulate. The derived spot must be finite; an overflowing change rejects the whole request before execution or quotation. These are conditional model valuations, not forecasts or market quotes.
Select black_scholes_merton with European exercise or bjerksund_stensland_1993 with American exercise. BS1993 is an approximation within the engine’s supported domain. Auto, QdFp, cash-dividend models and discrete dividend schedules are excluded from this endpoint. Other pricing endpoints retain their own model availability.
The response’s result contains base.inputs, base.result and an ordered scenarios list, one entry per submitted point. Each entry echoes its index and full inputs. A successful point includes result.price, price_change and, when a position is supplied, pnl; pnl_basis: base_model_value then states what P&L is measured from. Prices and price_change are per underlying unit; pnl is in currency. Position P&L equals the price change times signed quantity times multiplier; a negative quantity is short. It excludes trade entry cost, fees, financing and currency conversion. Zero changes remain zero.
Curves and heatmaps
Send explicit points in display order: a list of spots produces a curve; a flattened spot/volatility or spot/time grid produces a heatmap. The API preserves order and duplicate points. It does not interpolate or invent market data.
curl --fail-with-body --request POST "${MORPHIQ_API_URL:-https://api.morphiqlabs.com}/v1/scenarios:evaluate" \
--header "Authorization: Bearer $MORPHIQ_API_KEY" \
--header 'Content-Type: application/json' \
--data '{
"contract": {
"exercise_style": "european",
"pricing_model": "black_scholes_merton",
"option_type": "call",
"spot": 100,
"strike": 100,
"time_to_expiry_years": 1,
"risk_free_rate": 0.05,
"dividend_yield": 0,
"volatility": 0.2
},
"scenarios": [
{
"spot": 95,
"volatility": 0.15
},
{
"spot": 95,
"volatility": 0.2
},
{
"spot": 95,
"volatility": 0.25
},
{
"spot": 100,
"volatility": 0.15
},
{
"spot": 100,
"volatility": 0.2
},
{
"spot": 100,
"volatility": 0.25
},
{
"spot": 105,
"volatility": 0.15
},
{
"spot": 105,
"volatility": 0.2
},
{
"spot": 105,
"volatility": 0.25
}
],
"position": {
"quantity": 1,
"multiplier": 100
}
}'spot sets an absolute underlying price and cannot be combined with spot_change. volatility sets absolute annualized decimal volatility: 0.25 means 25%. elapsed_time_years subtracts that many years from base time to expiry, defaults to zero, and cannot be negative or exceed the remaining life. Exactly expiry is permitted; the engine determines applicable payoff behavior. Rates and yield stay fixed. An empty point object repeats the base assumptions.
The Python reference client creates a point, curve or grid, obtains a quote, and optionally executes with your explicit CU ceiling. It uses only the Python standard library and contains no pricing formulas. For example, run python3 scenario_tool.py --mode grid --model bs1993 to quote, then add --max-cu with your chosen budget to execute.
Bounds, quotes and failure behavior
Submit 1–99 scenario points. The base is one additional price calculation, so base plus points must fit the lower of 100 and your account’s price-batch limit. The normal batch body, response, concurrency and compute limits apply. Work runs on the isolated batch pool.
curl --fail-with-body --request POST "${MORPHIQ_API_URL:-https://api.morphiqlabs.com}/v1/cost/quote" \
--header "Authorization: Bearer $MORPHIQ_API_KEY" \
--header 'Content-Type: application/json' \
--data '{
"operation": "scenario_evaluate",
"request": {
"contract": {
"exercise_style": "european",
"pricing_model": "black_scholes_merton",
"option_type": "call",
"spot": 100,
"strike": 100,
"time_to_expiry_years": 1,
"risk_free_rate": 0.05,
"dividend_yield": 0,
"volatility": 0.2
},
"scenarios": [
{
"spot_change": 5
}
],
"position": {
"quantity": 1,
"multiplier": 100
}
}
}'Evaluation uses the existing price rates and price-batch entitlement. The quote counts the base and every submitted point, including duplicates and unchanged points. Fixed fees and minimums apply once to the request. Use the price filter on the cost schedule. Set X-MorphIQ-Max-CU on execution to enforce your budget; quoting reserves nothing. Internal compute units are separate from commercial CUs. See costs and receipts.
Malformed envelopes, ambiguous shocks, invalid time shifts and unsupported model selection reject the whole request before reservation. Engine numerical failures can occur after commitment: a failed scenario has status: error and a typed error, with no fabricated price or P&L; other points survive. A failed base valuation fails the entire request because relative changes are undefined. Position P&L overflow is a typed point error. Full committed charges remain owed on numerical failure or timeout; inspect metadata and do not blindly retry.
This operation is HTTP JSON only. Protobuf, gRPC and MCP scenario execution are not implemented. Engine and algorithm identities appear in metadata and price results; policy and charge receipts use the normal pricing contract. Review the endpoint reference for errors and schemas.
Solve for a target price
Target solving is not yet commercially available. The rate card below describes its planned billing. The request examples document the beta contract for local development.
Ask which underlying spot level, strike, time, rate or dividend yield makes your option worth a target price or Greek. POST /v1/scenarios:solve uses the engine’s bounded root search for the same explicit BSM and BS1993 models. Your client supplies controls and displays the result; it does not implement a numerical solver.
curl --fail-with-body --request POST "${MORPHIQ_API_URL:-https://api.morphiqlabs.com}/v1/scenarios:solve" \
--header "Authorization: Bearer $MORPHIQ_API_KEY" \
--header 'Content-Type: application/json' \
--data '{
"contract": {
"exercise_style": "european",
"pricing_model": "black_scholes_merton",
"option_type": "call",
"spot": 100,
"strike": 100,
"time_to_expiry_years": 1,
"risk_free_rate": 0.05,
"dividend_yield": 0,
"volatility": 0.2
},
"target": {
"kind": "option_price",
"value": 15
},
"lower": 50,
"upper": 150,
"coordinate_tolerance": 1e-9,
"value_tolerance": 0.000001
}'coordinate selects the single unknown: spot (default), strike, time_to_expiry, elapsed_time, rate or dividend_yield. lower and upper are finite search bounds in that coordinate’s units with lower strictly below upper. Spot, strike and time_to_expiry bounds must be positive; elapsed_time bounds lie within [0, time_to_expiry_years]; dividend_yield bounds are nonnegative; rate bounds may be negative. The bounds must also be far enough apart to hold the solve’s 32-interval scan at double precision; a narrower domain is refused as invalid_field on upper before quotation, with zero charge. For a time coordinate, omit elapsed_time_years or set it to zero. volatility is a coordinate for Greek targets only (positive bounds, with the volatility override omitted); to solve a price for volatility use implied volatility. The optional absolute volatility and elapsed_time_years have the same meaning as evaluation, and every other assumption stays fixed. Both tolerances must be positive: coordinate_tolerance localizes a boundary in the coordinate’s units (default 1e-9); value_tolerance is the allowed absolute target-value error (default 1e-6). A tight value tolerance can require a tighter coordinate tolerance, especially for large positions or where the price is nearly flat in the coordinate. Results return coordinate, boundaries with a coordinate value (or a lower/upper interval), regions, and explicit unresolved coverage cells with best_coordinate.
For a Greek target, use {"kind":"greek","greek":"delta","value":0.5} with delta, gamma, theta, vega, rho, vanna, volga, charm, veta or color. The target and every returned boundary value use the units the Greek endpoints publish (theta, charm, veta and color per year); value_tolerance is in the same units, and target_unit names them. For theta, charm, veta and color, value_tolerance / 365 must remain positive in binary64; a tolerance that rounds to zero returns 422 with field value_tolerance from both quotes and execution, before reservation or charging. Greek targets are per option and are not scaled by a position. A Greek the model cannot supply at a trial point aborts the solve with that Greek’s typed refusal. The sampled search can detect tangent roots where the curve touches the target at an extremum without changing sign. Structures smaller than the scan resolution can still be missed, and floating-point rounding can split a mathematical tangent into small evaluated crossings.
For a position target, use {"kind":"position_pnl","value":500,"position":{"quantity":2,"multiplier":100}}. Quantity is signed and nonzero; multiplier is positive. P&L is relative to the original base model mark, before changing volatility or time. It is not relative to trade entry cost. Target option prices are per underlying unit; target position P&L is in the position’s quote currency.
Solve API rate card
One flat charge covers the complete solve request, including every base, reference and search valuation. The same rate applies to option-price and position-P&L targets. Evaluation count, iterations, returned boundaries, position quantity and contract multiplier do not change the charge.
| Model | CU / request |
|---|---|
| BSM (European) | 100 CU |
| BS1993 (American) | 200 CU |
Quotes and spending limits
curl --fail-with-body --request POST "${MORPHIQ_API_URL:-https://api.morphiqlabs.com}/v1/cost/quote" \
--header "Authorization: Bearer $MORPHIQ_API_KEY" \
--header 'Content-Type: application/json' \
--data '{
"operation": "scenario_solve",
"request": {
"contract": {
"exercise_style": "european",
"pricing_model": "black_scholes_merton",
"option_type": "call",
"spot": 100,
"strike": 100,
"time_to_expiry_years": 1,
"risk_free_rate": 0.05,
"dividend_yield": 0,
"volatility": 0.2
},
"target": {
"kind": "option_price",
"value": 15
},
"lower": 50,
"upper": 150,
"coordinate_tolerance": 1e-9,
"value_tolerance": 0.000001
}
}'A free quote resolves the model and returns the exact conditional charge for one solve without running the numerical search or reserving funds. With the approved schedule, BSM quotes 100 CU and BS1993 quotes 200 CU. The operation requires its own permission and an account with the matching signed solve schedule. Quotes do not guarantee future funds, capacity or unchanged policy.
Set X-MorphIQ-Max-CU: 100 for a BSM solve or X-MorphIQ-Max-CU: 200 for a BS1993 solve. Admission reserves the full quoted amount before execution. A ceiling below the quote refuses with zero charge; equality is allowed. See costs and receipts.
The flat charge commits when execution starts. Completed no-root and unresolved searches, numerical failures and timeouts after commitment retain the full charge. A refusal or cancellation before execution starts charges zero. Use charge receipts for failed or interrupted requests; never infer a zero charge from a missing result or automatically retry an uncertain execution.
Start with outcome: solutions_found, no_solution_detected or incomplete. It summarizes coverage and boundaries, which remain the evidence. The response also reports the original base, adjusted fixed inputs, target with its target_unit, the coordinate and its coordinate_unit, search domain, tolerances, actual price_evaluations and the fixed scenario_solve/1 profile: 32 scan intervals, at most 64 refinements per candidate and a conservative bound of 4,774 pricing calls. These computational limits and the diagnostic evaluation count do not alter the flat request charge.
boundaries can contain evaluated points or sampled plateau intervals. Each boundary includes its evaluated value; subtract the requested target to obtain its residual. A point’s crossing: false means the sampled values did not establish a sign change across the target, as with a tangent or an endpoint hit. It does not invalidate the boundary or prove an exact mathematical tangency. regions indicate values above, below or at the target. coverage.status: resolved with basis: scan_resolution means the candidates resolved at the profile’s scan resolution; smaller structures can still be missed. Empty boundaries with resolved coverage mean no solution found at that resolution, not a proof of global nonexistence. Intervals are sampled evidence, not a claim that every real-valued coordinate was tested.
For coverage.status: unresolved, inspect each cell’s bounds, best coordinate, absolute error and typed reason. The API does not turn an incomplete search into a unique answer. A failed trial price aborts the solve with a typed problem whose solve_trial names the coordinate value and evaluation count where it stopped. For a position P&L target, reference_net_value is the base model value of the position and pnl_basis is base_model_value; both are absent for price and Greek targets.
Replay a boundary
Copy result.inputs for each point and let x = boundary.coordinate. Apply the mapping below for result.coordinate. The boundary’s value is the evaluated target quantity, not a replacement input.
| Coordinate | Change to copied inputs |
|---|---|
spot | spot = x |
strike | strike = x |
time_to_expiry | time_to_expiry_years = x |
elapsed_time | time_to_expiry_years = result.inputs.time_to_expiry_years - x |
rate | risk_free_rate = x |
dividend_yield | dividend_yield = x |
volatility | volatility = x |
For example, an elapsed-time boundary at 0.25 with result.inputs.time_to_expiry_years = 0.75 reprices with 0.50 years remaining. For an interval, use its lower or upper coordinate with the same mapping; its interior has only sampled coverage. Reprice option-price targets through the price endpoint, and Greek targets through the appropriate Greek endpoint in the published units. For position P&L, compute quantity × multiplier × (replayed price − result.base.result.price), using the position in result.target.
On a compatible deployment with the approved signed schedule, run python3 scenario_tool.py --mode solve --model bsm to quote, then add --max-cu 100 to execute. Use --mode solve-pnl for a position target, or --model bs1993 --max-cu 200 for BS1993. The client sends no automatic retries. See the solver endpoint reference. Scenario execution remains HTTP JSON only.
Reprice a book of positions
POST /v1/book-scenarios:evaluate reprices one or more books of signed option positions under one ordered scenario. The engine reprices every position and aggregates strategy, book and portfolio net values; your client supplies positions and shocks. Send one book for book totals, or several for portfolio totals.
curl --fail-with-body --request POST "${MORPHIQ_API_URL:-https://api.morphiqlabs.com}/v1/book-scenarios:evaluate" \
--header "Authorization: Bearer $MORPHIQ_API_KEY" \
--header 'Content-Type: application/json' \
--data '{
"currency": "USD",
"books": [
{
"id": "desk-a",
"positions": [
{
"id": "XYZ-P105",
"underlying": "XYZ",
"quantity": -2,
"multiplier": 100,
"contract": {
"exercise_style": "european",
"pricing_model": "black_scholes_merton",
"option_type": "put",
"spot": 100,
"strike": 105,
"time_to_expiry_years": 0.75,
"risk_free_rate": 0.04,
"dividend_yield": 0.01,
"volatility": 0.3
}
},
{
"id": "XYZ-C95",
"underlying": "XYZ",
"quantity": 3,
"multiplier": 100,
"contract": {
"exercise_style": "american",
"pricing_model": "bjerksund_stensland_1993",
"option_type": "call",
"spot": 100,
"strike": 95,
"time_to_expiry_years": 0.75,
"risk_free_rate": 0.04,
"dividend_yield": 0.01,
"volatility": 0.3
}
}
],
"strategies": [
{
"id": "risk-reversal",
"position_ids": [
"XYZ-P105",
"XYZ-C95"
]
}
]
}
],
"scenario": {
"name": "spot_up_5_vol_up_2",
"shocks": [
{
"kind": "spot_relative",
"relative": 0.05
},
{
"kind": "parallel_vol",
"shift": 0.02
}
]
}
}'A position is a signed quantity of contracts, a positive multiplier (underlying units per contract) and an explicit BSM or BS1993 contract. Each position also names its underlying, a label such as a ticker. Net value is quantity × multiplier × option price. The request’s currency (three uppercase letters, for example USD) states the currency of every price and total; all positions in a request share it and nothing is converted. Book, position and strategy ids are strings of 1–64 characters from A–Z, a–z, 0–9 and . _ : / -, so every client language preserves them exactly. Position ids are unique within a book, book ids within the request, and a strategy lists distinct ids of positions in its own book. Identifier errors name the exact field, for example books[0].strategies[1].position_ids[2].
Shocks apply left to right to every position, so order matters: spot_relative (relative above −1), parallel_vol (absolute shift), skew (slope per unit of ln(K/F)), rate (absolute shift per year), roll_down (nonnegative years) and vol_term (a linear ramp between a front and a back tenor, flat outside). Provide 1–16 shocks.
Collections are bounded before decoding: at most 50 books and 50 positions in total (each further narrowed by half your account’s price-calculation limit, since a position costs two calculations), 64 strategies and 1,024 strategy memberships in total. Each strategy may list at most 50 positions. Book solves allow one book and 16 positions, or your account’s contract limit if lower, with at most that many members per strategy and the same strategy and total membership limits. Exceeding these limits returns 422 before reservation.
The result echoes currency and states pnl_basis: base_model_value. Every position reports its submitted contract, unit prices, net values and pnl (shocked minus base net value), so a stored result can be replayed with the scenario. Strategies may overlap, so strategy totals are not additive; book and portfolio totals sum each position once. Each position counts as two price calculations (a base and a shocked valuation) against your price batch limit, and is charged at its model’s price rate with price-batch entitlement; there is no separate book rate. Quote with operation: book_scenario_evaluate. A position the model refuses fails the whole request with a typed error rather than returning a partial book. This operation is HTTP JSON only. See the endpoint reference.
Explain where the P&L came from
POST /v1/book-scenarios:explain takes the same request and returns exactly the evaluation result, with an attribution object added for each book and for the portfolio; one parser handles both routes. Both run the same engine valuation, so shared fields are identical. attribution holds expiry_buckets and strike_buckets. Positions, expiry buckets and strike buckets each partition the book, so each sums to its pnl; strategies may overlap and are not additive. Buckets group only bitwise-identical expiries and strikes. Entitlement, limits, quotes (operation: book_scenario_explain) and charging are identical to the scenario route. See the endpoint reference.
Solve a book for a target P&L
Book solving is not yet commercially available. POST /v1/book-scenarios:solve asks at which spot levels one book’s modeled P&L equals a target. Add strategy_id to solve only one strategy’s members. Each solved position is charged once at its model’s solve rate: the two-leg BSM straddle below quotes 200 CU, and a strategy solve charges only the strategy’s members. Unknown strategies and strategies with no members are rejected before quoting or reserving funds. The engine owns the bounded root search; your client supplies the book, the scenario and the bounds. A refused price aborts the solve with a problem whose solve_trial gives the spot and evaluation count where it stopped and whose field names the refusing position.
curl --fail-with-body --request POST "${MORPHIQ_API_URL:-https://api.morphiqlabs.com}/v1/book-scenarios:solve" \
--header "Authorization: Bearer $MORPHIQ_API_KEY" \
--header 'Content-Type: application/json' \
--data '{
"currency": "USD",
"book": {
"id": "desk-a",
"positions": [
{
"id": "XYZ-C100",
"underlying": "XYZ",
"quantity": 1,
"multiplier": 100,
"contract": {
"exercise_style": "european",
"pricing_model": "black_scholes_merton",
"option_type": "call",
"spot": 100,
"strike": 100,
"time_to_expiry_years": 0.75,
"risk_free_rate": 0.04,
"dividend_yield": 0.01,
"volatility": 0.3
}
},
{
"id": "XYZ-P100",
"underlying": "XYZ",
"quantity": 1,
"multiplier": 100,
"contract": {
"exercise_style": "european",
"pricing_model": "black_scholes_merton",
"option_type": "put",
"spot": 100,
"strike": 100,
"time_to_expiry_years": 0.75,
"risk_free_rate": 0.04,
"dividend_yield": 0.01,
"volatility": 0.3
}
}
],
"strategies": [
{
"id": "long-call",
"position_ids": [
"XYZ-C100"
]
}
]
},
"scenario": {
"name": "hold_three_months",
"shocks": [
{
"kind": "roll_down",
"years": 0.25
}
]
},
"signed_reference_net_value": 2036,
"target_pnl": 0,
"lower": 50,
"upper": 200
}'P&L is horizon value minus signed_reference_net_value: a debit paid is positive, a credit received is negative, in currency. target_pnl defaults to 0 (breakeven). The scenario holds the horizon and market assumptions and may not contain spot_relative, because the solve owns the spot axis; it may be empty. lower and upper are positive spot bounds, and every solved position must name the same underlying and share the same stored spot. The total roll-down may reach expiry but must not pass any solved position’s expiry; the engine allows small floating-point rounding differences at exact expiry. Both checks apply to the selected strategy’s members, or the whole book if no strategy is selected, and reject invalid requests before quotation or reservation. So does a domain too narrow for the 32-interval scan at double precision, refused as invalid_field on upper. Tolerances coordinate_tolerance (spot, default 1e-9) and pnl_tolerance (currency, default 1e-6) must be positive. Up to 16 explicit BSM or BS1993 positions are accepted.
The response uses the same outcome, boundaries, regions and coverage as the single-option solve, with coordinate: spot, coordinate_unit: price and value in modeled P&L (target_unit: position_value, in currency, with pnl_basis: signed_reference_net_value). It echoes currency, the shared underlying and each solved position’s submitted contract. It reports evaluations (each prices every solved position once) and price_evaluations ((evaluations + 1) × solved positions, including one base valuation per position). The profile’s max_price_evaluations includes those base valuations too. All submitted models must be entitled. The charge is one solve unit per solved position at its model’s rate. A quote’s resolved_models lists the actual solved models and counts solved positions per model; selecting a strategy restricts these counts to its members. This is separate from the single billable request in quote.lines. A search is never presented as a unique or global answer; inspect unresolved cells. Execution uses the same admission path as the single-option solve; quote with operation: book_scenario_solve and set X-MorphIQ-Max-CU. The commercial rate for book solves is not final. See the endpoint reference.