provinzio / CoinTaxman

Calculate your taxes from cryptocurrency gains
GNU Affero General Public License v3.0
141 stars 31 forks source link

Add Margin support #64

Closed scientes closed 2 years ago

scientes commented 3 years ago

This needs to be tested further

closes #52

and i'm not sure if the gain/loss calculation is 100% correct because i'm not sure if we'd need to make seperate balance counters for margin and spot, but seperating those would be a major hassle

scientes commented 3 years ago

due it now seperating losses form gains this should be fine because now tist is seperated from spot gains

provinzio commented 3 years ago

I am not that familiar with the taxation of margin trades. But aren't these CFD? And CFD are taxed with "Kapitalertragssteuer" (25%)?

Plead add an description/explanation on margin trade to the readme and cite a trustworthy source.

Beside that. Regarding your implementation. Why shouldn't we combine Operation.Buy with Operation.MarginBuy and Operation.Sell with Operation.MarginSell? It looks unnecessary to me, to keep the if cases separated. And as far as I know "Sonstige Einkünfte aus Margin Trades" is no tax relevant category.

scientes commented 3 years ago

Accointing (a german online service for crypto taxation) lists profits and losses from margin trading in a seperate colummn. https://accointing.com/de/crypto-tax-guide/de/was-wird-fur-das-finanzamt-benotigt

yes "Kapitalertragssteuer" (25%) apply here but losses from margin trading are complicated, so to help that both wins and losses are displayed seperately:

Verluste aus Kapitalerträgen, wie z.B. durch Margin Trading mit Kryptowährungen auf BitMex, können auch berücksichtigt werden. Allerdings ist hier der Verlustabzug ab dem 01.01.2020 aufgrund der neuen „Derivatesteuer“ nur noch sehr begrenzt möglich. Eine vertikale Verrechnung von Verlusten aus der Anlage KAP und der Anlage SO war auch schon vor der Gesetzesänderung aufgrund der Verlustabzugsbeschränkungen ausgeschlossen.

https://winheller.com/blog/verluste-bitcoin-kryptowaehrungen-steuererklaerung/

now that you say that the duplication does not make sense anymore, because at first i tried to seperate margin and spot but that doesn't work that well, but on the export the MarginBuy and sell does help differntiate a little especially for debugging

scientes commented 3 years ago

Should We maybe name it Margin: Kapitalertragssteuer Gewinn Margin: Kapitalertragssteuer Verlust ?

provinzio commented 3 years ago

Should We maybe name it Margin: Kapitalertragssteuer Gewinn Margin: Kapitalertragssteuer Verlust ?

I'd prefer if the taxation type is the same as the name from the tax report. We might additional information behint it to separate them for debugging and visitations purposes.

E.g. just "Sonstige Einkünfte" or "Sonstige Einkünfte: Margin Verlust"

provinzio commented 3 years ago

Accointing (a german online service for crypto taxation) lists profits and losses from margin trading in a seperate colummn. https://accointing.com/de/crypto-tax-guide/de/was-wird-fur-das-finanzamt-benotigt

yes "Kapitalertragssteuer" (25%) apply here but losses from margin trading are complicated, so to help that both wins and losses are displayed seperately:

Verluste aus Kapitalerträgen, wie z.B. durch Margin Trading mit Kryptowährungen auf BitMex, können auch berücksichtigt werden. Allerdings ist hier der Verlustabzug ab dem 01.01.2020 aufgrund der neuen „Derivatesteuer“ nur noch sehr begrenzt möglich. Eine vertikale Verrechnung von Verlusten aus der Anlage KAP und der Anlage SO war auch schon vor der Gesetzesänderung aufgrund der Verlustabzugsbeschränkungen ausgeschlossen.

https://winheller.com/blog/verluste-bitcoin-kryptowaehrungen-steuererklaerung/

now that you say that the duplication does not make sense anymore, because at first i tried to seperate margin and spot but that doesn't work that well, but on the export the MarginBuy and sell does help differntiate a little especially for debugging

Please check other sources too. Crypto taxation is quite a gray area. Whinheller might be a good start, but they might be too "Crypto friendly".

Summarize your findings in the readme.

Griffsano commented 2 years ago

Hey,

Winheller published an article in October that goes more into detail: https://winheller.com/blog/besteuerung-future-margin-trading/

Parallel dazu lassen sich die Überlegungen auf das Margin Trading übertragen, weshalb Gewinne aus Margin Trades immer nur dann unter Kapitaleinkünfte (§ 20 EStG) fallen, wenn keine Lieferung einer Kryptowährung, sondern ein Differenzausgleich durchgeführt wird. Kommt es hingegen zu einer Lieferung einer Kryptowährung, liegt ein privates Veräußerungsgeschäft gemäß § 23 Abs. 1 Satz 1 Nr. 2 EStG vor.

For my understanding that means if a margin position is closed, the gain/loss falls under income from capital (25%), and if a position is settled (you buy/sell the coin at the end with the starting price), you can treat it just as spot trades.

Additionally, according to the article, fees for futures may not be subtracted from the capital income, as they fall under "Werbungskosten" and are already covered by the standard deduction / "Pauschbetrag", and losses may only be considered up to 20k with the new regulation. In my opinion, this applies then to closed positions.

