Covariance Node
Sample Covariance — Two Series
Overview
The Covariance Node computes the sample covariance between two aligned time series. Covariance measures how two variables change together: positive covariance means they tend to move in the same direction, negative means they move oppositely.
Unlike correlation, covariance is not normalised, so its magnitude depends on the scale of the inputs.
Dual Input: This node requires two aligned input series — input1 and input2. Both must share the same timestamps.
Formula
Inputs & Outputs
| Slot | Direction | Type | Description |
|---|---|---|---|
| input1 | Input | { values, timestamps } | First numeric series (X) |
| input2 | Input | { values, timestamps } | Second numeric series (Y) |
| values | Output | (number | null)[] | Scalar covariance repeated per aligned timestamp |
| covariance | Output | number | null | Scalar covariance value |
| timestamps | Output | number[] | Aligned timestamps |
Use Cases
Portfolio Construction
Compute the covariance matrix component for any two assets to use in mean-variance optimisation (Markowitz).
Hedge Ratio Estimation
Cov(X, Y) / Var(Y) gives the OLS beta for hedging X with Y.
Risk Attribution
Measure how much two strategy return streams contribute to combined portfolio variance.
Tips & Best Practices
Align Timestamps
Both input series must have matching timestamps. Misaligned series will produce incorrect results.
Prefer Returns Over Prices
Feed log-return or simple-return series rather than raw prices to obtain a stationary, interpretable covariance.
Covariance vs Correlation
Covariance is scale-dependent. Use the Correlation node for a normalised (−1 to 1) measure of co-movement.