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

MEXC: No fee info in watchMyTrades #22318

Closed
mjwvb opened this issue Apr 28, 2024 · 1 comment · Fixed by #22320
Closed

MEXC: No fee info in watchMyTrades #22318

mjwvb opened this issue Apr 28, 2024 · 1 comment · Fixed by #22320
Assignees
Labels

Comments

@mjwvb
Copy link

mjwvb commented Apr 28, 2024

Operating System

MacOS

Programming Languages

JavaScript

CCXT Version

4.2.93

Description

When watching trades using watchMyTrades() the "fee" property is always undefined and thus not yet implemented. Nowadays the fee currency and cost are also sent with the websocket data as "N" (currency) and "n" (cost).
See: https://mexcdevelop.github.io/apidocs/spot_v3_en/#spot-account-deals

Would be nice to have them implemented as well.

Code

My workaround for now:

if (exchange.id === "mexc") {
  const parseWsTradeOriginal = exchange.parseWsTrade;
  exchange.parseWsTrade = function (trade, market) {
    const result = parseWsTradeOriginal.call(this, trade, market);

    if (result.fee === undefined) {
      const feeCurrency = this.safeString(trade, "N");
      const feeCost = this.safeNumber(trade, "n");

      if (feeCurrency !== undefined && feeCost !== undefined) {
        result.fee = {
          currency: feeCurrency,
          cost: feeCost,
        };
      }
    }

    return result;
  };
}

Example trade returned by watchMyTrades:

{
  "info": {
    "p": "141.0135",
    "v": "0.1",
    "a": "14.10135",
    "S": 1,
    "T": 1714305394276,
    "t": "8840627c72fb465a908794d8c4239f6f",
    "c": "SCS-A-95AdsRKSuyapDgRgkRAvH",
    "i": "C02__413235063167901696122",
    "m": 1,
    "st": 0,
    "n": "0.01410135",
    "N": "USDC"
  },
  "id": "8840627c72fb465a908794d8c4239f6f",
  "order": "C02__413235063167901696122",
  "timestamp": 1714305394276,
  "datetime": "2024-04-28T11:56:34.276Z",
  "symbol": "SOL/USDC",
  "type": undefined,
  "side": "buy",
  "takerOrMaker": "maker",
  "price": 141.0135,
  "amount": 0.1,
  "cost": 14.10135,
  "fee": undefined,
  "fees": []
}
@carlosmiei carlosmiei self-assigned this Apr 28, 2024
@carlosmiei carlosmiei added the bug label Apr 28, 2024
@carlosmiei
Copy link
Collaborator

Hello @mjwvb,
thanks for reporting it, we will take a look

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants