← API reference
Developer documentation

Regime analysis

Analyze your own price history for directional tendency and relative volatility.

POST https://api.morphiqlabs.com/v1/regime

The API uses deep learning to approximate outputs of a Markov-switching reference procedure. It returns a result synchronously for the final supplied observation. It does not forecast the next return or run a new Markov fit on each request.

Make a request

Use your normal API key in the Authorization: Bearer header. Follow the key setup instructions to set MORPHIQ_API_KEY in your terminal.

The example below requires Python 3 and cURL. It creates 512 synthetic prices for testing the request format, then submits them. Replace the array with your own prices.

Python 3 + cURL
python3 - <<'PY' > regime-request.json
import json, math

prices = [
    round(100 * math.exp(0.0004 * i + 0.018 * math.sin(i * 0.27)), 4)
    for i in range(512)
]
print(json.dumps({"prices": prices}))
PY

curl --fail-with-body 'https://api.morphiqlabs.com/v1/regime' \
  --header "Authorization: Bearer $MORPHIQ_API_KEY" \
  --header 'Content-Type: application/json' \
  --data-binary @regime-request.json

JSON is the only supported representation for this endpoint. There is no /v1/regime:batch route, polling step or symbol lookup.

Input window and ordering

For longer arrays, the API retains the newest 512 prices. Inference consumes the newest 507 within that window. It removes values from the beginning, never the recent end. There is no padding or resampling, and all supplied values are validated even if they will be cropped.

For exactly 512 input prices, the consumed range is [5, 512): indices 5 through 511. For N prices, it is [N−507, N). The result always describes the final supplied observation.

Use comparable prices with a consistent adjustment basis. No symbol or corporate-action data is supplied, so the API cannot correct splits or dividends for you.

Read the result

result.decision, result.direction and result.state share the same structure: status, basis.target and prediction. Available predictions contain a label, named scores and selection: "argmax".

Decision

The decision predicts the outcome of the reference procedure. The test and p-value bounds below define the prediction targets; they are not computed during this request.

LabelMeaning
not_eligibleReference model selection chooses a model other than the separate-scale Markov model; its scale-separation test does not apply.
supportedReference selection chooses the separate-scale model, and its separation-test p-value upper bound is at most 0.05.
unsupportedReference selection chooses the separate-scale model, and its p-value lower bound is greater than 0.05. Separation is not established; equal volatility is not proven.
unresolvedReference selection chooses the separate-scale model, but its p-value bounds straddle 0.05. This is a predicted reference outcome, not a serving error.

Direction: UP, DOWN, NEUTRAL

Direction describes the selected reference state’s fitted tendency. The target uses its mean divided by its return standard deviation: above 0.05 is UP, below −0.05 is DOWN, and the inclusive band between them is NEUTRAL. This is an effect-size convention, not statistical significance or the probability of a future gain. NEUTRAL never means unavailable.

State: LOWER_VOL, HIGHER_VOL

Volatility is relative to the other state in the reference Markov model. These labels do not mean low or high compared with historical norms. Either state can have an UP, DOWN or NEUTRAL tendency.

Applicability and failures

When decision selects not_eligible, direction and state have status: "not_applicable", prediction: null and reason_code: "predicted_not_eligible". They remain available for supported, unsupported and unresolved decisions.

basis remains present for every status. The schema reserves unavailable with a null prediction and prediction_unavailable reason code; V1 returns a non-200 error if inference fails, rather than a partial success. A predicted unresolved outcome is distinct from that failure.

Crisis status and volatility label

result.crisis reports whether the final price is in an exceptional volatility episode under the confirmed crisis-target-v1 method. The detector assesses the same 507 consumed prices as the model. It is causal, counts moves in either direction, and an isolated shock qualifies on its day.

statusscoreepisode_start_price_indexMeaning
crisisNumberOriginal-array indexReturn variability up to the final price is exceptional relative to this history’s own ordinary-high behaviour. Not a forecast.
not_crisisNumbernullNot in an episode at the final price.
unavailablenullnullNo statement is possible. reason_code is short_reference (fewer than 51 reference returns remain after excluding earlier crisis dates) or degenerate_reference (flat reference, for example all-equal prices). Never means not-crisis.

