예제 #1
0
        /// <summary>
        /// Depth-Five: The latest 5 entries of the market depth data is snapshooted and pushed every 100 milliseconds.
        /// Depth-All: After subscription, 400 entries of market depth data of the order book will first be pushed. Subsequently every 100 milliseconds we will snapshot and push entries that have changed during this time.
        /// Depth-TickByTick: The 400 entries of market depth data of the order book that return for the first time after subscription will be pushed; subsequently as long as there's any change of market depth data of the order book, the changes will be pushed tick by tick. Subsequently as long as there's any change of market depth data of the order book, the changes will be pushed tick by tick.
        /// </summary>
        /// <param name="instrument">Trading pair symbol</param>
        /// <param name="depth">Order Book Depth</param>
        /// <param name="onData">The handler for updates</param>
        /// <returns></returns>
        public virtual async Task <CallResult <UpdateSubscription> > Options_SubscribeToOrderBook_Async(string instrument, OkexOrderBookDepth depth, Action <OkexOptionsOrderBook> onData)
        {
            var internalHandler = new Action <OkexOptionsOrderBookUpdate>(data =>
            {
                foreach (var d in data.Data)
                {
                    d.Symbol   = instrument.ToUpper(OkexGlobals.OkexCultureInfo);
                    d.DataType = depth == OkexOrderBookDepth.Depth5 ? OkexOrderBookDataType.DepthTop5 : data.DataType;
                    onData(d);
                }
            });

            var channel = "depth";

            if (depth == OkexOrderBookDepth.Depth5)
            {
                channel = "depth5";
            }
            else if (depth == OkexOrderBookDepth.Depth400)
            {
                channel = "depth";
            }
            else if (depth == OkexOrderBookDepth.TickByTick)
            {
                channel = "depth_l2_tbt";
            }
            var request = new OkexSocketRequest(OkexSocketOperation.Subscribe, $"option/{channel}:{instrument}");

            return(await Subscribe(request, null, false, internalHandler).ConfigureAwait(false));
        }
 /// <summary>
 /// Depth-Five: Back to the previous five entries of depth data,This data is snapshot data per 100 milliseconds.For every 100 milliseconds, we will snapshot and push 5 entries of market depth data of the current order book.
 /// Depth-All: After subscription, 400 entries of market depth data of the order book will first be pushed. Subsequently every 100 milliseconds we will snapshot and push entries that have changed during this time.
 /// Depth-TickByTick: The 400 entries of market depth data of the order book that return for the first time after subscription will be pushed; subsequently as long as there's any change of market depth data of the order book, the changes will be pushed tick by tick. Subsequently as long as there's any change of market depth data of the order book, the changes will be pushed tick by tick.
 /// </summary>
 /// <param name="symbol">Trading pair symbol</param>
 /// <param name="depth">Order Book Depth</param>
 /// <param name="onData">The handler for updates</param>
 /// <returns></returns>
 public virtual CallResult <UpdateSubscription> Spot_SubscribeToOrderBook(string symbol, OkexOrderBookDepth depth, Action <OkexSpotOrderBook> onData) => Spot_SubscribeToTrades_Async(symbol, depth, onData).Result;
예제 #3
0
 /// <summary>
 /// Depth-Five: The latest 5 entries of the market depth data is snapshooted and pushed every 100 milliseconds.
 /// Depth-All: After subscription, 400 entries of market depth data of the order book will first be pushed. Subsequently every 100 milliseconds we will snapshot and push entries that have changed during this time.
 /// Depth-TickByTick: The 400 entries of market depth data of the order book that return for the first time after subscription will be pushed; subsequently as long as there's any change of market depth data of the order book, the changes will be pushed tick by tick. Subsequently as long as there's any change of market depth data of the order book, the changes will be pushed tick by tick.
 /// </summary>
 /// <param name="instrument">Trading pair symbol</param>
 /// <param name="depth">Order Book Depth</param>
 /// <param name="onData">The handler for updates</param>
 /// <returns></returns>
 public virtual CallResult <UpdateSubscription> Options_SubscribeToOrderBook(string instrument, OkexOrderBookDepth depth, Action <OkexOptionsOrderBook> onData) => Options_SubscribeToOrderBook_Async(instrument, depth, onData).Result;
 /// <summary>
 /// Depth-Five: The latest 5 entries of the market depth data is snapshooted and pushed every 100 milliseconds.
 /// Depth-All: After subscription, 400 entries of market depth data of the order book will first be pushed. Subsequently every 100 milliseconds we will snapshot and push entries that have changed during this time.
 /// Depth-TickByTick: The 400 entries of market depth data of the order book that return for the first time after subscription will be pushed; subsequently as long as there's any change of market depth data of the order book, the changes will be pushed tick by tick. Subsequently as long as there's any change of market depth data of the order book, the changes will be pushed tick by tick.
 /// </summary>
 /// <param name="symbol">Trading pair symbol</param>
 /// <param name="depth">Order Book Depth</param>
 /// <param name="onData">The handler for updates</param>
 /// <returns></returns>
 public virtual CallResult <UpdateSubscription> Futures_SubscribeToOrderBook(string symbol, OkexOrderBookDepth depth, Action <OkexFuturesOrderBook> onData) => Futures_SubscribeToOrderBook_Async(symbol, depth, onData).Result;