Covariance Node

Sample Covariance — Two Series

StatisticalRelationship

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

cov(X, Y) = Σ[(xᵢ − μₓ)(yᵢ − μᵧ)] / (n − 1)
Sample covariance (divides by n−1). Computed over the full aligned input window.

Inputs & Outputs

SlotDirectionTypeDescription
input1Input{ values, timestamps }First numeric series (X)
input2Input{ values, timestamps }Second numeric series (Y)
valuesOutput(number | null)[]Scalar covariance repeated per aligned timestamp
covarianceOutputnumber | nullScalar covariance value
timestampsOutputnumber[]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.

Related Indicators