quantitivecalc
Version:
A TypeScript library providing advanced quantitative finance functions for risk analysis, performance metrics, and technical indicators. (Currently in development)
21 lines • 1.41 kB
TypeScript
/**
* Calculates the rolling Sharpe ratio for a given dataset.
*
* The Sharpe ratio is computed over a moving window of specified size, using the provided returns column.
* The result is stored in a new column for each row, with `null` for rows where there is insufficient data.
*
* @param data - Array of data objects containing return values.
* @param returnsColumn - The key in each data object representing the return value.
* @param resultColumn - The key to store the calculated Sharpe ratio in each data object.
* @param windowSize - The number of periods to use for the rolling window (default: 252, typical for daily data over one year).
* @param riskFreeRate - The annual risk-free rate to use in the calculation (default: 0.02, or 2%).
* @returns A new array of data objects with the Sharpe ratio added to each row under `resultColumn`.
*
* @remarks
* - The Sharpe ratio is annualized by multiplying by `sqrt(252)`.
* - If there is insufficient data in the window, the result is `null` for that row.
* - Assumes daily data; adjust `windowSize` and risk-free rate conversion for other frequencies.
*/
export declare function calculateSharpeRatio(data: Array<Record<string, unknown>>, returnsColumn: string, resultColumn: string, windowSize?: number, // 1 year for daily data
riskFreeRate?: number): Array<Record<string, unknown>>;
//# sourceMappingURL=calculateSharpeRatio.d.ts.map