Skip to content

feat(log): expose the fx pnl component in the financial data log#4218

Merged
TaprootFreak merged 1 commit into
developfrom
feat/financial-log-fx-pnl
Jul 15, 2026
Merged

feat(log): expose the fx pnl component in the financial data log#4218
TaprootFreak merged 1 commit into
developfrom
feat/financial-log-fx-pnl

Conversation

@TaprootFreak

Copy link
Copy Markdown
Collaborator

Summary

totalBalanceChf (the operating equity) moves through transactional yield, price drift on open positions (FX) and errors. The FX component has not been visible anywhere - it was only derivable as a residual between the change log and the balance delta.

Every FinancialDataLog entry now carries balancesTotal.fxPnlChf: the price effect since the previous snapshot, computed as the previous net position times the price change, summed over all financialType assets. With it, every equity move decomposes into yield + fx + rest.

  • purely additive: no existing field, the valid-flag chain and the safety mode are untouched
  • the first entry (no reference point) omits the field; the dashboard maps missing values to zero, so historic entries stay readable
  • positions absent from either snapshot contribute nothing (new positions enter via flows, not FX)

Test plan

  • unit tests: long/short positions with rising/falling prices, financialType filter, no-predecessor case, appearing/disappearing assets, dashboard zero-default
  • full jest run green, format:check / lint / type-check clean

@TaprootFreak

Copy link
Copy Markdown
Collaborator Author

Both review tracks (conventions + correctness) came back clean on the first pass. Verified explicitly: the price-effect decomposition (previous net position times price change, quantity effect stays in the yield residual, no cross term), the skew-safe reference point (the predecessor is the last valid entry, matching how the chart consumes the series), the financialType filter parity with the balance buckets (synthetic RefCredit contributes nothing), and single-parse reuse of the predecessor message in the every-minute job.

@TaprootFreak TaprootFreak marked this pull request as ready for review July 15, 2026 13:07
Total balance moves through transactional yield, price drift on open
positions and errors - the price component was only derivable as a
residual. Every financial data log entry now carries fxPnlChf: the sum of
previous net position times price change per financialType asset since the
previous snapshot. Additive and backward-compatible: the first entry omits
the field, the dashboard maps missing values to zero, the valid-flag chain
and safety mode are untouched.
@TaprootFreak TaprootFreak force-pushed the feat/financial-log-fx-pnl branch from 926c935 to 352f47f Compare July 15, 2026 13:39
@TaprootFreak TaprootFreak merged commit 3c2cd50 into develop Jul 15, 2026
7 checks passed
@TaprootFreak TaprootFreak deleted the feat/financial-log-fx-pnl branch July 15, 2026 14:05
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