"Amount of sales for symbol exceeds the amount of buys"
f2016862 opened this issue · 1 comments
f2016862 commented
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 commented
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);