quantitivecalc
Version:
A TypeScript library providing advanced quantitative finance functions for risk analysis, performance metrics, and technical indicators. (Currently in development)
18 lines • 1.23 kB
TypeScript
/**
* Calculates the maximum drawdown for a time series of values.
*
* The function iterates through the provided data array, tracking the peak value and computing the drawdown
* at each point. The maximum drawdown observed up to each row is stored in the specified result column.
*
* @param data - An array of objects representing the time series data.
* @param sourceColumn - The key in each object from which to read the numeric value for drawdown calculation.
* @param resultColumn - The key in which to store the calculated maximum drawdown for each row (default: 'maxDrawdown').
* @returns A new array of objects, each including the calculated maximum drawdown in the specified result column.
*
* @remarks
* - If the value in `sourceColumn` is not a valid number, the previous row's drawdown value is used.
* - The drawdown is calculated as `(peak - value) / peak`, where `peak` is the highest value observed so far.
* - If the input data is empty or undefined, an empty array is returned.
*/
export declare function calculateMaxDrawdown(data: Array<Record<string, unknown>>, sourceColumn: string, resultColumn?: string): Array<Record<string, unknown>>;
//# sourceMappingURL=calculateMaxDrawdown.d.ts.map