Repository: rotki/rotki

Issue:
No Sells in Tax Report when "crypto to crypto" is disabled
Hi. I just found Rotkehlchen and think it is awesome, thanks for the good work.

## Problem Definition
When testing the Tax Report with the Setting "Take into account crypto to crypto trades" DISABLED, the resulting Tax Report includes only Buys and no Sells. When i re-enable the above setting, it works fine again.
I tried to study the logfile, but failed to understand why all Sells are omitted. The logfile shows, that they are generally processed. 

I tested switching main currency from USD to EUR with the same results. 


### System Description

Exchange: Binance
Assetpair: LINK/USDT
OS: Windows
[rotkehlchen.log](https://github.com/rotki/rotki/files/5143825/rotkehlchen.log)





Discussion:
Hey David thanks for being a Rotki user and for your kind words!


Can you give some examples of trades that were there with the "crypto to crypto" trades setting on and were no longer there after it is off?

> Assetpair: LINK/USDT

Keep in mind that USDT is also a cryptocurrency. So it should not appear at all.

After some testing I see that (even though they are not taken into account in profit calculation since they are buys) the buy part of the split between crypto to crypto trades still appeared in the tax report. I will fix it.

For example if you exchanged 10 ETH for 1 BTC and 1 ETH was $100 at the time, it would still show you that you bought 1 BTC with $1000. I am gonna fix this.

Resolving patch:
diff --git a/rotkehlchen/accounting/events.py b/rotkehlchen/accounting/events.py
--- a/rotkehlchen/accounting/events.py
+++ b/rotkehlchen/accounting/events.py
@@ -311,6 +311,14 @@ def add_buy(
         - RemoteError if there is a problem reaching the price oracle server
         or with reading the response returned by the server
         """
+        skip_trade = (
+            not self.include_crypto2crypto and
+            not bought_asset.is_fiat() and
+            not paid_with_asset.is_fiat()
+        )
+        if skip_trade:
+            return
+
         paid_with_asset_rate = self.get_rate_in_profit_currency(paid_with_asset, timestamp)
         buy_rate = paid_with_asset_rate * trade_rate
 
@@ -461,6 +469,13 @@ def add_sell(
         - RemoteError if there is a problem reaching the price oracle server
         or with reading the response returned by the server
         """
+        skip_trade = (
+            not self.include_crypto2crypto and
+            not selling_asset.is_fiat() and
+            receiving_asset and not receiving_asset.is_fiat()
+        )
+        if skip_trade:
+            return
 
         if selling_asset not in self.events:
             self.events[selling_asset] = Events([], [])


Test patch:
diff --git a/rotkehlchen/tests/unit/test_accounting.py b/rotkehlchen/tests/unit/test_accounting.py
--- a/rotkehlchen/tests/unit/test_accounting.py
+++ b/rotkehlchen/tests/unit/test_accounting.py
@@ -226,6 +226,10 @@ def test_buying_selling_btc_before_bchfork(accountant):
 }])
 def test_nocrypto2crypto(accountant):
     accounting_history_process(accountant, 1436979735, 1519693374, history5)
+    # Expected = 3 trades + the creation of ETC and BCH after fork times
+    msg = 'The crypto to crypto trades should not appear in the list at all'
+    assert len(accountant.csvexporter.all_events) == 5, msg
+
     assert accountant.general_trade_pl.is_close("264693.43364282")
     assert accountant.taxable_trade_pl.is_close("0")