bitsofwinter / cryptotaxsweden

Script for generating a tax report for cryptocurrency trading which can be sent to the Swedish tax authorities.
GNU General Public License v3.0
52 stars 24 forks source link

Support for proving average cost basis through SKV 2198? #23

Open aba9999123 opened 5 years ago

aba9999123 commented 5 years ago

Hi,

First of all, just want to say - impressive job! Thanks so much for providing this tool - easing the job for all the rest of us panicking when trying to declare crypto gains/losses... I have tried generating K4 for both 2017 & 2018 and it works good. Now I have K4 reports. But i am afraid of uploading them to SKV as I wouldn't be able to explain where the cost basis are coming from, i.e. prove the average cost basis of all trades in the K4 report. Am I missing something - Is there a way to do this? Or are there any plans in the future to add support for Hjälpblankett SKV 2198 - making it possible to easily prove the cost basis in a very clear way? By having that it would enable to double check that all calculations in the k4 report are correct.

Anyhow - many thanks for taking time building this tool... Cred to you!

ABEC7 commented 5 years ago

That information should be available in the input data from Cointracking, no? If your indata, i.e. the exported file from Cointracking, is in USD you'll find the conversion rates in the cryptotaxsweden package. Or are you asking about the same output data as Cointracking provides when doing the tax calculations in Cointracking? A log file showing every calculation that cryptotaxsweden might solve this?

yomutiny commented 5 years ago

aba is talking about if the tax authority decides to look closer at what you have declared and requires you to show how you arrived at your profit and loss figures. It would be great to be able to generate a file that described the calculations in detail to show the exact method for arriving at the figures on the generated K4s. I too would appreciate this ability.

aba9999123 commented 5 years ago

@adrihh The information regarding how the cost basis was calculated for the K4 report is not present on cointracking? The average cost basis is, as I understand, a byproduct of the algorithms employed in cryptotaxsweden scripts.

What I'm asking for is exactly what @yomutiny more cleary articulates "if the tax authority decides to look closer at what you have declared and requires you to show how you arrived at your profit and loss figures. It would be great to be able to generate a file that described the calculations in detail to show the exact method for arriving at the figures on the generated K4s.". Another benefit from such solution would be to enable more people to do Quality Assurance on the calculations. Logical errors or bugs would more easily be identified/discussed by the community :)

As Skatteverket this year will be specifically looking into cryptotrades, it is not unlikely they will ask for more details of the calculations - and if that is the case, i don't know if I could prove them.

ABEC7 commented 5 years ago

You're right, the calculations are not available, only the value of each transaction. You dont think providing the full spreadsheet showing each and every transaction, extracted from Cointracking, would be sufficent for SKV?

aba9999123 commented 5 years ago

I cannot anticipate what actions SKV will require, but the burden of proof is on the individual providing the declaration details. If SKV decides to look closer into the case, I doubt the average Joe in SKV will be able to do the calculations themselves - just as we are having trouble doing, instead they might ask you to prove your profit & loss figures together with the trade history, or they will determine your declaration incorrect w. accompanied penalties. Personally, I'm afraid to take the risk if I can't prove the calculations.

Buy maybe there are some people whom have previously dealt with SKV in regards to Cryptocurrencies that could shed some light into this matter? :)

bitsofwinter commented 5 years ago

Honest answer is that I haven't looked at this yet. However, I would assume that it wouldn't be too hard to output the data needed for this from the script, but I would have to have a look at the actual SKV form first.

This tool has been mainly something I've written to aid me with my own tax report and I am pretty confident I would be able to modify the code to output the information they would require in case they want to look closer but I don't know if I would prioritize writing that code before I had a good reason for it. It all depends on the amount of work involved of course.

