Skip to content

Adjust net deposit baseline for CAGR start - #103

Open
dbigham wants to merge 1 commit into
mainfrom
codex/fix-total-pl-calculation-for-eli-s-account-myoabn
Open

Adjust net deposit baseline for CAGR start#103
dbigham wants to merge 1 commit into
mainfrom
codex/fix-total-pl-calculation-for-eli-s-account-myoabn

Conversation

@dbigham

@dbigham dbigham commented Oct 12, 2025

Copy link
Copy Markdown
Owner

Summary

  • derive the baseline equity from the day before the CAGR start when computing net deposits
  • fall back to start-of-period equity if no prior data exists and update per-currency totals accordingly
  • add a regression test that covers the adjusted CAGR baseline handling

Testing

  • npm test -- --test test/totalPnlSeries.test.js

https://chatgpt.com/codex/tasks/task_e_68ebbc889bc0832dacb91ab5736fd7f3

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting

Comment thread server/src/index.js
Comment on lines +3627 to +3630
if (result.netDeposits.perCurrency) {
const currentCad = Number(result.netDeposits.perCurrency.CAD) || 0;
const nextCad = currentCad + baselineEquity;
result.netDeposits.perCurrency.CAD = Math.abs(nextCad) < CASH_FLOW_EPSILON ? 0 : nextCad;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Avoid double counting baseline equity in per-currency totals

When computeNetDeposits adjusts for a CAGR start date it now adds baselineEquity to result.netDeposits.perCurrency.CAD. The per-currency map produced by computeNetDepositsCore already reflects the full CAD funding history (no CAGR pruning), so after combinedCad is increased by the baseline the CAD entry already matches that total. Adding the baseline again inflates the CAD amount by the start-of-period equity and makes per-currency totals no longer align with combinedCad, yielding overstated CAD deposits whenever the adjustment runs. The CAD entry should either be left unchanged or reduced by pre-start flows instead of adding the baseline a second time.

Useful? React with 👍 / 👎.

@dbigham
dbigham force-pushed the main branch 3 times, most recently from c7f2145 to c8636e3 Compare November 15, 2025 21:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant