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

"Amount of sales for symbol exceeds the amount of buys" #2

Open
f2016862 opened this issue Apr 1, 2022 · 1 comment
Open

"Amount of sales for symbol exceeds the amount of buys" #2

f2016862 opened this issue Apr 1, 2022 · 1 comment

Comments

@f2016862
Copy link

f2016862 commented Apr 1, 2022

Bug report

"Amount of sales for symbol exceeds the amount of buys"
I checked all the BUYS and SELLS in my data and this is not possible.

@johanhellman
Copy link

There is an issue with decimal precision.

In particular this is impacted in calculateCapitalGainsForSale, on the if(sale.amount > 0) row.

The differences we have found are on the 14th decimal.

The solution is to replace it with if(Math.round(sale.amount, 4) > 0). Replace 4 with the appropriate precision.

You can also test this by modifying the throw Error row to:

throw Error("Amount of sales for symbol " + sale.symbol + " exceeds the amount of buys by " + sale.amount);

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

No branches or pull requests

2 participants