/** * Equity Tracker — time-series equity snapshots for PnL analysis. * * Stores snapshots in ~/.perp/equity-history/YYYY-MM.jsonl (monthly files). * Computes daily PnL, Sharpe ratio, max drawdown, win/loss stats. */ export interface EquitySnapshot { ts: string; exchange: string; equity: number; available: number; marginUsed: number; unrealizedPnl: number; positionCount: number; } export interface DailyPnl { date: string; exchange: string; startEquity: number; endEquity: number; pnl: number; pnlPct: number; } export interface PnlMetrics { totalReturn: number; totalReturnPct: number; dailyReturns: DailyPnl[]; sharpeRatio: number; maxDrawdown: number; maxDrawdownPct: number; winDays: number; lossDays: number; winRate: number; peakEquity: number; currentDrawdown: number; currentDrawdownPct: number; bestDay: DailyPnl | null; worstDay: DailyPnl | null; avgDailyPnl: number; period: { from: string; to: string; days: number; }; } export declare function saveEquitySnapshot(snap: EquitySnapshot): void; export declare function readEquityHistory(opts?: { exchange?: string; since?: Date; until?: Date; }): EquitySnapshot[]; /** Group snapshots by date, take first and last per day for daily PnL. */ export declare function computeDailyPnl(snapshots: EquitySnapshot[], exchange?: string): DailyPnl[]; /** Compute comprehensive PnL metrics from equity snapshots. */ export declare function computePnlMetrics(snapshots: EquitySnapshot[], exchange?: string): PnlMetrics; /** Compute weekly PnL from daily PnL data. */ export declare function aggregateWeekly(daily: DailyPnl[]): DailyPnl[];