ARCH
Install and import#
npm install fintech-algorithmsimport { calculate } from "fintech-algorithms/volatility-and-covariance/conditional-volatility/arch";Signature#
calculate(data)Follow a squared shock through a finite coefficient queue. Supplied-parameter educational reference; no fitted performance claim.
Parameters#
| Name | Type | Notes |
|---|---|---|
data | TopicInput | See data-contract/CONTRACT.md. |
Returns#
TopicResult
Structured result with readiness, values, parameters, and diagnostics.
Warm-up#
The first depends on window or model order positions are null prefix until minimum history exists.
Errors#
- When required data is missing, non-finite, malformed, or out of range — raises ContractError / Error
Complexity: time O(nq),
space Full diagnostic trace retained for teaching; see implementation for observation/window/matrix dimensions.
Worked example#
executed Captured by running this function on the input its own test provides. Real output of real code — but not asserted against a published figure.
Input#
{
"returns": [-0.02, 0.01, 0],
"parameters": {
"omega": 0.000002,
"initial_variance": 0.0001,
"alphas": [0.2, 0.1]
}
}Call#
calculate(data)Returns#
object with 8 fields: topic_id, title, parameters, series, latest, ready, ready_at, diagnostics
{
"topic_id": "D10-F03-A01",
"title": "ARCH",
"parameters": {
"omega": 0.000002,
"initial_variance": 0.0001,
"alphas": [0.2, 0.1]
},
"series": [
null,
null,
{
"index": 2,
"variance": 0.000062,
"intercept": 0.000002,
"lag_contributions": [0.00002, 0.00004]
}
],
"latest": {
"index": 2,
"variance": 0.000062,
"intercept": 0.000002,
"lag_contributions": [0.00002, 0.00004]
},
"ready": true,
"ready_at": 2,
"diagnostics": {
"causal": true,
"input_count": 3,
"fitted_parameters": false,
"model": "arch"
}
}Diagrams#
Calculation flow#
ARCH — calculation-flow
flowchart TD
N0["Read only past residuals"]
N1["Square each retained lag"]
N2["Multiply by its own coefficient"]
N3["Add intercept; current shock waits"]
N0 --> N1 --> N2 --> N3
ARCH — decision-boundary
flowchart TD
A["Supplied observations and parameters"] --> B{"Contract valid?"}
B -->|No| E["Reject with explicit error"]
B -->|Yes| C{"Required history available?"}
C -->|No| W["Withhold; never insert zero"]
C -->|Yes| D["ARCH calculation"]
D --> F["Inspect diagnostics and stated limits"]
How it works#
This page states the contract — how to call it correctly. The article explains the concept: why it works, and where it breaks.
References#
- Scope of evidence