kryptovero / kryptovero.github.io

MIT License
15 stars 8 forks source link

Epäluku EUR - NaN errors #12

Closed anssip closed 3 years ago

anssip commented 3 years ago

Thanks for creating this! Looks really promising.

I just tried with a CSV file i got from Coinbase Pro. For some reason the amount of tax (veron määrä) is always shown as zero or as "epäluku":

Screenshot 2021-08-17 at 8 42 20

Every row in the UI shows as either zero or as epäluku. Any idea what goes wrong?

The CSV file has 76 rows.

anssip commented 3 years ago
Screenshot 2021-08-17 at 14 45 55

It seems to be firing requests to Coinbase in an endless loop.

jehna commented 3 years ago

Hmm. Is it possible that you post the CSV rows that are causing the issue?

jehna commented 3 years ago

Ok, did some debugging. Here's where I'm at:

According to the vero.fi guidance:

The market value is the quoted value of the virtual currency in euros at the time of the transaction

This means that one of the sides of the transaction should either be EUR, or other one of the pairs should be converted to EUR to get the proper taxable value.

The transactions that seem to be causing issues are between USDC and BTC, so the csv report does not have an EUR value for either.

In this case the website makes a request to Coinbase to ask for a historical known EUR price one of the pairs, in this case USDC. The request being: https://api.pro.coinbase.com/products/USDC-EUR/candles?start=2020-12-22Z00:00:00.00&end=2020-12-23Z00:00:00.00&granularity=86400

However the response seems to be empty for some reason — perhaps there's no trading data for that day at all for USDC-EUR pair.

I'll try to fix this issue by trying the other pair too (in this case BTC) if the first one does not yield a result.

Also there seems to be an issue with trying to backfill multiple rows at the same time which causes exponential growth in requests. Fixing that too.

anssip commented 3 years ago

That transaction to USDC was actually a mistake I made. I was not able to sell USDC for EUR in Coinbase and looks like they are not offering the rate in their API either. Hopefully there is a way to make this work.

jehna commented 3 years ago

Ok, I think I have fixed both issues now.

Digging even deeper I found another issue: The pairs from your CSV are between two cryptos (and not euros at any point).

So the taxes are calculated based on the purchase price, there must be an initial EUR → crypto purchase so we can calculate gains based on the initial price. That seems to be missing from the CSV, so I assume one of these different scenarios:

  1. The Coinbase Fills CSV report did not contain all purchases before 2020-12-17 OR
  2. You have transferred the initial BTC to Coinbase before 2020-12-17 from some other exchange or wallet

You can resolve the 1. case by downloading a report that contains all transactions. The 2. case can be resolved by adding transactions leading the first Coinbase transaction manually from "Lisää uusi rivi..." button.

So the updated kryptovero.fi will now show an error when it finds that you're missing some transactions, like so:

Screenshot 2021-09-11 at 0 10 33
anssip commented 3 years ago

Looks better already but now it hangs up after the progress bar has progressed to the end. There is some error showing in the browser dev console. Here is the CSV file with my initial purchases added to the top.

jehna commented 3 years ago

I think you have edited the file using a spreadsheet program that changed comma separators (,) to semicolons (;). Also the timestamps have extra : in them. The CSV import is pretty naive at the moment to expect the CSV to be of the specific format that's exported by Coinbase.

A better way than manually editing the CSV file would be to use the form from kryptovero.fi ("Lisää uusi rivi..." button) to add the missing rows first, then import the CSV.

Meanwhile I'll add some extra checks to the CSV parsing to fix the issue and to give a proper error message if the CSV is in an invalid fomat 👍

anssip commented 3 years ago

Thanks! Indeed it was because i had mangled the CSV using the Numbers spreadsheet app. I did some find/replacing in the file and after that it was correctly handled in kryptoveri.fi.

The reason why i have so much rows in my CSV file is that i've used limit orders when buying and selling. These limit orders end up filled in multiple batches. These fills occur within 1-2 seconds so that the timestamps are almost equal. I wonder if I should combine these before feeding them to kryptovero, so that there are less transactions to be reported to the taxman. Any suggestions how this should be done? I guess each of the result rows shown in this app needs to be manually reported to the tax office.

Some kind of limit order combine feature might be a useful for kryptovero.fi :-)

jehna commented 3 years ago

I wonder if I should combine these before feeding them to kryptovero, so that there are less transactions to be reported to the taxman. Any suggestions how this should be done?

AFAIK all transactions should be separate, since their order and buy/sell price will affect the result. So no need to mangle.

I guess each of the result rows shown in this app needs to be manually reported to the tax office.

Good point. I can ask about this from Vero officials.

Will close this issue for now, but I'll open another one for the tax office report