OpenPond
1Branch0Tags
GL
glucryptochore: bump opentool to v0.8.28 and add template p...
b9421303 days ago2Commits
typescript
export type PriceChangeResult = { previous: number; percent: number; }; export function computePriceChange( values: number[], lookback = 24 ): PriceChangeResult | null { if (values.length < 2) return null; const current = values[values.length - 1]; const index = Math.max(0, values.length - 1 - lookback); const previous = values[index]; if (previous === 0) return null; const percent = ((current - previous) / previous) * 100; return { previous, percent, }; }