provinzio commented 2 years ago

Additionally, according to the article, fees for futures may not be subtracted from the capital income, as they fall under "Werbungskosten" and are already covered by the standard deduction / "Pauschbetrag", and losses may only be considered up to 20k with the new regulation. In my opinion, this applies then to closed positions.

We should still calculate the "Werbungskosten" in case the user has more expenses than the "Pauschbetrag".

Please update the README file with the Winheller explanation and a small text summarizing the findings.

Griffsano commented 2 years ago

Hey @provinzio @scientes, I did more digging into the margin trading topic and summarized my findings in the readme: https://github.com/Griffsano/CoinTaxman/blob/margin/README.md#future---margin-trading

It would be great if you could review and let me know if you have the same understanding concerning margin taxation. One point where I'm still unsure is if merely giving the investor the option of closing or settling a position already leads to a "Termingeschäft", or if this is decided when the trade is settled/closed. In the first case, we may need to add this to the summary:

Steht dem Investor offen, eine Margin-Position auszugleichen ("settle") oder zu schließen ("close"), liegt ein Termingeschäft vor

provinzio commented 2 years ago

Definition of a future ("Termingeschäft") from wikipedia.

My understanding of margin trades were that these are always CFDs ("Differentkontakte") and therefore are taxed as "Kapiteleinkünfte". Regardless of whether it is a future ("Termingeschäft").

The differentiation between a future trade and a normal trade irritates me. As far as I thought, regarding the taxation, it doesn't matter when the trade is fullfilled.

Edit: Margin trades are basically trades with borrowed capital. On stock exchanges, i only ever know margin trades in the form of CFDs. I am not aware of any other forms (like "normale trading" where you receive the goods)

Feel free to prove me wrong :)

Griffsano commented 2 years ago

For the exchanges that I've seen, there's always a distinction between futures and margin trading. Compared to futures (with or without leverage), margin trading is spot trading with leverage. This is also what Kraken states:

Margin Trading allows you to make spot purchases and sales of cryptocurrencies, on the Kraken exchange, using funds that may exceed the balance of your account.

I'm pretty certain that (classical) "closed" margin trades (which lead to the payment of the difference in value) are per definition CFDs/"Differenzkontrakte" and therefore "Termingeschäfte" (similar to classical futures). This also agrees with multiple articles / forum threads.

For "settled" margin trades (that lead to the delivery of the asset for the base price, not the difference in value), it could be different (I also found this opinion in a couple of threads). Argument 1 against "Termingeschäft": Wikipedia states that there needs to be a pre-defined point in the future:

Termingeschäfte (auch Zeitgeschäfte; englisch forward oder englisch future) sind Finanzkontrakte, bei denen sich die Vertragsparteien verpflichten, die gegenseitige Erfüllung (Zahlung und Lieferung) über mehr als zwei Handelstage hinaus auf einen vereinbarten Zeitpunkt zu verschieben.

For the exchanges I know, margin trades can be settled at any non-predefined point in time (for Kraken up to a duration of max. 365 days). This argument would also apply to "closed" margin trades, if they wouldn't already be CFDs. Argument 2: Winheller differentiates between the delivery of the asset or the payment of the difference in value (they apply the same argumentation to futures btw):

Parallel dazu lassen sich die Überlegungen auf das Margin Trading übertragen, weshalb Gewinne aus Margin Trades immer nur dann unter Kapitaleinkünfte (§ 20 EStG) fallen, wenn keine Lieferung einer Kryptowährung, sondern ein Differenzausgleich durchgeführt wird. Kommt es hingegen zu einer Lieferung einer Kryptowährung, liegt ein privates Veräußerungsgeschäft gemäß § 23 Abs. 1 Satz 1 Nr. 2 EStG vor.

Argument 3: Accointing gives this example scenario:

Person A schließt mit Person B einen Vertrag, der A das Recht einräumt, in Zukunft einen BTC von B zu erhalten, der momentan 35.000 Euro wert ist. Wird der Kontrakt fällig und A erhält von B den BTC, liegt ein Fall von § 23 Abs. 1 Satz 1 Nr. 2 EStG vor. Das heißt für B, dass er die Veräußerung des BTC mit seinem persönlichen Einkommensteuersatz versteuern muss. Für A bedeutet das hingegen, dass eine Anschaffung vorliegt und damit die Jahresfrist gilt.

The example scenario on Accointing continues as follows:

Treffen A und B hingegen im oben geschilderten Fall die Vereinbarung, dass A am Ende des Vertrages die Wahl hat, ob er einen BTC bekommt oder alternativ den Gegenwert der Differenz zum aktuellen Kurs, dann liegt ein Termingeschäft gem. § 20 Abs. 2 Satz 1 Nr. 3 EStG vor.

At least for Kraken, the user has the option of "settling" (delivery of asset) or "closing" (difference in value) a margin trade, the decision is open until the end.

In summary, I arrive at this understanding:

provinzio commented 2 years ago

Ah ok. Sounds good. Thanks for the detailed explanation.

provinzio commented 2 years ago

Stale. Further worked on in #120