UNPKG

quantitivecalc

Version:

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

31 lines 1.66 kB
import { PortfolioWeight, RebalancingResult } from './types'; /** * Calculates portfolio rebalancing actions over time based on asset prices, target weights, and a rebalance threshold. * * @param data - Array of records containing asset prices and dates for each period. * @param priceColumns - List of keys in each record that represent asset price columns. * @param targetWeights - Object mapping asset names to their target portfolio weights (e.g., `{ 'AAPL': 0.5, 'GOOG': 0.5 }`). * @param rebalanceThreshold - Maximum allowed drift from target weights before triggering a rebalance (default: `0.05`). * @param portfolioValue - Initial total value of the portfolio (default: `100000`). * @param dateColumn - Key in each record representing the date (default: `'date'`). * @returns Array of rebalancing results for each period, including current weights, drift, rebalance status, and required trades. * * @remarks * - The function assumes that `targetWeights` sum to 1.0. * - Trades are calculated as the number of shares to buy/sell to reach target weights when rebalancing is required. * - If no rebalance is required, trades will be zero for all assets. * * @example * ```typescript * const results = calculateRebalancing( * priceData, * ['AAPL', 'GOOG'], * { AAPL: 0.6, GOOG: 0.4 }, * 0.05, * 50000, * 'date' * ); * ``` */ export declare function calculateRebalancing(data: Array<Record<string, unknown>>, priceColumns: string[], targetWeights: PortfolioWeight, rebalanceThreshold?: number, portfolioValue?: number, dateColumn?: string): RebalancingResult[]; //# sourceMappingURL=calculateRebalancing.d.ts.map