Skip to content

v0.3.1

Choose a tag to compare

@cmj0121 cmj0121 released this 28 Apr 06:02
· 154 commits to main since this release

What's new

Time-aware routes now accept an optional ?date=YYYY-MM-DD query parameter to pin the response to a historical date.

  • /now?date=2012-02-02 — wall-clock HH:MM stays current; the calendar / weekday strip / year-progress caption all reflect the override day.
  • /stock?date=2012-02-02 — loads the latest stock data on or before the date (closest completed trading session). Live breadth is skipped on historical lookups; the closed-market enrichment block (positioning + breadth + credit, on the TW path) renders unconditionally.

Invalid ?date= values fall through silently to the live path, matching the existing behavior of ?format= and ?region=.

Implementation notes

  • New middleware DateOverrideDetector parses the override strictly with time.ParseInLocation against the caller's resolved location — middleware order pinned TimezoneDetector → DateOverrideDetector → … in server.New().
  • New helpers middleware.GetDate(c) and middleware.NowFor(c) — any future time-aware service consumes them for free.
  • Optional quote.HistoricalProvider and twse.HistoricalProvider interfaces (mirroring the existing LiveBreadthProvider pattern) avoid breaking-change to existing Provider implementations.
  • Yahoo GetAt uses a narrow period1/period2 window (asOf-14d → asOf+1d) and walks indicator timestamps backwards to the latest bar at-or-before end-of-asOf-day; IsClosed forced true for historical bars.
  • Future-dated asOf clamped to time.Now() defensively in both providers.
  • Cached layers passthrough on historical lookups (no date-keyed cache).

Test coverage

  • Middleware: explicit override, invalid date fall-through, timezone interaction, no-middleware safety.
  • /now: override shifts caption; invalid date falls through.
  • quote/yahoo: latest-bar-at-or-before pick, future clamp, empty-window handling.
  • quote/cached: bypasses live cache for historical, ErrUnavailable when inner is not historical.
  • twse: walk-back from asOf, future clamp, cache bypass, ErrUnavailable when inner is not historical.
  • /stock: GetAt routing under override, TW path skips live breadth and live Get, invalid date fall-through.