Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

lib: fix division by zero in roi when all assets are sold (fixes #2281) #2283

Merged
merged 1 commit into from
Nov 7, 2024

Conversation

adept
Copy link
Collaborator

@adept adept commented Nov 6, 2024

TWR computation works by computing the running total of "investment units" and their cost. If at some point we run out of units, we could divide by zero trying to compute new cost. Instead lets just reset the cost the the initial one as we have essentially went to the initial state (no units on hand, cost is an arbitrary chosen number 100).

This fixes #2281

@adept
Copy link
Collaborator Author

adept commented Nov 6, 2024

@simonmichael I dont understand the CI run failure here, but I think it is unrelated to my change

@simonmichael
Copy link
Owner

Yes, CI failure caused by recent hackage outage I guess. Thanks for the fix. 👍🏻

@simonmichael simonmichael merged commit c006959 into simonmichael:master Nov 7, 2024
1 check passed
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.

roi "Ratio has zero denominator" when --pnl account balances to 0
2 participants