eprbell / dali-rp2

DaLI (Data Loader Interface) is a data loader and input generator for RP2 (https://pypi.org/project/rp2), the privacy-focused, free, open-source cryptocurrency tax calculator: DaLI removes the need to manually prepare RP2 input files. Just like RP2, DaLI is also free, open-source and it prioritizes user privacy.
https://pypi.org/project/dali-rp2/
Apache License 2.0
62 stars 41 forks source link

Transaction Resolver resolves InTransaction into IntraTransaction for Existing RP2 Input #227

Open macanudo527 opened 3 months ago

macanudo527 commented 3 months ago

What?

When using the ODS plugin with existing data, the resolver creates IntraTransactions from Buy InTransactions that have fees. For some reason, this doesn't affect buys without fees.

Temporary Workaround

Replacing the unique ids from the buys in the original ODS with __unknown prevents the resolver from matching the transactions.

eprbell commented 3 months ago

The resolver turns a buy/in transaction into an intra one if there is also an out transaction with a unique id matching the buy/in transaction. Can you search through your debug logs for the unique id of the buy/in transaction and see if it occurs in an out transaction as well?

macanudo527 commented 3 months ago

Yeah, there are pairs of transactions in/out that share the same transaction id but are on the same exchange and have different assets. Basically, when I buy BTC, I do it in USDT, so there is a BTC buy, InTransaction, and a USDT sell, OutTransaction that share the same unique id. This isn't a problem when I use the rest API, but for some reason when using the existing RP2 plugin, it combines these transactions. They are on the same exchange and use different assets so this should never occur. Putting some kind of filter on the resolver would prevent this from happening. I'm just not sure why it happens on existing rp2 input.

I have a strange feeling we've had this bug before.

eprbell commented 3 months ago

That suggests there may be a bug in the way the plugin for that exchange (which one btw?) is assigning unique ids. Maybe the raw data contains other fields (or combination of fields) that can be used as unique ids for in/out transactions?

macanudo527 commented 3 months ago

So, the original plugin is okay. If I run the Binance REST API plugin, it works fine. Everything is okay.

It's just when I take the output of that run in ODS form ( and use the existing RP2 data plugin that reads previously generated ODS files in) and feed it back into dali-rp2 is when things cause trouble. It generates IntraTransactions where the to and from exchanges are equal. Binance to Binance, Can you think of a situation where the resolver should do that?

I guess my point is the resolver should never generate an IntraTransaction where the from and to exchanges are equal. That seems like a bug to me. Especially if it is generating it from two transactions with completely different assets.

eprbell commented 3 months ago

Thanks for clarifying. A few comments: