eprbell / rp2

Privacy-focused, free, open-source cryptocurrency tax calculator for multiple countries: it handles multiple coins/exchanges and computes long/short-term capital gains, cost bases, in/out lot relationships/fractioning, and account balances. It supports FIFO, LIFO, HIFO and it outputs in form 8949 format. It has a programmable plugin architecture
https://pypi.org/project/rp2/
Apache License 2.0
270 stars 43 forks source link

Changes to _seek_first_non_exhausted_acquired_lot to get highest cost lot #74

Closed debben closed 2 years ago

debben commented 2 years ago

Get the highest cost basis non-exhausted lot, not just the first non-exhausted. Fixes #73.

eprbell commented 2 years ago

Here's the summary:

Could you try this out and let me know if you see any more problems, either by running it or in the code?

Again, thanks so much for reporting and helping fix such tricky bugs!

debben commented 2 years ago

The changes look good. I checked again against my actual 2021 data and "golden copy" pdf report from the exchange and everything is matching up.

eprbell commented 2 years ago

Nice, I'll go ahead and merge then. If you see any more problems, just open a new issue or PR. Thanks!

eprbell commented 2 years ago

I ended up refactoring the entire accounting method plugin infrastructure. Now it's possible to build a new accounting method by defining only two small methods: see the new, simplified LIFO and HIFO. This should not only make it easier to write new plugins but also less error-prone (because most of the implementation is now common and factored in the superclass).

@debben can I ask you to try your test with this new implementation? All of our tests are passing, but I'd like to make sure your test is passing as well. Thanks.

debben commented 2 years ago

I gave the latest of main another run against my 2021 data. The HIFO report matches my golden copy from the exchange.

eprbell commented 2 years ago

Great, thanks!