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

Add proper types for futuresExchangeInfo #649

Open
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

valentiniljaz
Copy link
Contributor

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

@@ -1,6 +1,8 @@
node_modules/
.nyc_output/
dist/

.vscode/
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(all changes of gitignore)

@@ -1036,7 +1036,7 @@ declare module 'binance-api-node' {

export interface SymbolMinNotionalFilter {
filterType: SymbolFilterType.MIN_NOTIONAL
notional: string
minNotional: string
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bennycode what's the consensus on this one? Pretty sure there's a lot of back and forth on this which might be due to the fact the field changes depending on which endpoint is hit

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yepp, that's why there is now a FuturesSymbolMinNotionalFilter and a SymbolMinNotionalFilter. 👍

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh actually you were part of the original convo, my bad

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Gotcha thank you for the confirmation

@bennycode
Copy link
Contributor

bennycode commented Oct 14, 2023

@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))?

@valentiniljaz
Copy link
Contributor Author

valentiniljaz commented Oct 16, 2023

@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?

@bennycode
Copy link
Contributor

@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"
}

@valentiniljaz
Copy link
Contributor Author

valentiniljaz commented Oct 16, 2023

@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
Copy link
Contributor Author

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

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

Successfully merging this pull request may close these issues.

3 participants