UNPKG

quantitivecalc

Version:

A TypeScript library providing advanced quantitative finance functions for risk analysis, performance metrics, and technical indicators. (Currently in development)

18 lines 1.45 kB
/** * Calculates the MACD (Moving Average Convergence Divergence) indicator for a given dataset. * * The function computes the MACD line, signal line, and histogram values for each row in the input data. * It uses exponential moving averages (EMAs) for the fast and slow periods, and the signal line is an EMA of the MACD line. * * @param data - Array of data objects containing price or value information. * @param sourceColumn - The key in each data object to use as the source value for calculations (e.g., 'close'). * @param macdColumn - The key to store the calculated MACD line value. Defaults to 'macd'. * @param signalColumn - The key to store the calculated signal line value. Defaults to 'macd_signal'. * @param histogramColumn - The key to store the calculated MACD histogram value. Defaults to 'macd_histogram'. * @param fastPeriod - The period for the fast EMA. Defaults to 12. * @param slowPeriod - The period for the slow EMA. Defaults to 26. * @param signalPeriod - The period for the signal line EMA. Defaults to 9. * @returns A new array of data objects with MACD, signal, and histogram columns added. */ export declare function calculateMACD(data: Array<Record<string, unknown>>, sourceColumn: string, macdColumn?: string, signalColumn?: string, histogramColumn?: string, fastPeriod?: number, slowPeriod?: number, signalPeriod?: number): Array<Record<string, unknown>>; //# sourceMappingURL=calculateMACD.d.ts.map