Binance Connector JS
    Preparing search index...

    TradeApi - interface TradeApi

    interface TradeApiInterface {
        accountTradeList(
            requestParameters: DerivativesTradingUsdsFuturesRestAPI.AccountTradeListRequest,
        ): Promise<
            RestApiResponse<
                DerivativesTradingUsdsFuturesRestAPI.AccountTradeListResponse,
            >,
        >;
        allOrders(
            requestParameters: DerivativesTradingUsdsFuturesRestAPI.AllOrdersRequest,
        ): Promise<
            RestApiResponse<DerivativesTradingUsdsFuturesRestAPI.AllOrdersResponse>,
        >;
        autoCancelAllOpenOrders(
            requestParameters: DerivativesTradingUsdsFuturesRestAPI.AutoCancelAllOpenOrdersRequest,
        ): Promise<
            RestApiResponse<
                DerivativesTradingUsdsFuturesRestAPI.AutoCancelAllOpenOrdersResponse,
            >,
        >;
        cancelAlgoOrder(
            requestParameters?: DerivativesTradingUsdsFuturesRestAPI.CancelAlgoOrderRequest,
        ): Promise<
            RestApiResponse<
                DerivativesTradingUsdsFuturesRestAPI.CancelAlgoOrderResponse,
            >,
        >;
        cancelAllAlgoOpenOrders(
            requestParameters: CancelAllAlgoOpenOrdersRequest,
        ): Promise<RestApiResponse<CancelAllAlgoOpenOrdersResponse>>;
        cancelAllOpenOrders(
            requestParameters: DerivativesTradingUsdsFuturesRestAPI.CancelAllOpenOrdersRequest,
        ): Promise<
            RestApiResponse<
                DerivativesTradingUsdsFuturesRestAPI.CancelAllOpenOrdersResponse,
            >,
        >;
        cancelMultipleOrders(
            requestParameters: DerivativesTradingUsdsFuturesRestAPI.CancelMultipleOrdersRequest,
        ): Promise<
            RestApiResponse<
                DerivativesTradingUsdsFuturesRestAPI.CancelMultipleOrdersResponse,
            >,
        >;
        cancelOrder(
            requestParameters: DerivativesTradingUsdsFuturesRestAPI.CancelOrderRequest,
        ): Promise<
            RestApiResponse<
                DerivativesTradingUsdsFuturesRestAPI.CancelOrderResponse,
            >,
        >;
        changeInitialLeverage(
            requestParameters: DerivativesTradingUsdsFuturesRestAPI.ChangeInitialLeverageRequest,
        ): Promise<
            RestApiResponse<
                DerivativesTradingUsdsFuturesRestAPI.ChangeInitialLeverageResponse,
            >,
        >;
        changeMarginType(
            requestParameters: DerivativesTradingUsdsFuturesRestAPI.ChangeMarginTypeRequest,
        ): Promise<
            RestApiResponse<
                DerivativesTradingUsdsFuturesRestAPI.ChangeMarginTypeResponse,
            >,
        >;
        changeMultiAssetsMode(
            requestParameters: ChangeMultiAssetsModeRequest,
        ): Promise<RestApiResponse<ChangeMultiAssetsModeResponse>>;
        changePositionMode(
            requestParameters: DerivativesTradingUsdsFuturesRestAPI.ChangePositionModeRequest,
        ): Promise<
            RestApiResponse<
                DerivativesTradingUsdsFuturesRestAPI.ChangePositionModeResponse,
            >,
        >;
        currentAllAlgoOpenOrders(
            requestParameters?: CurrentAllAlgoOpenOrdersRequest,
        ): Promise<RestApiResponse<CurrentAllAlgoOpenOrdersResponse>>;
        currentAllOpenOrders(
            requestParameters?: DerivativesTradingUsdsFuturesRestAPI.CurrentAllOpenOrdersRequest,
        ): Promise<
            RestApiResponse<
                DerivativesTradingUsdsFuturesRestAPI.CurrentAllOpenOrdersResponse,
            >,
        >;
        futuresTradfiPerpsContract(
            requestParameters?: DerivativesTradingUsdsFuturesRestAPI.FuturesTradfiPerpsContractRequest,
        ): Promise<
            RestApiResponse<
                DerivativesTradingUsdsFuturesRestAPI.FuturesTradfiPerpsContractResponse,
            >,
        >;
        getOrderModifyHistory(
            requestParameters: DerivativesTradingUsdsFuturesRestAPI.GetOrderModifyHistoryRequest,
        ): Promise<
            RestApiResponse<
                DerivativesTradingUsdsFuturesRestAPI.GetOrderModifyHistoryResponse,
            >,
        >;
        getPositionMarginChangeHistory(
            requestParameters: DerivativesTradingUsdsFuturesRestAPI.GetPositionMarginChangeHistoryRequest,
        ): Promise<
            RestApiResponse<
                DerivativesTradingUsdsFuturesRestAPI.GetPositionMarginChangeHistoryResponse,
            >,
        >;
        modifyIsolatedPositionMargin(
            requestParameters: DerivativesTradingUsdsFuturesRestAPI.ModifyIsolatedPositionMarginRequest,
        ): Promise<
            RestApiResponse<
                DerivativesTradingUsdsFuturesRestAPI.ModifyIsolatedPositionMarginResponse,
            >,
        >;
        modifyMultipleOrders(
            requestParameters: DerivativesTradingUsdsFuturesRestAPI.ModifyMultipleOrdersRequest,
        ): Promise<
            RestApiResponse<
                DerivativesTradingUsdsFuturesRestAPI.ModifyMultipleOrdersResponse,
            >,
        >;
        modifyOrder(
            requestParameters: DerivativesTradingUsdsFuturesRestAPI.ModifyOrderRequest,
        ): Promise<
            RestApiResponse<
                DerivativesTradingUsdsFuturesRestAPI.ModifyOrderResponse,
            >,
        >;
        newAlgoOrder(
            requestParameters: DerivativesTradingUsdsFuturesRestAPI.NewAlgoOrderRequest,
        ): Promise<
            RestApiResponse<
                DerivativesTradingUsdsFuturesRestAPI.NewAlgoOrderResponse,
            >,
        >;
        newOrder(
            requestParameters: DerivativesTradingUsdsFuturesRestAPI.NewOrderRequest,
        ): Promise<
            RestApiResponse<DerivativesTradingUsdsFuturesRestAPI.NewOrderResponse>,
        >;
        placeMultipleOrders(
            requestParameters: DerivativesTradingUsdsFuturesRestAPI.PlaceMultipleOrdersRequest,
        ): Promise<
            RestApiResponse<
                DerivativesTradingUsdsFuturesRestAPI.PlaceMultipleOrdersResponse,
            >,
        >;
        positionAdlQuantileEstimation(
            requestParameters?: DerivativesTradingUsdsFuturesRestAPI.PositionAdlQuantileEstimationRequest,
        ): Promise<
            RestApiResponse<
                DerivativesTradingUsdsFuturesRestAPI.PositionAdlQuantileEstimationResponse,
            >,
        >;
        positionInformationV2(
            requestParameters?: DerivativesTradingUsdsFuturesRestAPI.PositionInformationV2Request,
        ): Promise<
            RestApiResponse<
                DerivativesTradingUsdsFuturesRestAPI.PositionInformationV2Response,
            >,
        >;
        positionInformationV3(
            requestParameters?: PositionInformationV3Request,
        ): Promise<RestApiResponse<PositionInformationV3Response>>;
        queryAlgoOrder(
            requestParameters?: QueryAlgoOrderRequest,
        ): Promise<RestApiResponse<QueryAlgoOrderResponse>>;
        queryAllAlgoOrders(
            requestParameters: QueryAllAlgoOrdersRequest,
        ): Promise<RestApiResponse<QueryAllAlgoOrdersResponse>>;
        queryCurrentOpenOrder(
            requestParameters: DerivativesTradingUsdsFuturesRestAPI.QueryCurrentOpenOrderRequest,
        ): Promise<
            RestApiResponse<
                DerivativesTradingUsdsFuturesRestAPI.QueryCurrentOpenOrderResponse,
            >,
        >;
        queryOrder(
            requestParameters: DerivativesTradingUsdsFuturesRestAPI.QueryOrderRequest,
        ): Promise<
            RestApiResponse<
                DerivativesTradingUsdsFuturesRestAPI.QueryOrderResponse,
            >,
        >;
        testOrder(
            requestParameters: TestOrderRequest,
        ): Promise<RestApiResponse<TestOrderResponse>>;
        usersForceOrders(
            requestParameters?: DerivativesTradingUsdsFuturesRestAPI.UsersForceOrdersRequest,
        ): Promise<
            RestApiResponse<
                DerivativesTradingUsdsFuturesRestAPI.UsersForceOrdersResponse,
            >,
        >;
    }

    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, which is different from dapi modify order endpoint.
      • 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

      Parameters

      Returns Promise<
          RestApiResponse<
              DerivativesTradingUsdsFuturesRestAPI.ModifyOrderResponse,
          >,
      >

      TradeApiInterface

    • Send in a new algo (conditional) order. Use this endpoint to place TP/SL (Take Profit / Stop Loss) and trailing stop orders on USD-M Futures. Supported order types under algoType=CONDITIONAL are STOP_MARKET, TAKE_PROFIT_MARKET, STOP, TAKE_PROFIT, and TRAILING_STOP_MARKET.

      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:

      • Algo order with type STOP, parameter timeInForce can be sent (default GTC).
      • Algo order with type TAKE_PROFIT, parameter timeInForce can be sent ( default GTC).
      • 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")
      • TAKE_PROFIT, TAKE_PROFIT_MARKET:
      • BUY: latest price ("MARK_PRICE" or "CONTRACT_PRICE")
      • SELL: latest price ("MARK_PRICE" or "CONTRACT_PRICE") >= triggerPrice
      • TRAILING_STOP_MARKET:
      • BUY: the lowest price after order placed = the lowest price * (1 + callbackRate)
      • SELL: the highest price after order placed >= activatePrice, and the latest price
      • 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<
          RestApiResponse<
              DerivativesTradingUsdsFuturesRestAPI.NewAlgoOrderResponse,
          >,
      >

      TradeApiInterface

    • Check the status of an algo (conditional) order, such as TP/SL (Take Profit / Stop Loss) or trailing stop orders on USD-M Futures.

      These orders will not be found: order status is CANCELED or EXPIRED AND order has NO filled trade AND created time + 3 days < current time order create time + 90 days < current time

      Weight(IP): 1

      Security Type: USER_DATA

      Notes:

      • Either algoId or clientAlgoId must be sent.
      • algoId is self-increment for each specific symbol

      Parameters

      Returns Promise<RestApiResponse<QueryAlgoOrderResponse>>

      TradeApiInterface

    • Get all algo (conditional) orders — active, CANCELED, TRIGGERED, or FINISHED — including TP/SL (Take Profit / Stop Loss) and trailing stop orders on USD-M Futures.

      These orders will not be found: order status is CANCELED or EXPIRED AND order has NO filled trade AND created time + 3 days < current time order create time + 90 days < current time

      Weight(IP): 5

      Security Type: USER_DATA

      Notes:

      • If algoId is set, it will get orders >= that algoId. Otherwise most recent orders are returned.
      • The query time period must be less then 7 days( default as the recent 7 days).

      Parameters

      Returns Promise<RestApiResponse<QueryAllAlgoOrdersResponse>>

      TradeApiInterface

    • Testing order request, this order will not be submitted to matching engine

      Security Type: TRADE

      Notes: Additional mandatory parameters based on type:

      Type Additional mandatory parameters
      LIMIT timeInForce, quantity, price
      MARKET quantity
      STOP/TAKE_PROFIT quantity, price, stopPrice
      STOP_MARKET/TAKE_PROFIT_MARKET stopPrice
      TRAILING_STOP_MARKET callbackRate
      • Order with type STOP, parameter timeInForce can be sent ( default GTC).
      • Order with type TAKE_PROFIT, parameter timeInForce can be sent (default GTC).
      • Condition orders will be triggered when:
      • If parameterpriceProtectis sent as true:
      • when price reaches the stopPrice ,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") >= stopPrice
      • SELL: latest price ("MARK_PRICE" or "CONTRACT_PRICE")
      • TAKE_PROFIT, TAKE_PROFIT_MARKET:
      • BUY: latest price ("MARK_PRICE" or "CONTRACT_PRICE")
      • SELL: latest price ("MARK_PRICE" or "CONTRACT_PRICE") >= stopPrice
      • TRAILING_STOP_MARKET:
      • BUY: the lowest price after order placed ``= the lowest price * (1 + callbackRate)
      • SELL: the highest price after order placed >= activationPrice, and the latest price
      • 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: activationPrice should be smaller than latest price.
      • SELL: activationPrice should be larger than latest price.
      • If newOrderRespType is sent as RESULT :
      • MARKET order: the final FILLED result of the order will be return directly.
      • LIMIT order with special timeInForce: the final status result of the order(FILLED or EXPIRED) will be returned directly.
      • 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.
      • In extreme market conditions, timeInForce GTD order auto cancel time might be delayed comparing to goodTillDate

      Parameters

      Returns Promise<RestApiResponse<TestOrderResponse>>

      TradeApiInterface