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
64 stars 42 forks source link

Unsupported transaction types "spend" and "receive" (Kraken) as well as RP2RuntimeError: Internal error: both 'crypto_fee' and 'fiat_fee' are defined #256

Open githubuserthatsright opened 2 weeks ago

githubuserthatsright commented 2 weeks ago

Hi,

of course I am trying out rp2 5 days ahead of the tax filing deadline and nothing works at all. Having installed Python, rp2 and dali-rp2 correctly (after an additional 4+ gigabyte MS VC install, sigh), I have configured the config.ini like so:


# Global configuration

# Data loaders
[dali.plugin.input.rest.kraken MyNameishere]
account_holder = <account_holder>
api_key = cantputtherealonehere
api_secret = cantputtherealonehere
native_fiat = EUR
thread_count = 4

[dali.plugin.pair_converter.ccxt_kraken]
historical_price_type = nearest
fiat_priority = EUR

[dali.plugin.pair_converter.historic_crypto]
historical_price_type = nearest

and then set the two variables for generic country to be EUR and 365 and fired up

dali_generic -s -o oututfile -p testme config.ini

It ran for AN HOUR and then gave me this:


INFO: Country: generic
INFO: Initialized input plugin 'dali.plugin.input.rest.kraken MyNamehere'
INFO: Initialized pair converter plugin 'dali.plugin.pair_converter.ccxt_kraken'
INFO: Initialized pair converter plugin 'dali.plugin.pair_converter.historic_crypto'
INFO: Reading crypto data using plugin 'dali.plugin.input.rest.kraken MyNamehere
ERROR: Unsupported transaction type: receive (skipping): {'aclass': 'currency', 'amount': '58.1500', 'asset': 'ZEUR', 'balance': '85.3278', 'fee': '0.0000', 'refid': 'editedout', 'time': '1702988682.636202', 'type': 'receive', 'subtype': ''}. Please open an issue at https://github.com/eprbell/dali-rp2/issues
ERROR: Unsupported transaction type: spend (skipping): {'aclass': 'currency', 'amount': '-64.2800', 'asset': 'ZUSD', 'balance': '0.0003', 'fee': '0.9600', 'refid': 'editedout', 'time': '1702988682.6361973', 'type': 'spend', 'subtype': ''}. Please open an issue at https://github.com/eprbell/dali-rp2/issues
ERROR: Fatal exception occurred:
Traceback (most recent call last):
  File "C:\Users\usernamehere\AppData\Local\Programs\Python\Python39\lib\site-packages\dali\dali_main.py", line 168, in _dali_main_internal
    result_list = pool.map(_input_plugin_helper, input_plugin_args_list)
  File "C:\Users\usernamehere\AppData\Local\Programs\Python\Python39\lib\multiprocessing\pool.py", line 364, in map
    return self._map_async(func, iterable, mapstar, chunksize).get()
  File "C:\Users\usernamehere\AppData\Local\Programs\Python\Python39\lib\multiprocessing\pool.py", line 771, in get
    raise self._value
  File "C:\Users\usernamehere\AppData\Local\Programs\Python\Python39\lib\multiprocessing\pool.py", line 125, in worker
    result = (True, func(*args, **kwds))
  File "C:\Users\usernamehere\AppData\Local\Programs\Python\Python39\lib\multiprocessing\pool.py", line 48, in mapstar
    return list(map(*args))
  File "C:\Users\usernamehere\AppData\Local\Programs\Python\Python39\lib\site-packages\dali\dali_main.py", line 226, in _input_plugin_helper
    plugin_transactions = input_plugin.load(country)
  File "C:\Users\usernamehere\AppData\Local\Programs\Python\Python39\lib\site-packages\dali\plugin\input\rest\kraken.py", line 211, in load
    return self._compute_transaction_set(trade_history, ledger)
  File "C:\Users\usernamehere\AppData\Local\Programs\Python\Python39\lib\site-packages\dali\plugin\input\rest\kraken.py", line 357, in _compute_transaction_set
    InTransaction(
  File "C:\Users\usernamehere\AppData\Local\Programs\Python\Python39\lib\site-packages\dali\in_transaction.py", line 82, in __init__
    raise RP2RuntimeError(
rp2.rp2_error.RP2RuntimeError: Internal error: both 'crypto_fee' and 'fiat_fee' are defined, instead of only one: their values are 0 and 0.0000 respectively
INFO: Log file: ./log/rp2_2024_08_27_11_54_54_863266.log
INFO: Generated output directory: oututfile
INFO: Done

The receive/spend is simply a manual conversion / trade inside of Kraken; me selling accidentally gained USD (I was a moron and traded BTCUSD instead of BTCEUR) back to EUR. This btw is also a taxable event (same logic for FX and crypto - profit or loss is relevant within 365 days according to FIFO) and I don't know whether rp2 accounts for it. I mean it already does not recognize it as is, but I meant like if it could I do not know if thats already coded in.

As for the runtime error: Since I am using the Kraken API, its clearly not me doing the "setting two fees at once" thing wrong. I saw there was something vaguely like this in https://github.com/eprbell/dali-rp2/discussions/89 but that seems to be a manual CSV import.

Either the Kraken API Plugin did not account for this or rp2 is being too pedantic as it says in the other issue or what, but other than the error log, it did not even provide me a minimal output file AT ALL, which means I still after all of today's efforts have nothing to feed to rp2.

I do not understand why there is not simply an offline Kraken csv import supported, as almost every other portfolio tracker uses the full ledger CSV export from Kraken as well and it already was brought up in https://github.com/eprbell/dali-rp2/discussions/122 over a year ago.

I can spend another day just trying to "hack in" a custom configuration into the input mapper, but if everything still just ends up crashing I will simply end up past the tax filing deadline with no functionality.

So, to maybe ask the very most important question of all: I am only even going to rp2, because my other tool did not account for margin trading fees being paid in crypto fees, which leads to a potential "profit on conversion" risk . It is humanly impossible to figure out whether those conversions, thanks to FIFO and a lot of transactions, may or not have incurred profits versus the ususal 365 day holding period window.

Does rp2 even look up and do crypto conversions that occur as fees for Kraken? I ask because they are tagged / reported completely differently in margin trading as opposed to actual normal spot crypto sales and its a frickin' nightmare. Same with trades that end up creating nonpromary FX conversions (here: creating a USD balance, which would be in tax view a purchase of a foreign FX, USD, which is then later sold at a possible profit if conversion rates say so, within 365 days).

Sorry to likely create the worst issue report in human history, but I'm the depressed kind of person and the thought of looking at a criminal law penalty for a basically not reliably manually solvable issue is nervewracking - and paying a tax accountant a thousand bucks just to be really really sure I didn't make a hidden 50 EUR profit in the total fee conversions of 2023 would be insane.

eprbell commented 2 weeks ago

CC: @ndopencode, who worked on the Kraken plugin. If you have deadline coming up soon, I suggest you hire a professional or try with another tool: it's unlikely that this bug in the DaLI Kraken plugin will be fixed in a few days, given that DaLI is an open-source, volunteer-driven effort. The reason there is no Kraken CSV plugin is that nobody worked on it yet.

githubuserthatsright commented 2 weeks ago

it's unlikely that this bug in the DaLI Kraken plugin will be fixed in a few days, given that DaLI is an open-source, volunteer-driven effort.

Yea I know. And setting aside my own misery, I wanted to give you big props for getting something like this rolling and visible in the community in the first place. Documentation and versatility and ease of use all still have potential left, but it sure is something at least to have an open source effort and not just all those "minimum 12 months of sub for a one time tax report" ripoff crypto "accounting" sites that take zero responsibility for getting paid nutty sums.

Thank you for your time and effort. I am currently seeing what I can do to manually churn through the core data and at which point I hit a road block. So far estimates of being "off" with manual labour put me well below even a single billable hour for a real tax office employee, and the sheer mountain of manual checkup one has to do is nuts. Today was 5 hours to figure out 17 bucks profit from forced crypto sales for fees and negative outcome margin trades.

I'll see how it goes. Will watch the project closely as next year will surely come around soon enough..

eprbell commented 2 weeks ago

Thanks and good luck!