Method GetCandlesticksAsync
- Namespace
- WhalesSecret.TradeScriptLib.API.TradingV1.MarketData
- Assembly
- WhalesSecret.TradeScriptLib.dll
GetCandlesticksAsync(CandleWidth, DateTime, DateTime, CancellationToken)
Sends a request to retrieve historical candlestick data.
Task<CandlestickData> GetCandlesticksAsync(CandleWidth candleWidth, DateTime startTime, DateTime endTime, CancellationToken cancellationToken)
Parameters
candleWidth
CandleWidthWidth of candles to retrieve.
startTime
DateTimeUTC timestamp of the start of the time frame for which to retrieve the candlestick data.
endTime
DateTimeExclusive 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
CancellationTokenCancellation 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 ifstartTime
is afterendTime
.- 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