static IDisposable SubscribeOrderbookSource(RealtimeSourceFactory factory, BfProductCode productCode) { var source = factory.GetOrderBookSource(productCode); return(source.Select(orderBook => orderBook.GetSnapshot(15)).Subscribe(obs => { foreach (var ask in obs.Asks.Reverse()) { Console.WriteLine($"Ask: P:{ask.Price} S:{ask.Size}"); } Console.WriteLine($"Mid: P:{obs.MidPrice}"); foreach (var bid in obs.Bids.Reverse()) { Console.WriteLine($"Bid: P:{bid.Price} S:{bid.Size}"); } })); }
static void RealtimeOrderBookSample(RealtimeSourceFactory factory) { var left = Console.CursorLeft; var top = Console.CursorTop; factory.GetOrderBookSource(BfProductCode.FXBTCJPY) .Select(orderBook => orderBook.GetSnapshot(15)) // Take 15 orders from 300 orders .Subscribe(obs => { Console.SetCursorPosition(left, top); foreach (var ask in obs.Asks.Reverse()) { Console.WriteLine($"{ask.Size.ToString("##0.00000000#")} {ask.Price} "); } Console.WriteLine($"Mid: {obs.MidPrice}"); foreach (var bid in obs.Bids.Reverse()) { Console.WriteLine($" {bid.Price} {bid.Size.ToString("##0.00000000#")}"); } }).AddTo(_disposables); }