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

2 transactions with same uniqueID in binance #164

Open
Larision opened this issue May 18, 2023 · 7 comments
Open

2 transactions with same uniqueID in binance #164

Larision opened this issue May 18, 2023 · 7 comments

Comments

@Larision
Copy link
Contributor

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

i suppose is a binance issue, @macanudo527 maybe if same uniqueID and different asset pair, check orderid? as you mencioned in #157 ??

@macanudo527
Copy link
Collaborator

This is truly strange, the id and orderId should be the same.

@macanudo527
Copy link
Collaborator

These are just regular trades?

@eprbell
Copy link
Owner

eprbell commented May 19, 2023

This is truly strange, the id and orderId should be the same.

Can you elaborate on this? Curious why they should be the same. In any case since these are not transactions that need the resolver (they are a sale and a fee related to conversions), how about the following ideas:

  • use f"{id}_{orderId}" as the unique id for the sale,
  • use f"{id}_{orderId}/fee" as the unique id for the fee (to defensively distinguish it from the sale, if needed).

Would this work?

@macanudo527
Copy link
Collaborator

macanudo527 commented May 20, 2023

Can you elaborate on this? Curious why they should be the same.

Sorry, I misread the CCXT codebase. They shouldn't be the same actually.

I think this change will disambiguate the ids and it make it safe for all the other exchanges as well.

@Larision
Copy link
Contributor Author

            # Users can use other crypto assets to pay for trades
            if fee_asset != out_asset and RP2Decimal(transaction_fee) > ZERO:
                out_transaction_list.append(
                    OutTransaction(
                        plugin=self.plugin_name(),
                        unique_id=f"{transaction[_ID]}/fee",

will work with this /fee addition in abstract_ccxt_input_plugin??

@macanudo527
Copy link
Collaborator

@Larision I think @eprbell 's suggestion should fix this issue if you want to implement that.

@Larision
Copy link
Contributor Author

@macanudo527 @eprbell Srry but not easy to me. Where shoud i fix it?

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

No branches or pull requests

3 participants