Binance Connector JS
    Preparing search index...
    Index

    Constructors

    Methods

    • Disconnects from the WebSocket server. If there is no active connection, a warning is logged. Otherwise, all connections in the connection pool are closed gracefully, and a message is logged indicating that the connection has been disconnected.

      Returns Promise<void>

      A Promise that resolves when all connections have been closed.

      Error if the WebSocket client is not set.

    • Parameters

      • event: "open" | "message" | "error" | "close" | "ping" | "pong"
      • listener: (...args: any[]) => void

      Returns void

    • Parameters

      • event: "open" | "message" | "error" | "close" | "ping" | "pong"
      • listener: (...args: any[]) => void

      Returns void

    • Send in an one-cancels-the-other (OCO) pair, where activation of one order immediately cancels the other.

      An OCO has 2 orders called the above order and below order. One of the orders must be a LIMIT_MAKER/TAKE_PROFIT/TAKE_PROFIT_LIMIT order and the other must be STOP_LOSS or STOP_LOSS_LIMIT order. Price restrictions: If the OCO is on the SELL side: LIMIT_MAKER/TAKE_PROFIT_LIMIT price > Last Traded Price > STOP_LOSS/STOP_LOSS_LIMIT stopPrice TAKE_PROFIT stopPrice > Last Traded Price > STOP_LOSS/STOP_LOSS_LIMIT stopPrice If the OCO is on the BUY side: LIMIT_MAKER price < Last Traded Price < STOP_LOSS/STOP_LOSS_LIMIT stopPrice TAKE_PROFIT stopPrice > Last Traded Price > STOP_LOSS/STOP_LOSS_LIMIT stopPrice OCOs add 2 orders to the EXCHANGE_MAX_ORDERS filter and MAX_NUM_ORDERS filter. Weight: 1

      Unfilled Order Count: 2

      Parameters

      Returns Promise<WebsocketApiResponse<OrderListPlaceOcoResponse>>

      Promise<WebsocketApiResponse>

    • Places an OTO.

      An OTO (One-Triggers-the-Other) is an order list comprised of 2 orders. The first order is called the working order and must be LIMIT or LIMIT_MAKER. Initially, only the working order goes on the order book. The second order is called the pending order. It can be any order type except for MARKET orders using parameter quoteOrderQty. The pending order is only placed on the order book when the working order gets fully filled. If either the working order or the pending order is cancelled individually, the other order in the order list will also be canceled or expired. When the order list is placed, if the working order gets immediately fully filled, the placement response will show the working order as FILLED but the pending order will still appear as PENDING_NEW. You need to query the status of the pending order again to see its updated status. OTOs add 2 orders to the EXCHANGE_MAX_NUM_ORDERS filter and MAX_NUM_ORDERS filter. Weight: 1

      Unfilled Order Count: 2

      Parameters

      Returns Promise<WebsocketApiResponse<OrderListPlaceOtoResponse>>

      Promise<WebsocketApiResponse>

    • Place an OTOCO.

      An OTOCO (One-Triggers-One-Cancels-the-Other) is an order list comprised of 3 orders. The first order is called the working order and must be LIMIT or LIMIT_MAKER. Initially, only the working order goes on the order book. The behavior of the working order is the same as the OTO. OTOCO has 2 pending orders (pending above and pending below), forming an OCO pair. The pending orders are only placed on the order book when the working order gets fully filled. The rules of the pending above and pending below follow the same rules as the Order list OCO. OTOCOs add 3 orders to the EXCHANGE_MAX_NUM_ORDERS filter and MAX_NUM_ORDERS filter. Weight: 1

      Unfilled Order Count: 3

      Parameters

      Returns Promise<WebsocketApiResponse<OrderListPlaceOtocoResponse>>

      Promise<WebsocketApiResponse>

    • Sends a ping message to all connected Websocket servers in the pool. If no connections are ready, a warning is logged. For each active connection, the ping message is sent, and debug logs provide details.

      Returns void

      Error if a Websocket client is not set for a connection.

    • Sends an unsigned message to the WebSocket server

      Parameters

      • method: string

        The API method to call

      • payload: WebsocketSendMsgOptions = {}

        Message parameters and options

      Returns Promise<WebsocketApiResponse<unknown>>

      Promise that resolves with the server response

      Error if not connected

    • Sends a signed message to the WebSocket server with authentication

      Parameters

      • method: string

        The API method to call

      • payload: WebsocketSendMsgOptions = {}

        Message parameters and options

      Returns Promise<WebsocketApiResponse<unknown>>

      Promise that resolves with the server response

      Error if not connected