/** * Value at Risk (VaR) and Conditional VaR (CVaR) Utility * * Risk quantification for DeFi vault returns using historical simulation. * Provides tail-risk metrics (VaR, CVaR) and downside-adjusted performance * measurement (Sortino ratio) for vault assessment. */ /** * VaR and CVaR analysis results for a return series. * All loss values are expressed as positive percentages (e.g., 2.5 means 2.5% loss). */ export interface VaRAnalysis { /** VaR at 95% confidence level (percentage loss not exceeded 95% of the time) */ var95: number; /** VaR at 99% confidence level (percentage loss not exceeded 99% of the time) */ var99: number; /** CVaR/Expected Shortfall at 95% (mean loss beyond VaR95, as percentage) */ cvar95: number; /** CVaR/Expected Shortfall at 99% (mean loss beyond VaR99, as percentage) */ cvar99: number; /** Number of return observations used in the analysis */ dataPoints: number; } /** * Calculate Value at Risk (VaR) and Conditional VaR (CVaR) using historical simulation. * * Historical simulation sorts observed returns and reads off percentiles directly, * making no distributional assumptions. This is appropriate for DeFi returns which * often exhibit fat tails and skewness that parametric methods underestimate. * * @param returns - Array of periodic returns as decimal fractions (e.g., -0.02 = -2% loss) * @returns VaR analysis with loss magnitudes as positive percentages * * @example * ```ts * const dailyReturns = [-0.01, 0.005, -0.03, 0.02, ...]; // 30+ observations * const analysis = calculateVaR(dailyReturns); * // analysis.var95 = 2.5 means "95% of the time, daily loss does not exceed 2.5%" * ``` */ export declare function calculateVaR(returns: number[]): VaRAnalysis; /** * Calculate the Sortino ratio for a return series. * * Sortino ratio improves on Sharpe by penalizing only downside volatility, * which better reflects investor preferences in asymmetric return distributions * typical of DeFi strategies. * * Formula: (mean return - risk-free rate) / downside deviation * * @param returns - Array of periodic returns as decimal fractions * @param riskFreeRate - Per-period risk-free rate as decimal (default: 0.02 = 2% per period). * Callers must convert annualized rates to match the return period * (e.g., annual 5% → daily 0.05/365 ≈ 0.000137). * @returns Sortino ratio, or 0 if insufficient data or no downside deviation * * @example * ```ts * const weeklyReturns = [0.01, -0.005, 0.015, -0.02, ...]; * const weeklyRiskFree = 0.05 / 52; // 5% annual → per-week * const sortino = calculateSortinoRatio(weeklyReturns, weeklyRiskFree); * ``` */ export declare function calculateSortinoRatio(returns: number[], riskFreeRate?: number): number; //# sourceMappingURL=var.d.ts.map