diff --git a/src/client/spark_api/MarketData/IncrementalMarketDataClient.cs b/src/client/spark_api/MarketData/IncrementalMarketDataClient.cs index 1f17a4147..75edace00 100644 --- a/src/client/spark_api/MarketData/IncrementalMarketDataClient.cs +++ b/src/client/spark_api/MarketData/IncrementalMarketDataClient.cs @@ -1,3 +1,4 @@ +#nullable enable namespace bts.md { using bts.api.core; @@ -23,13 +24,7 @@ namespace bts.md { _poll_interval = poll_interval; _num_depth_levels = num_depth_levels; } - IObservable> security_market_data(SecurityCriteria cr, uint security_id) { - return market_data() - .Select(table => { - var b = table.state.Values.Take(3).ToList(); - return b; - }); - } + public IObservable security_market_data(uint security_id) => market_data() .Select(table => { @@ -39,19 +34,19 @@ namespace bts.md { }) .DistinctUntilChanged(); - public IObservable> market_data() { + public IObservable> market_data(SecurityCriteria? criteria = null) { // This MDSource's IObservable provides callbacks when a security is added or removed, but // doesn't detect book changes. To avoid maintaining complicated state, create a brand new // IObservable of book updates whenever the securities change. - return _source.subscribe_securities() + return criteria.subscribe_md(_source.subscribe_securities()) .Select(fixed_sec_market_data) .FlattenTableSeries(); IObservable> fixed_sec_market_data( - IReadOnlyDictionary security_mds) { + IEnumerable security_mds) { // Convert 'security_mds' to a list of PollableBooks. var cached_books = security_mds - .Select(kv => new PollableBook(kv.Value, _num_depth_levels)) + .Select(s => new PollableBook(s, _num_depth_levels)) .ToList(); return Observable.Interval(_poll_interval).Scan(