/// <summary>
 /// To create a Reactive Extension for the event of the best offer decrease on a specific value.
 /// </summary>
 /// <param name="marketDepth">The order book to be traced for the event of the best offer decrease on a specific value.</param>
 /// <param name="price">The shift value.</param>
 /// <returns>Reactive Extension.</returns>
 public static IObservable <MarketDepth> RxWhenBestAskPriceLess(this MarketDepth marketDepth, Unit price)
 {
     if (marketDepth == null)
     {
         throw new ArgumentNullException(nameof(marketDepth));
     }
     return(marketDepth.RxQuotesChanged()
            .Where(_ => marketDepth.BestAsk != null && marketDepth.BestAsk.Price < price));
 }
        /// <summary>
        /// To create a Reactive Extension for the event of order book spread size decrease on a specific value.
        /// </summary>
        /// <param name="marketDepth">The order book to be traced for the spread change event.</param>
        /// <param name="price">The shift value.</param>
        /// <returns>Reactive Extension.</returns>
        public static IObservable <MarketDepth> RxWhenSpreadLess(this MarketDepth marketDepth, Unit price)
        {
            if (marketDepth == null)
            {
                throw new ArgumentNullException(nameof(marketDepth));
            }
            var pair       = marketDepth.BestPair;
            var firstPrice = pair?.SpreadPrice ?? 0;

            return(marketDepth.RxQuotesChanged().Where(_ =>
                                                       marketDepth.BestPair != null && marketDepth.BestPair.SpreadPrice < (firstPrice - price)));
        }