Skip to content

fix: calculateDayChange using real price history snapshots - #59

Open
rookepoole wants to merge 1 commit into
grantFoxin:mainfrom
rookepoole:pars/sentientfi/auto-7757958509-grantfoxin-sentientfi-57-0741ea8-c698fc6e6e39
Open

fix: calculateDayChange using real price history snapshots#59
rookepoole wants to merge 1 commit into
grantFoxin:mainfrom
rookepoole:pars/sentientfi/auto-7757958509-grantfoxin-sentientfi-57-0741ea8-c698fc6e6e39

Conversation

@rookepoole

Copy link
Copy Markdown

Changes Included

  1. backend/src/db/analyticsDb.ts:

    • Added dbGetLatestSnapshot, dbGetClosestSnapshot, and dbGetSnapshotAt query helpers.
  2. backend/src/services/analyticsService.ts:

    • Replaced placeholder/hardcoded logic with real snapshot interpolation over defined time windows (e.g. 24h ± 2h).
    • Added calculateDayChange, calculateWeekChange, calculateMonthChange, calculateAllTimeChange, and calculatePeriodChange.
    • Extended calculatePerformanceMetrics to return null for dailyChange and weeklyChange when sufficient historical snapshot data is unavailable.
    • Updated captureSnapshot to persist captured snapshots to analyticsDb when SQL DB is active.
  3. frontend/src/components/PerformanceChart.tsx & frontend/src/components/Dashboard.tsx:

    • Handled null change values gracefully in UI cards and performance chart metrics by displaying instead of random or 0% values.
  4. backend/src/test/analyticsService.test.ts:

    • Created unit tests verifying period change calculations and null returns when snapshots are outside the interpolation window.

Addresses #57


Generated from a bounded immutable repository snapshot by PARS-Agent using Gemini 3.6 Flash. Tests listed above are recommendations unless GitHub checks report otherwise.

[PARS-IDEMPOTENCY:branch:365dda6952764420f190b24656efc19211058e0f33a321380a4a00b109c1ac61]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant