Table of Contents

Method GetOrderBookAsync

Namespace
WhalesSecret.TradeScriptLib.API.TradingV1.MarketData
Assembly
WhalesSecret.TradeScriptLib.dll

GetOrderBookAsync()

Get the latest order book snapshot for this subscription or waits for the first order book snapshot to be received if none is available.

Task<OrderBook> GetOrderBookAsync()

Returns

Task<OrderBook>

Up-to-date order book.

Remarks

This method is useful, for example, if one wants to get an order book snapshot every N seconds.

The method is not suitable to give you all order book updates.

Exceptions

OperationCanceledException

Thrown if the operation was cancelled, including cancellation during the shutdown.

NotConnectedTimeoutException

Thrown if the connection strategy associated with this instance is BlockUntilReconnectedOrTimeout with non-infinite timeout value and this timeout expired while the connection to the exchange is interrupted. That is, this exception does not limit the request itself, it rather limits the period of time that allows the client to recover from the interruption of the connection to the exchange.

NotConnectedException

Thrown if the connection strategy is FailInstantlyIfNotConnected and the connection to the exchange is interrupted.

NotFoundException

Thrown if:

  • FailIfNotAvailable is used and no order book data are yet present to report an order book snapshot, or
  • the method is called after the order book subscription was disposed.

GetOrderBookAsync(CancellationToken)

Get the latest order book snapshot for this subscription or waits for the first order book snapshot to be received if none is available.

Task<OrderBook> GetOrderBookAsync(CancellationToken cancellationToken)

Parameters

cancellationToken CancellationToken

Cancellation token that allows the caller to cancel the operation.

Returns

Task<OrderBook>

Up-to-date order book.

Remarks

This method is useful, for example, if one wants to get an order book snapshot every N seconds.

The method is not suitable to give you all order book updates.

Exceptions

OperationCanceledException

Thrown if the operation was cancelled, including cancellation during the shutdown.

NotConnectedTimeoutException

Thrown if the connection strategy associated with this instance is BlockUntilReconnectedOrTimeout with non-infinite timeout value and this timeout expired while the connection to the exchange is interrupted. That is, this exception does not limit the request itself, it rather limits the period of time that allows the client to recover from the interruption of the connection to the exchange.

NotConnectedException

Thrown if the connection strategy is FailInstantlyIfNotConnected and the connection to the exchange is interrupted.

NotFoundException

Thrown if:

  • FailIfNotAvailable is used and no order book data are yet present to report an order book snapshot, or
  • the method is called after the order book subscription was disposed.

GetOrderBookAsync(OrderBookGetMode, CancellationToken)

Gets an up-to-date order book for the subscribed symbol pair that satisfies getMode requirement.

Task<OrderBook> GetOrderBookAsync(OrderBookGetMode getMode = OrderBookGetMode.WaitUntilNew, CancellationToken cancellationToken = default)

Parameters

getMode OrderBookGetMode

Sets the mode specifying which order book snapshot is returned and when.

cancellationToken CancellationToken

Cancellation token that allows the caller to cancel the operation.

Returns

Task<OrderBook>

Up-to-date order book.

Remarks

This method is useful, for example, if one wants to get an order book snapshot every N seconds.

The method is not suitable to give you all order book updates.

Exceptions

OperationCanceledException

Thrown if the operation was cancelled, including cancellation during the shutdown.

NotConnectedTimeoutException

Thrown if the connection strategy associated with this instance is BlockUntilReconnectedOrTimeout with non-infinite timeout value and this timeout expired while the connection to the exchange is interrupted. That is, this exception does not limit the request itself, it rather limits the period of time that allows the client to recover from the interruption of the connection to the exchange.

NotConnectedException

Thrown if the connection strategy is FailInstantlyIfNotConnected and the connection to the exchange is interrupted.

NotFoundException

Thrown if:

  • FailIfNotAvailable is used and no order book data are yet present to report an order book snapshot, or
  • the method is called after the order book subscription was disposed.