/** * Historical funding rate tracking. * * Stores funding rate snapshots as JSONL files in ~/.perp/funding-rates/ * organized by month (YYYY-MM.jsonl). Provides averaging and trend analysis * over configurable time windows. */ import type { ExchangeFundingRate } from "./rates.js"; export interface FundingHistoryEntry { ts: string; symbol: string; exchange: string; rate: number; hourlyRate: number; } export interface HistoricalAverages { avg1h: number | null; avg8h: number | null; avg24h: number | null; avg7d: number | null; } export declare function cleanupOldFiles(): void; export declare function _resetCleanupFlag(): void; /** * Save current funding rates as a historical snapshot. * Deduplicates: skips entries if same symbol+exchange was saved within 5 minutes. */ export declare function saveFundingSnapshot(rates: ExchangeFundingRate[]): void; /** * Get average funding rate for a symbol+exchange over the last N hours. * Returns null if no data available. */ export declare function getAvgFundingRate(symbol: string, exchange: string, hours: number): number | null; /** * Get all historical rates for a symbol+exchange in a time range. */ export declare function getHistoricalRates(symbol: string, exchange: string, startTime: Date, endTime: Date): { ts: string; rate: number; hourlyRate: number; }[]; /** * Get averaged rates for all symbols across time windows. * Returns a Map with key format "SYMBOL:exchange". */ export declare function getHistoricalAverages(symbols: string[], exchanges: string[]): Map; /** * Calculate effective annualized return considering compounding frequency. * * All three main exchanges (HL, PAC, LT) compound every 1h (8760 times/year). * * Formula: (1 + rate)^(8760/compoundingHours) - 1 * * @param hourlyRate - the per-hour funding rate * @param compoundingHours - how often the exchange compounds (1 for all main exchanges) * @returns effective annualized return as a decimal (not percentage) */ export declare function getCompoundedAnnualReturn(hourlyRate: number, compoundingHours: number): number; /** * Get the compounding hours for an exchange. * All main exchanges (HL, PAC, LT) compound every 1h. */ export declare function getExchangeCompoundingHours(exchange: string): number;