quantitivecalc
Version:
A TypeScript library providing advanced quantitative finance functions for risk analysis, performance metrics, and technical indicators. (Currently in development)
17 lines • 1.31 kB
TypeScript
import { AssetReturn, CorrelationMatrix } from './types';
/**
* Calculates the rolling correlation matrix for a set of assets over a specified window size.
*
* @param data - An array of asset return objects, where each object contains asset return values keyed by asset name.
* @param assetColumns - An array of asset names (keys in each data object) to include in the correlation matrix.
* @param windowSize - Optional. The number of periods to use for the rolling window. If not provided, uses the entire data length.
* @returns An array of correlation matrices, each representing the correlations between assets for a window of data.
*
* @remarks
* - If `windowSize` is not specified, the function computes the correlation matrix for the entire dataset.
* - Each correlation matrix is a nested object where the outer keys are asset names, and the inner keys are asset names with correlation values.
* - Correlation values are set to `1` for diagonal elements (self-correlation), and `0` if there is insufficient data.
* - Handles missing or invalid data by skipping those entries in the calculation.
*/
export declare function calculateCorrelationMatrix(data: AssetReturn[], assetColumns: string[], windowSize?: number): CorrelationMatrix[];
//# sourceMappingURL=calculateCorrelationMatrix.d.ts.map