Method CreateCandlestickSubscriptionsAsync
- Namespace
- WhalesSecret.TradeScriptLib.API.TradingV1
- Assembly
- WhalesSecret.TradeScriptLib.dll
CreateCandlestickSubscriptionsAsync(IReadOnlyList<SymbolPair>)
Sends a subscription request to receive candlestick updates from the exchange.
Task<ICandlestickSubscriptionSet> CreateCandlestickSubscriptionsAsync(IReadOnlyList<SymbolPair> symbolPairs)
Parameters
symbolPairs
IReadOnlyList<SymbolPair>Symbol pairs to subscribe.
Returns
- Task<ICandlestickSubscriptionSet>
Candlestick subscription set wrapping a collection of ICandlestickSubscriptions with convenience methods.
Remarks
Method can be called in parallel fashion but the symbol pairs of the parallel calls are subscribed one set at the time given internal locking mechanism.
To retrieve historical candles (i.e. before the current day), the script can use GetCandlesticksAsync(SymbolPair, CandleWidth, DateTime, DateTime, CancellationToken) and does not need any subscriptions. The subscriptions are not technically required even for today's data but in that case, extra requests may be sent to an exchange. To minimize the number of requests sent to an exchange, the script that relies on recent (today's) candlesticks should first create a candlestick subscription and then use either GetCandlesticksAsync(SymbolPair, CandleWidth, DateTime, DateTime, CancellationToken) or the subscription's methods to retrieve the candlestick data.
Exceptions
- AlreadyExistsException
Thrown if at least one of the given symbol pairs is already subscribed or its subscription is in progress.
- NotConnectedException
Thrown if the request could not be sent to the exchange.
- NotAvailableException
Thrown if the symbol pair is not supported on the exchange or if the used connection has not been created with MarketData support.
- ExchangeResponseTimeoutException
Thrown if the exchange does not respond in timely manner.
- InvalidExchangeResponseException
Thrown if the exchange responded with invalid response.
- ExchangeIsUnderMaintenanceException
Thrown if the exchange is in the maintenance mode and does not accept new requests.
- ApiRequestLimitReachedException
Thrown if the exchange rejected to create a new data subscription due to an API rate limit.
- InvalidRequestDataException
Thrown if the exchange rejected to accept a new data subscription because some value in the subscription request is malformed or otherwise invalid.
- 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.
- OperationFailedException
Thrown if the request failed for an unknown reason with an unknown outcome.
- MalfunctionException
Thrown if an internal unexpected error occurred.
- InvalidArgumentException
Thrown if
symbolPairs
isnull
, an empty collection, or contains a single symbol pair multiple times.
- See Also