eprbell / dali-rp2

DaLI (Data Loader Interface) is a data loader and input generator for RP2 (https://pypi.org/project/rp2), the privacy-focused, free, open-source cryptocurrency tax calculator: DaLI removes the need to manually prepare RP2 input files. Just like RP2, DaLI is also free, open-source and it prioritizes user privacy.
https://pypi.org/project/dali-rp2/
Apache License 2.0
63 stars 42 forks source link

2 same uniqueID transactions in binance´s dust trade. #157

Closed Larision closed 1 year ago

Larision commented 1 year ago

I was checking historical transactions and i can confirm was a dust trade. Checking all dust trades only BTC, USDT, BUSD and EUR have pair assets like BNB/XXX, all others are XXX/BNB and getting first asset to append to id number like id=1111111111BTC. Here i traded usdt and btc dust in bnb so both got BNB append making them have the same uniqueID making dali failing resolving them.. Srry if im a bit lost but im quite newbie with python.

Traceback (most recent call last):
  File "/home/kali/renta/dali-rp2/src/dali/dali_main.py", line 168, in _dali_main_internal
    resolved_transactions: List[AbstractTransaction] = resolve_transactions(transactions, dali_configuration, args.read_spot_price_from_web)
                                                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/kali/renta/dali-rp2/src/dali/transaction_resolver.py", line 289, in resolve_transactions
    raise RP2RuntimeError(
rp2.rp2_error.RP2RuntimeError: Internal error: attempting to resolve two transactions that aren't Intra/Intra, In/Out or Out/In:
InTransaction:
  plugin=Binance.com_REST
  unique_id=XXX760BNB
  raw_data={"id": "XXX760BNB", "timestamp": 1648564129000, "datetime": "2022-03-29T14:28:49.000Z", "symbol": "BNB/USDT", "order": "XXX760", "type": null, "takerOrMaker": null, "side": "buy", "amount": 8.313e-05, "price": 439.07133405509444, "cost": 0.0365, "fee": {"currency": "BNB", "cost": 1.66e-06}, "info": {"fromAsset": "USDT", "amount": "0.0365", "transferedAmount": "0.00008313", "serviceChargeAmount": "0.00000166", "operateTime": "1648564129000", "transId": "XXX760", "isDustTrade": true}}
  timestamp=2022-03-29 14:28:49+0000
  asset=BNB
  exchange=Binance.com
  holder=fran
  transaction_type=Buy
  spot_price=__unknown
  crypto_in=0.00008313
  fiat_fee=None
  fiat_in_no_fee=None
  fiat_in_with_fee=None
  notes=Buy side of conversion from 0.0365 USDT -> 8.313e-05 BNB(USDT out-transaction unique id: XXX760BNB
InTransaction:
  plugin=Binance.com_REST
  unique_id=XXX760BNB
  raw_data={"id": "XXX760BNB", "timestamp": 1648564129000, "datetime": "2022-03-29T14:28:49.000Z", "symbol": "BNB/BTC", "order": "XXX760", "type": null, "takerOrMaker": null, "side": "buy", "amount": 0.09148394, "price": 0.00918500012133277, "cost": 0.00084028, "fee": {"currency": "BNB", "cost": 0.00182967}, "info": {"fromAsset": "BTC", "amount": "0.00084028", "transferedAmount": "0.09148394", "serviceChargeAmount": "0.00182967", "operateTime": "1648564129000", "transId": "XXX760", "isDustTrade": true}}
  timestamp=2022-03-29 14:28:49+0000
  asset=BNB
  exchange=Binance.com
  holder=fran
  transaction_type=Buy
  spot_price=__unknown
  crypto_in=0.09148394
  fiat_fee=None
  fiat_in_no_fee=None
  fiat_in_with_fee=None
  notes=Buy side of conversion from 0.00084028 BTC -> 0.09148394 BNB(BTC out-transaction unique id: XXX760BNB
macanudo527 commented 1 year ago

This should be a simple fix. Can you clone the change and check if it works for you?

Larision commented 1 year ago

Binance.com/fran/DEBUG: Buy: {"id": "XXXXXXX760USDT", "timestamp": 1648564129000, "datetime": "2022-03-29T14:28:49.000Z", "symbol": "BNB/USDT", "order": "XXXXXXX760" Binance.com/fran/DEBUG: Buy: {"id": "XXXXXXXX760BTC", "timestamp": 1648564129000, "datetime": "2022-03-29T14:28:49.000Z", "symbol": "BNB/BTC", "order": "XXXXXXX760"

Fixed! Thank you.

But..... i got another 2 uniqueIDs error. seems not same issue, check it pls and tell me if i should open a new issue.

ERROR: Fatal exception occurred:
Traceback (most recent call last):
  File "/home/kali/renta/dali-rp2/src/dali/dali_main.py", line 181, in _dali_main_internal
    resolved_transactions: List[AbstractTransaction] = resolve_transactions(transactions, dali_configuration, args.read_spot_price_from_web)
                                                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/kali/renta/dali-rp2/src/dali/transaction_resolver.py", line 290, in resolve_transactions
    raise RP2RuntimeError(
rp2.rp2_error.RP2RuntimeError: Internal error: attempting to resolve two transactions that aren't Intra/Intra, In/Out or Out/In:
OutTransaction:
  plugin=Binance.com_REST
  unique_id=7484550
  raw_data={"info": {"symbol": "CAKEBNB", "id": "7484550", "orderId": "103694345", "orderListId": "-1", "price": "0.04646000", "qty": "1.47000000", "quoteQty": "0.06829620", "commission": "0.00005125", "commissionAsset": "BNB", "time": "1633735165866", "isBuyer": true, "isMaker": true, "isBestMatch": true}, "timestamp": 1633735165866, "datetime": "2021-10-08T23:19:25.866Z", "symbol": "CAKE/BNB", "id": "7484550", "order": "103694345", "type": null, "side": "buy", "takerOrMaker": "maker", "price": 0.04646, "amount": 1.47, "cost": 0.0682962, "fee": {"cost": 5.125e-05, "currency": "BNB"}, "fees": [{"cost": 5.125e-05, "currency": "BNB"}]}
  timestamp=2021-10-08 23:19:25+0000
  asset=BNB
  exchange=Binance.com
  holder=fran
  transaction_type=Sell
  spot_price=__unknown
  crypto_out_no_fee=0.0682962
  crypto_fee=0.00005125
  crypto_out_with_fee=0.06834745
  fiat_out_no_fee=None
  fiat_fee=None
  notes=Sell side of conversion from 0.0682962 BNB -> 1.47 CAKE(CAKE in-transaction unique id: 7484550
OutTransaction:
  plugin=Binance.com_REST
  unique_id=7484550
  raw_data={"info": {"symbol": "BETAUSDT", "id": "7484550", "orderId": "67825086", "orderListId": "-1", "price": "1.35567000", "qty": "19.00000000", "quoteQty": "25.75773000", "commission": "0.00003097", "commissionAsset": "BNB", "time": "1638451894562", "isBuyer": true, "isMaker": true, "isBestMatch": true}, "timestamp": 1638451894562, "datetime": "2021-12-02T13:31:34.562Z", "symbol": "BETA/USDT", "id": "7484550", "order": "67825086", "type": null, "side": "buy", "takerOrMaker": "maker", "price": 1.35567, "amount": 19.0, "cost": 25.75773, "fee": {"cost": 3.097e-05, "currency": "BNB"}, "fees": [{"cost": 3.097e-05, "currency": "BNB"}]}
  timestamp=2021-12-02 13:31:34+0000
  asset=BNB
  exchange=Binance.com
  holder=fran
  transaction_type=Fee
  spot_price=__unknown
  crypto_out_no_fee=0
  crypto_fee=0.00003097
  crypto_out_with_fee=0.00003097
  fiat_out_no_fee=None
  fiat_fee=None
  notes=Fee for conversion from 25.75773 USDT -> 19.0 BETA
macanudo527 commented 1 year ago

Yeah, this is not the same issue. These aren't dust trades. That seems quite baffling. We might be able to try using orderId for the unique id though.