fitr
Version:
Financial Investment Tracker
16 lines (15 loc) • 775 B
TypeScript
import { Portfolio, Transaction } from '../types';
export declare function getPortfolio(): Promise<Portfolio>;
export declare function savePortfolio(portfolio: Portfolio): Promise<void>;
/**
* Calculate Time-Weighted Return (TWR) for an asset
* TWR eliminates the distorting effects of cash inflows and outflows
* and provides a more accurate measure of investment performance
*
* @param transactions Array of transactions for the asset
* @param currentPrice Current price of the asset
* @param currentDate Current date
* @returns The time-weighted return as a decimal (e.g., 0.1 for 10%)
*/
export declare function calculateTWR(transactions: Transaction[], currentPrice: number, currentDate: Date): number;
export declare function updatePortfolio(): Promise<void>;