Table of Contents

Method GetCandlesticksAsync

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

GetCandlesticksAsync(SymbolPair, CandleWidth, DateTime, DateTime, CancellationToken)

Sends a request to retrieve historical candlestick data.

Task<CandlestickData> GetCandlesticksAsync(SymbolPair symbolPair, CandleWidth candleWidth, DateTime startTime, DateTime endTime, CancellationToken cancellationToken)

Parameters

symbolPair SymbolPair

Symbol pair to get candlestick data for.

candleWidth CandleWidth

Width of candles to retrieve.

startTime DateTime

UTC timestamp of the start of the time frame for which to retrieve the candlestick data.

endTime DateTime

Exclusive UTC timestamp of the end of the time frame for which to retrieve the candlestick data. Every returned candlestick will start before this timestamp, but may end after this timestamp. It must be greater than startTime.

cancellationToken CancellationToken

Cancellation token that allows the caller to cancel the operation.

Returns

Task<CandlestickData>

Candlestick data for the requested time frame. Only closed candlesticks are returned.

Remarks

For discussion on minimization of the number of requests sent to an exchange, see the remarks section of CreateCandlestickSubscriptionsAsync(IReadOnlyList<SymbolPair>).

Exceptions

InvalidArgumentException

Thrown if:

  • candleWidth is set to Other, or
  • startTime is after endTime, or
  • the set does not contain a subscription for the given symbol pair.
NotAvailableException

Thrown if the symbol pair is not supported on the exchange or if the used connection has not been created with MarketData support.

MalfunctionException

Thrown if an internal unexpected error occurred.

NotConnectedException

Thrown if the request could not be sent.

OperationCanceledException

Thrown if the operation was cancelled including cancellation due to shutdown or object disposal.

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.

InvalidArgumentException

Thrown if candleWidth is set to Other, or if startTime is after endTime.

NotAvailableException

Thrown if the symbol pair is not supported on the exchange or if the used connection has not been created with MarketData support.

MalfunctionException

Thrown if an internal unexpected error occurred.

NotConnectedException

Thrown if the request could not be sent.

OperationCanceledException

Thrown if the operation was cancelled including cancellation due to shutdown or object disposal.

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.

OperationFailedException

Thrown if the request failed for an unknown reason with an unknown outcome.

See Also