Hi DG,
Here are a few solutions depending on requirements/specifics:
1. Depending on how dynamic the queries are, i.e. if it’s a mostly fixed list of aggregations, I would suggest using a Real Time Subscriber (RTS) and creating tables for the different aggregations, then subscribing to those aggregate tables from C# using .u.sub
– Q Real Time Subscriber
– C# KDB Q Subscriber Example
2. If the aggregations are very dynamic, create on the C# side a polling query to Q. This would be similar to static queries (examples below) but wrapped in a looping statement within C#.
– AquaQ Documentation on C# Aggregations
– KX Example Simple Query
Note this second solution wouldn’t be truly Real-Time, but you could reduce the polling time to an extent where it’s close enough to real-time for your purposes.
3. If you’re truly looking for Real-Time responses you could subscribe via a Gateway Process and treat it as an aggregator, then define the aggregation that’s run on-update via remote queries from C#. Something along the lines of:
connection.ks(“.my.agg:{select avg price from x}”)
Where the string would be defined by C# dynamically and run on-change.
The 3rd method is quite a bit more complicated than the other two and will have a few issues that need to be overcome. I have noted it to answer this question in it’s completion but would advise either approach 1 or 2. If a non-polling approach is definitely required I’ll be happy to go into more detail on the third solution and the gotchas.
Regards,
Sam B