Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Kraken Margin Trading #120

Open
wants to merge 14 commits into
base: main
Choose a base branch
from
Open

Conversation

Griffsano
Copy link
Contributor

Initial working draft for Kraken margin trading. Similar to @scientes' work in #64.

Addresses #52, #97

@provinzio
Copy link
Owner

Please add your sources of information, at least in the PR. So I can double check :)

@Griffsano
Copy link
Contributor Author

Hey @provinzio, I updated the README according to our discussion in #64:
https://github.com/Griffsano/CoinTaxman/blob/margin_kraken/README.md#future---margin-trading
This should contain all relevant information regarding my conception for margin taxation (if it's not clear, I'll try to clarify it directly in the README).

I'm still not sure if the tax calculation is 100% correct (especially since spot and margin wallets are combined for Kraken). However, at least the results for my exports make sense (profit/loss similar to Kraken dashboard).

@provinzio
Copy link
Owner

Hey @Griffsano, thank you for your clarification. As I am currently reworking the evaluation and export, this PR is blocked by the branch rework-evaluation-export, but feel free to further work on the integration of Kraken Margin Trading.

@Griffsano Griffsano marked this pull request as ready for review May 26, 2022 15:21
@Griffsano
Copy link
Contributor Author

Griffsano commented May 26, 2022

Hey @provinzio, I merged the current main branch into this PR and made the necessary changes so that margin evaluation for Kraken works again. Could you please review? I updated the README with my conception of margin taxation.

There's one thing that's weird though: Whenever I have margin entries in my CSV exports, the "Unrealisierte Einkünfte" part in the .xlsx just contains zeros, I haven't figured out yet why.

Btw, thanks for the detailed report feature, looks awesome :D

@provinzio provinzio mentioned this pull request Jun 4, 2022
Copy link
Owner

@provinzio provinzio left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @Griffsano,

good first start to implement the Margin Trading into CoinTaxman. I appreciate your effort in writing the README.md. It gives a clear overview on the topic.

One question: at which time will the fees of a MarginTrade be recognized as tax loss? Already at the time of the paying (like currently implemented) or after the margin trade is closed?

I am a bit confused by the statement from winheller, which says, that your "Werbungskosten" can not be used to reduce your tax.

der Abzug der tatsächlichen Werbungskosten ist ausgeschlossen

After this they say, that costs will become tax relevant on sell (which indicates that we have to adjust the code and match margin fees to margin-closes.

In folgenden Fällen sind die Kosten auch ab 2009 weiterhin abzugsfähig:

  • Veräußerungskosten und Kosten in Zusammenhang mit Termingeschäften werden bei der Veräußerungsgewinnermittlung nach § 20 Abs. 4 EStG berücksichtigt.

@@ -744,6 +764,10 @@ class StakingInterestReportEntry(InterestReportEntry):
event_type = "Staking Einkünfte"


class MarginReportEntry(InterestReportEntry):
event_type = "Margin-Trading"
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does the labels from InterestReportEntry make sense here? All your MarginGain/MarginLoss.change are positive. So that the report should state that you always receive ("Erhalten am") coins. I believe that you have to update the labels. Also "Wert in EUR" doesn't make sense as we do not evaluate the value of the "bought" coins.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed to TaxReportEntry.
"Wert in EUR" makes sense for gains/losses/fees received/paid in crypto coins. However, since it's the same as "Gewinn/Verlust in EUR", I removed the column.
Not sure about the date (as it could be gain or loss), what do you think about "Erhalten oder ausgegeben am"?

src/taxman.py Outdated Show resolved Hide resolved
src/taxman.py Outdated Show resolved Hide resolved
src/taxman.py Outdated Show resolved Hide resolved
src/taxman.py Outdated Show resolved Hide resolved
"""Losses from margin trading.
This is already a taxable value, no buy/sell calculation required."""

pass
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When possible, it might be nicer to have classes MarginStart, MarginFee, MarginClose instead.
MarginClose should have a fees: list[MarginFee] variable. The fees must be linked to the MarginClose for tax evaluation.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The thing is that Kraken logs do not provide starts and closes of margins. Instead, the already computed gains or losses are logged. Therefore, we don't have to / can't compute the gains/losses ourselves.
An example can be found here: #97

@provinzio provinzio marked this pull request as draft June 4, 2022 08:47
@provinzio
Copy link
Owner

I did some small formatting and merged main into the branch, to keep it up to date. :)

@Griffsano
Copy link
Contributor Author

Hi @provinzio,

I finally had some time to continue working on this issue.

I am a bit confused by the statement from winheller, which says, that your "Werbungskosten" can not be used to reduce your tax.

Yes, I was confused by the same sentence. Maybe they meant this?

Das bedeutet, dass auch Aufwendungen im Zusammenhang mit der Einnahmeerzielung nicht mehr gegen Nachweis als Werbungskosten berücksichtigt werden. Sie sind mit dem Sparerpauschbetrag von 801 Euro bei Alleinstehenden und 1.602 Euro bei Verheirateten abgegolten.
(Source: https://www.steuergo.de/ro/texte/2021/597/kapitalvermoegen)

One question: at which time will the fees of a MarginTrade be recognized as tax loss? Already at the time of the paying (like currently implemented) or after the margin trade is closed?

Good point. The problem is, that in case of Kraken, we probably can't link opening and closing actions, or the fees associated with the margin trade, as they have different reference IDs (see #97).

src/price_data.py Outdated Show resolved Hide resolved
@Griffsano Griffsano marked this pull request as ready for review December 17, 2022 11:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants