UNPKG

quantitivecalc

Version:

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

34 lines 2.34 kB
/** * Calculates compound returns grouped by time periods (yearly or monthly) from daily returns. * * Takes daily returns data and groups it by the specified time period, then calculates * compound returns for each period. The result includes the period identifier and * the compound return for that period. * * @param data - Array of objects representing the dataset. Each object should contain the returns column and date column. * @param returnsColumn - The key in each object representing the daily return value. Defaults to 'dailyReturn'. * @param dateColumn - The key in each object representing the date (timestamp in milliseconds or date string). Defaults to 'date'. * @param period - The time period to group by: 'yearly' or 'monthly'. Defaults to 'yearly'. * @param initialValue - The initial value to start compounding from. Defaults to 1. * @returns Array of objects with period identifier and compound return for each period. */ export declare function calculatePeriodicCompoundReturns(data: Array<Record<string, unknown>>, returnsColumn?: string, dateColumn?: string, period?: 'yearly' | 'monthly', initialValue?: number): Array<{ period: string; compoundReturn: number; startDate: number; endDate: number; }>; /** * Alternative version that adds periodic compound returns back to the original dataset. * Each row gets the compound return for its corresponding period. * * @param data - Array of objects representing the dataset. * @param returnsColumn - The key in each object representing the daily return value. * @param dateColumn - The key in each object representing the date (timestamp in milliseconds or date string). * @param resultColumn - The key to store the calculated periodic compound return in each object. * @param period - The time period to group by: 'yearly' or 'monthly'. * @param initialValue - The initial value to start compounding from. * @returns A new array of objects with the periodic compound return added to each row. */ export declare function addPeriodicCompoundReturnsToData(data: Array<Record<string, unknown>>, returnsColumn: string | undefined, dateColumn: string | undefined, resultColumn: string, period?: 'yearly' | 'monthly', initialValue?: number): Array<Record<string, unknown>>; //# sourceMappingURL=calculatePeriodicCompoundReturns.d.ts.map