/// <summary> /// Retrieve order book data. /// Use books for 400 depth levels, book5 for 5 depth levels, books50-l2-tbt tick-by-tick 50 depth levels, and books-l2-tbt for tick-by-tick 400 depth levels. /// books: 400 depth levels will be pushed in the initial full snapshot. Incremental data will be pushed every 100 ms when there is change in order book. /// books5: 5 depth levels will be pushed every time.Data will be pushed every 200 ms when there is change in order book. /// books50-l2-tbt: 50 depth levels will be pushed in the initial full snapshot. Incremental data will be pushed tick by tick, i.e.whenever there is change in order book. /// books-l2-tbt: 400 depth levels will be pushed in the initial full snapshot. Incremental data will be pushed tick by tick, i.e.whenever there is change in order book. /// </summary> /// <param name="intrumentId">Instrument ID</param> /// <param name="orderBookType">Order Book Type</param> /// <param name="onData">On Data Handler</param> /// <returns></returns> public virtual async Task <CallResult <UpdateSubscription> > SubscribeToOrderBook_Async(string intrumentId, OkexOrderBookType orderBookType, Action <OkexOrderBook> onData) { var internalHandler = new Action <DataEvent <OkexOrderBookUpdate> >(data => { foreach (var d in data.Data.Data) { d.Instrument = intrumentId; d.Action = data.Data.Action; onData(d); } }); var jc = JsonConvert.SerializeObject(orderBookType, new OrderBookTypeConverter(false)); var request = new OkexSocketRequest(OkexSocketOperation.Subscribe, jc, intrumentId); return(await SubscribeAsync(request, null, false, internalHandler).ConfigureAwait(false)); }
/// <summary> /// Retrieve order book data. /// Use books for 400 depth levels, book5 for 5 depth levels, books50-l2-tbt tick-by-tick 50 depth levels, and books-l2-tbt for tick-by-tick 400 depth levels. /// books: 400 depth levels will be pushed in the initial full snapshot. Incremental data will be pushed every 100 ms when there is change in order book. /// books5: 5 depth levels will be pushed every time.Data will be pushed every 200 ms when there is change in order book. /// books50-l2-tbt: 50 depth levels will be pushed in the initial full snapshot. Incremental data will be pushed tick by tick, i.e.whenever there is change in order book. /// books-l2-tbt: 400 depth levels will be pushed in the initial full snapshot. Incremental data will be pushed tick by tick, i.e.whenever there is change in order book. /// </summary> /// <param name="intrumentId">Instrument ID</param> /// <param name="orderBookType">Order Book Type</param> /// <param name="onData">On Data Handler</param> /// <returns></returns> public virtual CallResult <UpdateSubscription> SubscribeToOrderBook(string intrumentId, OkexOrderBookType orderBookType, Action <OkexOrderBook> onData) => SubscribeToOrderBook_Async(intrumentId, orderBookType, onData).Result;