Merging historical and live stock price data with Rx

前端 未结 4 751
清酒与你
清酒与你 2020-12-14 11:54

I\'m trying out Rx because it seems like a good fit for our domain but the learning curve has taken me by surprise.

I need to knit together historical price data wit

4条回答
  •  既然无缘
    2020-12-14 12:11

    A convenient way in terms of memory and trades overlapping (correctness).
    Waiting for your feedback:

    var tradeIds = new HashSet();
    var replayQuotationTrades = new ReplaySubject();
    var replaySubscription = _quotationTrades.Subscribe(replayQuotationTrades);
    return _historyTrades
                    .DelaySubscription(TimeSpan.FromMilliseconds(500), _backgroundScheduler)
                    .Do(t => tradeIds.Add(t.TradeId))
                    .Finally(() => DisposeAndCompleteReplayStream(replaySubscription, replayQuotationTrades))
                    .Concat(replayQuotationTrades.Where(t => !tradeIds.Contains(t.TradeId)))
                    .Finally(tradeIds.Clear)
                    .Concat(_quotationTrades)
                    .Subscribe(observer);
    

提交回复
热议问题