Hello,
Is it possible to have only the latest update event (per key) instead of multiple in case of batch editing when using a SourceCache and an IObservableCache?
I use batch edit to add some market prices in the SourceCache (as shown below)
public void AddTicks(ICollection<Tick> newTicks)
{
_ticksCache.Edit(innerCache => innerCache.AddOrUpdate(newTicks));
}
I also have an IObservableCache<Tick, string> NewTicks (as shown below)
NewTicks = _ticksCache
.Connect()
.Filter(tick => tick.LastUpdate > DateTime.UtcNow - TimeSpan.FromSeconds(1))
.Batch(TimeSpan.FromSeconds(1))
.AsObservableCache();
When i subscribe to the IObservableCache i get multiple update events for the same currency pairs eg EURUSD per second
tickService.NewTicks
.Connect()
.Watch("EURUSD")
.Subscribe(price => Console.WriteLine(price));
In my case I'm only interested about the latest value of a currency pair (eg if EURUSD had 3 price changes in 1 second i'm only interested about the 3rd).
Update, Key: EURUSD, Current: Name: EURUSD, Price: 1, LastUpdate: 14/03/2022 4:14:21 pm, Previous: Name: EURUSD, Price: 0, LastUpdate: 14/03/2022 4:14:20 pm
Update, Key: EURUSD, Current: Name: EURUSD, Price: 2, LastUpdate: 14/03/2022 4:14:21 pm, Previous: Name: EURUSD, Price: 1, LastUpdate: 14/03/2022 4:14:21 pm
Update, Key: EURUSD, Current: Name: EURUSD, Price: 3, LastUpdate: 14/03/2022 4:14:21 pm, Previous: Name: EURUSD, Price: 2, LastUpdate: 14/03/2022 4:14:21 pm
Is what I'm asking possible? If yes how?
ps: Yesterday I asked this question in stackoverflow. There i have my full sample code. I can copy it here as well if it's preferable. Also assuming i get an answer i will update/close this question accordingly (and vice versa of course).
Hello,
Is it possible to have only the latest update event (per key) instead of multiple in case of batch editing when using a
SourceCacheand anIObservableCache?I use batch edit to add some market prices in the SourceCache (as shown below)
I also have an
IObservableCache<Tick, string> NewTicks(as shown below)When i subscribe to the
IObservableCachei get multiple update events for the same currency pairs eg EURUSD per secondIn my case I'm only interested about the latest value of a currency pair (eg if EURUSD had 3 price changes in 1 second i'm only interested about the 3rd).
Is what I'm asking possible? If yes how?
ps: Yesterday I asked this question in stackoverflow. There i have my full sample code. I can copy it here as well if it's preferable. Also assuming i get an answer i will update/close this question accordingly (and vice versa of course).