public async Task SubscribeOnOrderBook(string currencyPairId, Action <IList <OrderBookItem> > callback) { Connect(); var innerExistingOrderbook = await _connection.Context.MarketOrderbookAsync(currencyPairId, 30); var existingOrderBook = innerExistingOrderbook.ToOuterModel(); callback(existingOrderBook); var subscription = new Subscription { SubscribeRequest = StreamingRequest.SubscribeOrderbook(currencyPairId, 30), UnsubscribeRequest = StreamingRequest.UnsubscribeOrderbook(currencyPairId, 30), EventHandler = (o, e) => { if (!(e.Response is OrderbookResponse orderbookResponse) || orderbookResponse.Payload.Figi != currencyPairId) { return; } var orderBook = orderbookResponse.Payload.ToOuterModel(); callback(orderBook); } }; _connection.StreamingEventReceived += (o, e) => subscription.EventHandler(o, e); await _connection.Context.SendStreamingRequestAsync(subscription.SubscribeRequest); }