UNPKG

quantitivecalc

Version:

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

79 lines 2.84 kB
/** * Represents the return values for multiple assets on a specific date. * * @property date - The date for which the asset returns are recorded (ISO string). * @property [assetName: string] - The return value for each asset, where the key is the asset name and the value is a number (return) or string (date). */ export interface AssetReturn { date: string; [assetName: string]: number | string; } /** * Represents the weights of assets in a portfolio. * * Each key is the name of an asset, and its value is the corresponding weight (as a number). * The sum of all weights typically equals 1, representing the full allocation of the portfolio. * * @example * const weights: PortfolioWeight = { * 'AAPL': 0.5, * 'GOOG': 0.3, * 'TSLA': 0.2 * }; */ export interface PortfolioWeight { [assetName: string]: number; } /** * Represents a correlation matrix between assets. * Each key is an asset name, mapping to an object where keys are other asset names and values are the correlation coefficients between the two assets. * * @example * { * "AssetA": { "AssetA": 1, "AssetB": 0.5 }, * "AssetB": { "AssetA": 0.5, "AssetB": 1 } * } */ export interface CorrelationMatrix { [asset1: string]: { [asset2: string]: number; }; } /** * Represents the result of a portfolio rebalancing operation. * * @property date - The date when the rebalancing calculation was performed. * @property currentWeights - The current weights of assets in the portfolio. * @property targetWeights - The target weights for assets in the portfolio. * @property driftFromTarget - The deviation of current weights from target weights. * @property rebalanceRequired - Indicates whether rebalancing is necessary. * @property trades - An object mapping asset names to trade amounts (positive for buy, negative for sell). */ export interface RebalancingResult { date: string; currentWeights: PortfolioWeight; targetWeights: PortfolioWeight; driftFromTarget: PortfolioWeight; rebalanceRequired: boolean; trades: { [assetName: string]: number; }; } /** * Represents the risk contribution details for each asset in a portfolio. * * The keys are asset names, and the values contain risk metrics for each asset: * - `volatility`: The standard deviation of the asset's returns. * - `marginalRisk`: The incremental risk added by the asset to the portfolio. * - `componentRisk`: The portion of total portfolio risk attributed to the asset. * - `contributionPercent`: The percentage contribution of the asset to the portfolio's total risk. */ export interface RiskContribution { [assetName: string]: { volatility: number; marginalRisk: number; componentRisk: number; contributionPercent: number; }; } //# sourceMappingURL=types.d.ts.map