- Preview
- A fictional GBP/NZD daily series with a chart and reversible quotes.
- Inputs
- Supply distinct uppercase three-letter base and quote codes. Each point needs a valid calendar date in YYYY-MM-DD and a finite, positive rate in quote currency units per one base unit. The rate’s reciprocal must also be finite. The last valid reading per date wins.
- Source options
- Supply dated closes from the provider’s calendar. The horizontal axis uses calendar time and the line connects the supplied quotes. An empty rates array represents a known empty series. Pass null when the feed is unavailable.
- Actions
- Tap or drag on the plot to select the closest supplied date, or use the arrow keys, Home and End. Escape and Latest rate return to the most recent quote. Swapping preserves the selected date and displays the reciprocal. The percentage compares with the previous supplied quote in the current direction.
import type { ExchangeSnapshot } from "@lumo/widgets/catalog/travel/currency";
interface ProviderQuote { date: string; rates: Record<string, number> }
export function toExchangeSnapshot(base: string, quote: string, readings: readonly ProviderQuote[]): ExchangeSnapshot {
return { base, quote, rates: readings.flatMap(row => {
const rate = row.rates[quote];
return Number.isFinite(rate) && rate > 0 ? [{ date: row.date, rate }] : [];
}) };
}