binance-api-node icon indicating copy to clipboard operation
binance-api-node copied to clipboard

Add proper types for futuresExchangeInfo

Open valentiniljaz opened this issue 2 years ago • 5 comments

Exchange info for Futures API uses different structure then the API for Spot. PR contains new types for ExchangeInfo that reflect the actual state of the API.

Source of truth for the change is:

  • https://binance-docs.github.io/apidocs/futures/en/#general-info
  • actual API response /fapi/v1/exchangeInfo

valentiniljaz avatar Oct 13 '23 08:10 valentiniljaz

@valentiniljaz thank you very much for making this PR 🙇‍♂️ Can you also change MIN_NOTIONAL = 'MIN_NOTIONAL' into MIN_NOTIONAL = 'NOTIONAL' as per our discovery (see https://github.com/ViewBlock/binance-api-node/pull/643#issuecomment-1752898623)?

bennycode avatar Oct 14 '23 16:10 bennycode

@valentiniljaz thank you very much for making this PR 🙇‍♂️ Can you also change MIN_NOTIONAL = 'MIN_NOTIONAL' into MIN_NOTIONAL = 'NOTIONAL' as per our discovery (see #643 (comment))?

Both filters: SPOT and FUTURES are still called "MIN_NOTIONAL". Only the property for Futures Symbol Filter is changed to "notional". That's why I would not change MIN_NOTIONAL => NOTIONAL. Or did you have something else in mind?

valentiniljaz avatar Oct 16 '23 13:10 valentiniljaz

@valentiniljaz If I call this.client.exchangeInfo() then I am getting returned products with a NOTIONAL filter type instead of a MIN_NOTIONAL type. Is it the same for you?

Example:

{
  "allowedSelfTradePreventionModes": [
    "NONE",
    "EXPIRE_TAKER",
    "EXPIRE_MAKER",
    "EXPIRE_BOTH"
  ],
  "allowTrailingStop": true,
  "baseAsset": "ETH",
  "baseAssetPrecision": 8,
  "baseCommissionPrecision": 8,
  "cancelReplaceAllowed": true,
  "defaultSelfTradePreventionMode": "NONE",
  "filters": [
    {
      "filterType": "PRICE_FILTER",
      "maxPrice": "922327.00000000",
      "minPrice": "0.00001000",
      "tickSize": "0.00001000"
    },
    {
      "filterType": "LOT_SIZE",
      "maxQty": "100000.00000000",
      "minQty": "0.00010000",
      "stepSize": "0.00010000"
    },
    {
      "filterType": "ICEBERG_PARTS",
      "limit": 10
    },
    {
      "filterType": "MARKET_LOT_SIZE",
      "maxQty": "2829.36596416",
      "minQty": "0.00000000",
      "stepSize": "0.00000000"
    },
    {
      "filterType": "TRAILING_DELTA",
      "maxTrailingAboveDelta": 2000,
      "maxTrailingBelowDelta": 2000,
      "minTrailingAboveDelta": 10,
      "minTrailingBelowDelta": 10
    },
    {
      "askMultiplierDown": "0.2",
      "askMultiplierUp": "5",
      "avgPriceMins": 5,
      "bidMultiplierDown": "0.2",
      "bidMultiplierUp": "5",
      "filterType": "PERCENT_PRICE_BY_SIDE"
    },
    {
      "applyMaxToMarket": false,
      "applyMinToMarket": true,
      "avgPriceMins": 5,
      "filterType": "NOTIONAL",
      "maxNotional": "9000000.00000000",
      "minNotional": "0.00010000"
    },
    {
      "filterType": "MAX_NUM_ORDERS",
      "maxNumOrders": 200
    },
    {
      "filterType": "MAX_NUM_ALGO_ORDERS",
      "maxNumAlgoOrders": 5
    }
  ],
  "icebergAllowed": true,
  "isMarginTradingAllowed": true,
  "isSpotTradingAllowed": true,
  "ocoAllowed": true,
  "orderTypes": [
    "LIMIT",
    "LIMIT_MAKER",
    "MARKET",
    "STOP_LOSS_LIMIT",
    "TAKE_PROFIT_LIMIT"
  ],
  "permissions": [
    "SPOT",
    "MARGIN",
    "TRD_GRP_004",
    "TRD_GRP_005",
    "TRD_GRP_006",
    "TRD_GRP_008",
    "TRD_GRP_009",
    "TRD_GRP_010",
    "TRD_GRP_011",
    "TRD_GRP_012",
    "TRD_GRP_013",
    "TRD_GRP_014",
    "TRD_GRP_015",
    "TRD_GRP_016",
    "TRD_GRP_017",
    "TRD_GRP_018",
    "TRD_GRP_019",
    "TRD_GRP_020",
    "TRD_GRP_021",
    "TRD_GRP_022",
    "TRD_GRP_023"
  ],
  "quoteAsset": "BTC",
  "quoteAssetPrecision": 8,
  "quoteCommissionPrecision": 8,
  "quoteOrderQtyMarketAllowed": true,
  "quotePrecision": 8,
  "status": "TRADING",
  "symbol": "ETHBTC"
}

bennycode avatar Oct 16 '23 13:10 bennycode

@bennycode Referring to the official docs https://binance-docs.github.io/apidocs/spot/en/#filters

There are two distinct filters: MIN_NOTIONAL and NOTIONAL. As of this moment "binance-api-node" does not provide types for filter NOTIONAL.

With additional investigation there appears to be more missing types for Symbol Filters: PERCENT_PRICE_BY_SIDE ICEBERG_PARTS MAX_NUM_ICEBERG_ORDERS MAX_POSITION TRAILING_DELTA and NOTIONAL

and for Exchange Filter: EXCHANGE_MAX_NUM_ICEBERG_ORDERS

I think it's better to prepare new PR just for these filters. What do you think?

valentiniljaz avatar Oct 16 '23 13:10 valentiniljaz

I have edited the PR and added the missing filters for Spot. I've also decoupled Futures filters from Spot.

Take a look and let me know if there's anything else that I can do

valentiniljaz avatar Oct 20 '23 14:10 valentiniljaz