Skip to content

claude/fix-balance-history-daily-Lvhfp#764

Merged
dylanjeffers merged 2 commits intomainfrom
claude/fix-balance-history-daily-Lvhfp
Apr 14, 2026
Merged

claude/fix-balance-history-daily-Lvhfp#764
dylanjeffers merged 2 commits intomainfrom
claude/fix-balance-history-daily-Lvhfp

Conversation

@dylanjeffers
Copy link
Copy Markdown
Contributor

The daily granularity query was summing balance_usd across every hourly
snapshot in the day, inflating the result by ~24x. Each hourly row is a
point-in-time portfolio snapshot, not an additive quantity, so summing
across hours is wrong.

Sum across mints per hour first, then pick the latest-hour snapshot of
each day as the end-of-day balance.

claude added 2 commits April 14, 2026 22:19
The daily granularity query was summing balance_usd across every hourly
snapshot in the day, inflating the result by ~24x. Each hourly row is a
point-in-time portfolio snapshot, not an additive quantity, so summing
across hours is wrong.

Sum across mints per hour first, then pick the latest-hour snapshot of
each day as the end-of-day balance.
The SELECT aliased bucket_timestamp AS timestamp, so the secondary
ORDER BY timestamp DESC resolved to the alias (a constant within each
bucket) instead of the source row's timestamp. DISTINCT ON then picked
an arbitrary hour per day. Rename the underlying column to
source_timestamp in the CTE so the ORDER BY references it unambiguously
and end-of-day is selected.
@dylanjeffers dylanjeffers merged commit a8261c6 into main Apr 14, 2026
5 checks passed
@dylanjeffers dylanjeffers deleted the claude/fix-balance-history-daily-Lvhfp branch April 14, 2026 22:41
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.

2 participants