Binance Connector JS
    Preparing search index...

    TradeApi - interface

    TradeApi

    interface TradeApiInterface {
        cancelAlgoOrder(
            requestParameters?: DerivativesTradingUsdsFuturesWebsocketAPI.CancelAlgoOrderRequest,
        ): Promise<
            WebsocketApiResponse<
                DerivativesTradingUsdsFuturesWebsocketAPI.CancelAlgoOrderResponse,
            >,
        >;
        cancelOrder(
            requestParameters: DerivativesTradingUsdsFuturesWebsocketAPI.CancelOrderRequest,
        ): Promise<
            WebsocketApiResponse<
                DerivativesTradingUsdsFuturesWebsocketAPI.CancelOrderResponse,
            >,
        >;
        modifyOrder(
            requestParameters: DerivativesTradingUsdsFuturesWebsocketAPI.ModifyOrderRequest,
        ): Promise<
            WebsocketApiResponse<
                DerivativesTradingUsdsFuturesWebsocketAPI.ModifyOrderResponse,
            >,
        >;
        newAlgoOrder(
            requestParameters: DerivativesTradingUsdsFuturesWebsocketAPI.NewAlgoOrderRequest,
        ): Promise<
            WebsocketApiResponse<
                DerivativesTradingUsdsFuturesWebsocketAPI.NewAlgoOrderResponse,
            >,
        >;
        newOrder(
            requestParameters: DerivativesTradingUsdsFuturesWebsocketAPI.NewOrderRequest,
        ): Promise<
            WebsocketApiResponse<
                DerivativesTradingUsdsFuturesWebsocketAPI.NewOrderResponse,
            >,
        >;
        positionInformation(
            requestParameters?: DerivativesTradingUsdsFuturesWebsocketAPI.PositionInformationRequest,
        ): Promise<
            WebsocketApiResponse<
                DerivativesTradingUsdsFuturesWebsocketAPI.PositionInformationResponse,
            >,
        >;
        positionInformationV2(
            requestParameters?: DerivativesTradingUsdsFuturesWebsocketAPI.PositionInformationV2Request,
        ): Promise<
            WebsocketApiResponse<
                DerivativesTradingUsdsFuturesWebsocketAPI.PositionInformationV2Response,
            >,
        >;
        queryOrder(
            requestParameters: DerivativesTradingUsdsFuturesWebsocketAPI.QueryOrderRequest,
        ): Promise<
            WebsocketApiResponse<
                DerivativesTradingUsdsFuturesWebsocketAPI.QueryOrderResponse,
            >,
        >;
    }

    Implemented by

    Index

    Methods

    • Order modify function, currently only LIMIT order modification is supported, modified orders will be reordered in the match queue

      Weight: 1 on 10s order rate limit(X-MBX-ORDER-COUNT-10S); 1 on 1min order rate limit(X-MBX-ORDER-COUNT-1M); 0 on IP rate limit(x-mbx-used-weight-1m)

      Security Type: TRADE

      Notes:

      • Either orderId or origClientOrderId must be sent, and the orderId will prevail if both are sent.

      • Both quantity and price must be sent. (After CM migration, the dapi modify order endpoint follows the same rule.)

      • When the new quantity or price doesn't satisfy PRICE_FILTER / PERCENT_FILTER / LOT_SIZE, amendment will be rejected and the order will stay as it is.

      • However the order will be cancelled by the amendment in the following situations:

      • when the order is in partially filled status and the new quantity <= executedQty

      • When the order is GTX and the new price will cause it to be executed immediately

      • One order can only be modfied for less than 10000 times

      • reduceOnly behavior:

      • false or omitted: behave as today — min_notional is enforced on the modified order.

      • true and the original order's reduceOnly attribute is also true (consistent): the min_notional check is skipped on the modified order, matching placement semantics.

      • true but the original order's reduceOnly attribute is false (inconsistent): the modify request is rejected with error code -5047, "The original order is not a reduce-only order".

      • reduceOnly is used purely for validation — passing true does not change the original order's reduceOnly attribute; that flag remains whatever it was set to at placement time.

      Parameters

      Returns Promise<
          WebsocketApiResponse<
              DerivativesTradingUsdsFuturesWebsocketAPI.ModifyOrderResponse,
          >,
      >

      TradeApiInterface

    • Send in a new algo order.

      Weight(IP): 0

      Security Type: TRADE

      Notes:

      • Condition orders will be triggered when:
      • If parameterpriceProtectis sent as true:

      • when price reaches the triggerPrice ,the difference rate between "MARK_PRICE" and "CONTRACT_PRICE" cannot be larger than the "triggerProtect" of the symbol

      • "triggerProtect" of a symbol can be got from GET /fapi/v1/exchangeInfo

      • STOP, STOP_MARKET:

      • BUY: latest price ("MARK_PRICE" or "CONTRACT_PRICE") >= triggerPrice

      • SELL: latest price ("MARK_PRICE" or "CONTRACT_PRICE") <= triggerPrice

      • TAKE_PROFIT, TAKE_PROFIT_MARKET:

      • BUY: latest price ("MARK_PRICE" or "CONTRACT_PRICE") <= triggerPrice

      • SELL: latest price ("MARK_PRICE" or "CONTRACT_PRICE") >= triggerPrice

      • TRAILING_STOP_MARKET:

      • BUY: the lowest price after order placed <= activatePrice, and the latest price >= the lowest price * (1 + callbackRate)

      • SELL: the highest price after order placed >= activatePrice, and the latest price <= the highest price * (1 - callbackRate)

      • For TRAILING_STOP_MARKET, if you got such error code.

      {"code": -2021, "msg": "Order would immediately trigger."}

      means that the parameters you send do not meet the following requirements:

      • BUY: activatePrice should be smaller than latest price.

      • SELL: activatePrice should be larger than latest price.

      • STOP_MARKET, TAKE_PROFIT_MARKET with closePosition=true:

      • Follow the same rules for condition orders.

      • If triggered,close all current long position( if SELL) or current short position( if BUY).

      • Cannot be used with quantity paremeter

      • Cannot be used with reduceOnly parameter

      • In Hedge Mode,cannot be used with BUY orders in LONG position side. and cannot be used with SELL orders in SHORT position side

      • selfTradePreventionMode is only effective when timeInForce set to IOC or GTC or GTD.

      Parameters

      Returns Promise<
          WebsocketApiResponse<
              DerivativesTradingUsdsFuturesWebsocketAPI.NewAlgoOrderResponse,
          >,
      >

      TradeApiInterface