/// <see cref="ICobinhoodClient.GetCandles(string, string, Timeframe, DateTime?, DateTime?)"/> public async Task <CandlesInfo> GetCandles(string quoteSymbol, string baseSymbol, Timeframe timeframe, DateTime?startTime = null, DateTime?endTime = null) { if (string.IsNullOrWhiteSpace(quoteSymbol)) { throw new ArgumentException("QuoteSymbol cannot be empty. ", "quoteSymbol"); } if (string.IsNullOrWhiteSpace(baseSymbol)) { throw new ArgumentException("BaseSymbol cannot be empty. ", "baseSymbol"); } var parameters = $"timeframe={timeframe.GetDescription()}" + (startTime.HasValue ? $"&start_time={startTime.Value.GetUnixTimeStamp()}" : "") + (endTime.HasValue ? $"&end_time={endTime.Value.GetUnixTimeStamp()}" : ""); var tradingPair = (quoteSymbol + "-" + baseSymbol).ToUpper(); var finalEndpoint = EndPoints.GetCandles.Replace("<trading_pair_id>", tradingPair); var result = await _apiClient.CallAsync <CandlesInfo>(ApiMethod.GET, finalEndpoint, parameters); return(result); }
/// <see cref="ICobinhoodClient.ListenCandleEndpoint(string, string, Timeframe, ApiClientAbstract.MessageHandler{CandleResponse})"/> public void ListenCandleEndpoint(string quoteSymbol, string baseSymbol, Timeframe timeframe, ApiClientAbstract.MessageHandler <CandleResponse> messageHandler) { if (string.IsNullOrWhiteSpace(quoteSymbol)) { throw new ArgumentException("QuoteSymbol cannot be empty. ", "quoteSymbol"); } if (string.IsNullOrWhiteSpace(baseSymbol)) { throw new ArgumentException("BaseSymbol cannot be empty. ", "baseSymbol"); } var tradingPair = (quoteSymbol + "-" + baseSymbol).ToUpper(); var requestData = new WebSocketRequest() { Action = "subscribe", Type = "candle", TradingPairId = tradingPair, Timeframe = timeframe.GetDescription() }; _apiClient.SuscribeToWebSocket(messageHandler, requestData); }