episode_start_price_index indexes your original array: consumed_price_range.start_index plus the episode’s position within the consumed range. crisis is a per-session signal of an acute shock, not a persistent regime. The API returns the raw detector status with no debouncing or smoothing, so a calm day inside a sustained episode can end it and the next large move can start a new one. Across every 507-price window of 1,343 securities held out from model training (2005–2026), there were about 3.4 episodes per security-year. 80% lasted one session, and 73% of security-years contained at least one crisis session. If you need persistence, apply your own rule to score and episode_start_price_index, for example requiring consecutive crisis sessions. Crisis means an acute onset: a volatility rise that builds gradually is reported as high, not crisis. The detector judges each session against the security’s own recent history, so a shock that arrives while volatility is already elevated is measured against that elevated level.

result.crisis_score_contract describes crisis.score: kind linear_readout, with entry threshold theta_in and exit threshold theta_out. The score is monotone in evidence. It is not a probability, not calibrated and not limited to [0, 1]. Outside an episode the detector enters when the score reaches theta_in; inside one it stays while the score is at least theta_out.

result.volatility uses the same head structure, with basis.target: "current_volatility" and a prediction of {"label": "low" | "high" | "crisis"}, without scores. crisis takes precedence whenever crisis.status is crisis. Otherwise low and high follow the state head’s LOWER_VOL and HIGHER_VOL, which are relative to the other reference state, not historical norms. When there is no crisis and the decision is not_eligible, the label is not_applicable with reason_code: "predicted_not_eligible". Read result.crisis alongside the label: low or high next to an unavailable crisis status does not mean the price history is not in crisis.

Scores are not confidence probabilities

result.score_contract.kind is uncalibrated_softmax and applies to the decision, direction and state heads. Scores are classification outputs, not calibrated probabilities, p-values or statistical confidence. Do not apply the reference test’s 0.05 threshold to them or multiply scores from different heads.

The current model is experimental and was trained on daily equity histories. Accepting another interval or domain does not establish fidelity there. Market evaluation did not include unsupported or unresolved examples; their presence in the label set does not establish performance for those classes.

Metadata and provenance

metadata.engines identifies morphiq-analytics, its version and Git revision. provenance.model_id identifies the immutable model release; model_sha256 hashes the exact served ONNX file bytes. teacher_executed: false records that the reference fit did not run on this request.

provenance.volatility_label identifies the label rule (method: "three-label-v1") with the model and crisis-detector identities it combines. provenance.crisis identifies the detector’s method, parameter-file SHA-256 and feature definition.

api_version identifies the route family, response_contract_version the response schema, and service_version the deployed API release. The body’s request_id matches the x-request-id header.

inference_time_us measures input-slice selection through prediction construction, including preprocessing and inference. It excludes request reading, validation, authentication, queueing, model loading, crisis assessment, response serialization and network time. crisis_time_us separately measures only the crisis assessment of the consumed prices. Neither is end-to-end API latency or an SLA.

See the complete request, response and error schemas for every field.

Billing and errors

One regime execution is priced at 100 CU, independent of input length within the request limits. Your account’s signed schedule determines the effective rate. Use your account’s cost quote to check the effective charge. cu_quoted and cu_charged report the applied policy. Pre-execution refusals cost zero. Charges commit at execution start; a failure or timeout after that point retains the charge.

HTTP statusAction or meaning
400Fewer than 512 prices, a nonpositive or nonfinite value, invalid JSON or as_of, or an unknown field such as cadence.
401 / 403Missing or invalid authentication, or an account or entitlement restriction.
402Account allowance exhausted.
405Wrong HTTP method. Use POST; the response includes Allow: POST.
413Encoded request exceeds the body limit, before any cropping.
429Account rate or concurrency limit reached.
503Capacity or a required service is unavailable. Follow Retry-After when supplied.
504Execution deadline exceeded. A charge already committed at execution start is retained.

Errors use application/problem+json with error.code, error.message and service metadata. They do not assert engine execution. Keep the request ID when contacting support. The reference lists all status codes and response fields.