quantitivecalc
Version:
A TypeScript library providing advanced quantitative finance functions for risk analysis, performance metrics, and technical indicators. (Currently in development)
17 lines • 1.29 kB
TypeScript
import { AssetReturn, PortfolioWeight } from './types';
/**
* Calculates the portfolio returns for a given dataset of asset returns and weights.
*
* Iterates over each row of asset returns, computes the weighted return for specified assets,
* and normalizes the result if the total weight does not sum to 1. The function adds the calculated
* portfolio return, total weight, and count of valid assets to each row.
*
* @param data - Array of asset return objects, where each object represents a row of asset returns.
* @param weights - An object mapping asset column names to their respective portfolio weights.
* @param returnColumns - Array of column names representing the assets to include in the calculation.
* @param portfolioReturnColumn - (Optional) Name of the column to store the calculated portfolio return. Defaults to 'portfolio_return'.
* @returns An array of objects, each containing the original row data, the calculated portfolio return,
* the total weight used, and the number of valid assets considered.
*/
export declare function calculatePortfolioReturns(data: AssetReturn[], weights: PortfolioWeight, returnColumns: string[], portfolioReturnColumn?: string): Array<Record<string, unknown>>;
//# sourceMappingURL=calculatePortfolioReturns.d.ts.map