If someone else wants to add this functionality then I can assist with explaining the code. (It's not that complicated for someone who knows how to program in Python).

yomutiny commented 5 years ago

I wrote a quick program independently in c# and can verify the results produced by bitsofwinter down to a few kronor but it does rely on the conclusion in this issue. My code isn't in a fit state to put up here yet but I might try and enable a report to explain the calculations in detail. Obviously it's best if it gets included in this repo but I don't speak python unfortunately. I'll try and clean up the code and add it as a repo in the hopefully near future.

Ninj201 commented 5 years ago

I will be reporting my crypto trades for the first time this year, got it all done and working finally! But now when I start to read around, I'm a little worried as well about not being able to provide any calculations if needed. I guess I will have to send it as is and hope they don't ask, if they do I guess I can try ask if they want the transaction history from cointracking, the (.csv), and explain the calculation has been done in this software and I have no clue how to provide it.

I hope something like this can be added or someone like Yomutiny can get something working even if it is just a quick fix.

Ninj201 commented 5 years ago

Today I got a mail from skatteverket, asking me to strengthen my avarage cost basis by 1: providing transaction history, 2: bank transaction history to show what I payed/received in sek when buying crypto. 3: show how I have calculated the avarage cost basis.

I will have to mail them and explain the situation, I sent them a simplified k4 as It had too much text in the non-simplified version, so maybe I can also send them a sru or pdf of that version too as it shows more individual numbers, but other than that I cannot prove the calculation as it was automated with this software, hopefully they understand the situation as there is simply too many transactions to calculate by hand 300+ or so.

I have made no actual money in crypto, only losses, so hopefully they don't care too much about it.

yomutiny commented 5 years ago

If you are willing to send me your trades.csv, I can send you the output from my report generator that tries to explain the cost basis calculations. It might be of use. It generates a file detailing the calculations of each buy and sell and then does a little summary at the end. The file could potentially be huge if you've done a lot of trades. I make the reservation that I only calculate for buys and sells, nothing else.

Here is an example: ----- Coin: AE ----- -- BEGIN BUY: Balance: 0, Buy amount: 134.82900000, Cost: 3198.14, Current Cost basis (AverageUnitCost): 0 UPDATE COST BASIS: ((AverageUnitCost * Balance) + cost) / (Balance + amount) = 23.719971222808149582063205987 NEW BALANCE: 134.82900000 -- END BUY

-- BEGIN BUY: Balance: 134.82900000, Buy amount: 25.17100000, Cost: 597.05, Current Cost basis (AverageUnitCost): 23.719971222808149582063205987 UPDATE COST BASIS: ((AverageUnitCost * Balance) + cost) / (Balance + amount) = 23.71993750000000000 NEW BALANCE: 160.00000000 -- END BUY

-- BEGIN SELL: Balance: 160.00000000, Sell amount: 106.63000000, Proceeds: 453.27, Current cost basis (AverageUnitCost): 23.71993750000000000 CALCULATE IF PROFIT OR LOSS: proceeds - (AverageUnitCost amount) = -2075.9869356250000000000000000 LOSS Add sale proceeds 453.27 to current total proceeds from losing trades (0) = 453.27 Add cost of sold currency (AverageUnitCost amount) (2529.2569356250000000000000000) to current total value of currency sold at a loss (0) = 2529.2569356250000000000000000 Add amount sold (106.63000000) to current total amount sold at a loss (0) = 106.63000000 -- END SELL

-- BEGIN SELL: Balance: 53.37000000, Sell amount: 46.67000000, Proceeds: 198.39, Current cost basis (AverageUnitCost): 23.71993750000000000 CALCULATE IF PROFIT OR LOSS: proceeds - (AverageUnitCost amount) = -908.6194831250000000000000000 LOSS Add sale proceeds 198.39 to current total proceeds from losing trades (453.27) = 651.66 Add cost of sold currency (AverageUnitCost amount) (1107.0094831250000000000000000) to current total value of currency sold at a loss (2529.2569356250000000000000000) = 3636.2664187500000000000000000 Add amount sold (46.67000000) to current total amount sold at a loss (106.63000000) = 153.30000000 -- END SELL

------ AE SUMMARY ------ ---- Winning Trades: ---- Amount of Coins: 0 Proceeds: 0 Cost: 0 Total Profit: 0 ---- Losing Trades: ---- Amount of Coins: 153.30000000 Proceeds: 652 Cost: 3637 Total Loss: -2984 Balance: 7 ---- || -----

Ninj201 commented 5 years ago

Thanks Yomutiny that would be super great! any explanation/information I can provide them the better! Don't worry if it become a long list, that's to be expected, atleast than they have it as additonal information.

You can send me a mail to: patrik_se@outlook.com

I will than send you the csv file, that way you don't have to give out your mail.

Im very glad for the help, thanks!

bitsofwinter commented 5 years ago

Any feedback you get from SKV about how this reporting should be done would be useful to post here so that I can look into adding this functionality to the script at some point.

yomutiny commented 5 years ago

Any feedback you get from SKV about how this reporting should be done would be useful to post here so that I can look into adding this functionality to the script at some point.

Here is the excerpt from the letter from SKV which talks about explaining the calculation of average cost basis.

report

Greveyaro commented 5 years ago

Wouldn't it be easier to just get cointracking.info to implement the correct swedish calculation method, employed by the script? Then they have a detailed report where every calculation is accounted for and separated fot each crypto.

I tried the ACB (adjusted cost base, Canada) method and got pretty similar numbers as the script. Has anyone tried it? Looking at the detailed report it looks similar to what I understand is the SKV method, but I'm no accountant.

//

yomutiny commented 5 years ago

@Instantexit if I get the time I will try and adjust my script to output mining and the other options covered by @bitsofwinter and generate you a file. Have you been asked for extra info by SKV?

yomutiny commented 5 years ago

@Greveyaro that would be great! Have you asked cointracking about it?

I asked them about 6 months ago and they had no plans to implement it.

By the way, the Canada method looks similar.

Greveyaro commented 5 years ago

thank you for your message. We will look into the requirements for Sweden. Do you have a tax deadline by which you need to file? Any English descriptions on how the gains need to be calculated?

Best regards, Christiane

Dr. Christiane Williams CoinTracking Support Supervisor

yomutiny commented 5 years ago

That was weird, I thought you, @Greveyaro were from Cointacking for a minute.

I got a similar reply: "thank you for your message and the link. I will forward it to the developer to have a look, whether it is possible to implement. Best regards, Christiane Dr. Christiane Williams CoinTracking Support Supervisor"

Have you sent any English descriptions or should I do it?

Greveyaro commented 5 years ago

I have not found an english description, SKV only has Swedish explanations online, so please do.

On Fri, Apr 26, 2019 at 22:08, yomutiny notifications@github.com wrote:

That was weird, I thought you, @Greveyaro were from Cointacking for a minute.

I got a similar reply: "thank you for your message and the link. I will forward it to the developer to have a look, whether it is possible to implement. Best regards, Christiane Dr. Christiane Williams CoinTracking Support Supervisor"

Have you sent any English descriptions or should I do it?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or mute the thread.

bitsofwinter commented 5 years ago

Hi, I've quickly hacked something together on a git branch called calculation_report which can output some information about the calculations as csv files, one csv file per coin at the moment. The csv files are output under the out folder.

I will need feedback on whether this kind of output is what you need and what might be missing. I can't spend a lot of time implementing this right now but if the script can at least output some kind of raw data you could potentially process it further in a spreadsheet editor to adapt to your needs.

Also, I haven't tested this functionality extensively so please verify that it looks reasonable.

bitsofwinter commented 5 years ago

You can also look at modifying how the csv output is generated. It isn't very complex and the code is located in the generate_calculation_report function in tax.py.

bitsofwinter commented 5 years ago

All events are listed as buys or sells (mining etc are converted to buys/sells) at the moment and if doing a crypto-crypto trade these will be listed as one buy event for one of the cryptos and a sell event for the other. Further work is needed to report the actual crypto-crypto trade as "one" event but perhaps the current output is still useful as a starting point?

Greveyaro commented 5 years ago

From CoinTracking support :

Hi

the developers are willing to try and implement the Swedish calculation, if possible. However we need a description which method is applied (best in English, if in Swedish we will try to translate) and how it differs from the ACB method that we already offer for Canada.

Best regards, Christiane

Dr. Christiane Williams CoinTracking Support Supervisor

On Fri, Apr 26, 2019 at 16:21, yomutiny notifications@github.com wrote:

@Greveyaro that would be great! Have you asked cointracking about it?

I asked them about 6 months ago and they had no plans to implement it.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or mute the thread.

bitsofwinter commented 5 years ago

From CoinTracking support : Hi the developers are willing to try and implement the Swedish calculation, if possible. However we need a description which method is applied (best in English, if in Swedish we will try to translate) and how it differs from the ACB method that we already offer for Canada. Best regards, Christiane Dr. Christiane Williams CoinTracking Support Supervisor On Fri, Apr 26, 2019 at 16:21, yomutiny @.***> wrote: @Greveyaro that would be great! Have you asked cointracking about it? I asked them about 6 months ago and they had no plans to implement it. — You are receiving this because you were mentioned. Reply to this email directly, [view it on GitHub](#23 (comment)), or mute the thread.

This is great news. Are they planning on making it output in a format which SKV will accept as well, i.e. K4 documents in PDF or SRU format?

bitsofwinter commented 5 years ago

The delimiter is tab as that makes it super easy to copy paste the data into a Google Sheet. You should be able to configure Excel to load it as well.

All the profits should be in the vinst column and the losses in the förlust column. There is one csv per coin type though, perhaps you had the losses in another coin? I could also make it output a combined csv with all the coins, just thought that would be a bit messier to process but now that I think about it that might be pretty useful.

I could probably solve the mining issue in the script but that would take more time. I don't know exactly how mining should be declared but perhaps you could export the mining transactions in a separate csv file from cointracking to get that in a separate report?

Sorry for not having more time to help here. Maybe there is someone else here who has the time to work with you to solve this issue.

bitsofwinter commented 5 years ago

I updated the branch and it now also outputs a combined report for all coins (fiat and crypto).

bitsofwinter commented 5 years ago

Any info on what would make the report more useful is of course good to post here. Someone else might pick this up and improve it or I might look into improving it when I have time.

yomutiny commented 5 years ago

Awesome you could add this @bitsofwinter @Instantexit I have quickly added a field for trade type on the type_field_for_calculation_report branch so you can see if it was mining or spend 'trade type' https://github.com/yomutiny/cryptotaxsweden/tree/type_field_for_calculation_report

bitsofwinter commented 5 years ago

Nice fix @yomutiny. I've added your fix to the calculation_report branch.

bitsofwinter commented 5 years ago

Could you get a detailed breakdown of their calculations and compare to the results of the calculation_report branch?

ABEC7 commented 5 years ago

@yomutiny and @bitsofwinter

Any possibility for a short guide on how to use the report tool in the calculation_report branch?

bitsofwinter commented 5 years ago

@ABEC7 If you are already running the script using python directly then just switch to the branch and run it as usual. There are no released packages for windows/mac with this functionality yet.

bitsofwinter commented 5 years ago

@Instantexit I tried to import my trades on deklira as well but had so many problems that I didn't feel like pursuing it any further. Was mostly interested in validating my own calculations but not if it would take that much time to figure out how to get their system to work.

ABEC7 commented 5 years ago

@ABEC7 If you are already running the script using python directly then just switch to the branch and run it as usual. There are no released packages for windows/mac with this functionality yet.

Ah, great. So using the same input data i can simply run the branch with "python report.py 2018" and get a calculation report in sru/pdf?

bitsofwinter commented 5 years ago

Ah, great. So using the same input data i can simply run the branch with "python report.py 2018" and get a calculation report in sru/pdf?

Exactly like that except that the calculation report is just a csv file with some info on cost basis, price, total amounts of each coin, profit, loss, etc for each trade.

bitsofwinter commented 5 years ago

The calculation report can definitely be improved, it is just a quick hack on my side and just exports the values used by the internals of the tax calculation at each step. It could be enough data to prove things to SKV but it might need some prettification and massaging to be more easily understood. If someone can say specifically what information they think SKV need and in which format it will help with implementing it. At the moment the main issue is that the SKV tax auditing process seems to be a black box, i.e. I don't know what SKV really wants so that they will trust that the calculations are correct. Somehow we just have to wait for the first case of someone having to prove their calculations to get this feedback or someone has to ask SKV specifically about this and I guess you will have to work a bit to find a SKV employee who actually knows what information they will require in practice when they want to audit the tax report of someone.

The data in the calculation report should be enough to fill in a SKV 2198 form though but if that is enough to make SKV happy I don't know. It looked like the SKV 2198 form is just a helper form you can use yourself when calculating average cost basis, profit and loss manually.

Sorry for not being super helpful on this topic right now. But I'm not a tax attorney or accountant and don't really know how auditing processes work.

bitsofwinter commented 5 years ago

@Greveyaro Have you heard anything from cointracking about their implementation of the swedish tax rules?

Ninj201 commented 5 years ago

I Should probably have reported this earlier but I just wanted to say that the calculation report you made Bitsofwinter, seemed to have been enough for SKV, thanks! I unfortunately didn't get any info on what their opinion was of it, but it was accepted so it should be good enough.

The only thing I had to do was to convert the files to txt. files since their site didn't support that many file types.

But it seems like its enough to prove the math behind it, so if anyone else get a letter from SKV after sending in your crypto report to prove your calculations, show your transaction history, were and when you acquired and such it should be doable!

Anyway thanks a lot for providing these tools Bitsofwinter! and also thanks to Yomutiny for helping!