/** * Drawdown Analysis Utility * * Provides drawdown analysis for DeFi vault price history using a * running-maximum algorithm. Calculates maximum drawdown, duration, * recovery time, and current drawdown from all-time high. */ /** * A single price observation in a vault's history */ export interface PricePoint { /** Unix timestamp in seconds */ timestamp: number; /** Price per share or NAV value */ value: number; } /** * Complete drawdown analysis result for a vault's price history */ export interface DrawdownAnalysis { /** Maximum drawdown as a percentage (0-100) */ maxDrawdown: number; /** Duration from peak to trough in days */ maxDrawdownDuration: number; /** Days from trough back to a new high, or null if not yet recovered */ recoveryTime: number | null; /** Current drawdown from the all-time high as a percentage (0-100) */ currentDrawdown: number; /** Highest observed value */ peakValue: number; /** Lowest value during the max drawdown period */ troughValue: number; /** Timestamp of the peak preceding the max drawdown */ peakTimestamp: number; /** Timestamp of the trough during the max drawdown */ troughTimestamp: number; } /** * Analyze drawdown characteristics from a vault's price history. * * Uses a running-maximum algorithm to efficiently compute: * - Maximum drawdown (peak-to-trough decline as a percentage) * - Drawdown duration (time from peak to trough) * - Recovery time (time from trough back to a new high) * - Current drawdown from the all-time high * * @param priceHistory - Array of timestamp/value pairs (need not be sorted) * @returns Complete drawdown analysis, or zero-valued result if fewer than 2 data points * * @example * ```typescript * const analysis = analyzeDrawdown([ * { timestamp: 1700000000, value: 1.00 }, * { timestamp: 1700086400, value: 1.05 }, * { timestamp: 1700172800, value: 0.95 }, * { timestamp: 1700259200, value: 1.10 }, * ]); * // analysis.maxDrawdown ~= 9.52 (from 1.05 down to 0.95) * ``` */ export declare function analyzeDrawdown(priceHistory: PricePoint[]): DrawdownAnalysis; //# sourceMappingURL=drawdown.d.ts.map