/// <summary> /// Retrieve the candlestick data /// </summary> /// <param name="symbol">Trading pair symbol</param> /// <param name="period">The period of a single candlestick</param> /// <param name="onData">The handler for updates</param> /// <returns></returns> public async Task <CallResult <UpdateSubscription> > Spot_SubscribeToCandlesticks_Async(string symbol, OkexSpotPeriod period, Action <OkexSpotCandle> onData) { symbol = symbol.ValidateSymbol(); var internalHandler = new Action <OkexSocketUpdateResponse <IEnumerable <OkexSpotCandleContainer> > >(data => { foreach (var d in data.Data) { d.Timestamp = DateTime.UtcNow; d.Candle.Symbol = symbol.ToUpper(OkexGlobals.OkexCultureInfo); onData(d.Candle); } }); var request = new OkexSocketRequest(OkexSocketOperation.Subscribe, $"spot/candle{JsonConvert.SerializeObject(period, new SpotPeriodConverter(false))}s:{symbol}"); return(await Subscribe(request, null, false, internalHandler).ConfigureAwait(false)); }
/// <summary> /// Retrieve the candlestick charts of option contracts. Does not require login,data is pushed every 500ms. /// Retrieve the candlestick data /// </summary> /// <param name="instrument">Trading contract symbol</param> /// <param name="period">The period of a single candlestick</param> /// <param name="onData">The handler for updates</param> /// <returns></returns> public virtual CallResult <UpdateSubscription> Options_SubscribeToCandlesticks(string instrument, OkexSpotPeriod period, Action <OkexOptionsCandle> onData) => Options_SubscribeToCandlesticks_Async(instrument, period, onData).Result;
/// <summary> /// Retrieve the candlestick data /// </summary> /// <param name="symbol">Trading pair symbol</param> /// <param name="period">The period of a single candlestick</param> /// <param name="onData">The handler for updates</param> /// <returns></returns> public CallResult <UpdateSubscription> Spot_SubscribeToCandlesticks(string symbol, OkexSpotPeriod period, Action <OkexSpotCandle> onData) => Spot_SubscribeToCandlesticks_Async(symbol, period, onData).Result;
/// <summary> /// Retrieve the candlestick data /// </summary> /// <param name="symbol">Trading pair symbol</param> /// <param name="period">The period of a single candlestick</param> /// <param name="onData">The handler for updates</param> /// <returns></returns> public virtual CallResult <UpdateSubscription> Futures_SubscribeToCandlesticks(string symbol, OkexSpotPeriod period, Action <OkexFuturesCandle> onData) => Futures_SubscribeToCandlesticks_Async(symbol, period, onData).Result;