Hello everybody,
I’m developing a backtesting system and need some advice with KDB IPC. Here is my stack:
Process A (tick + order router): recieves data from A, recieves order commands from clients (like C), sends order commands to B.
Process B (historical feed + order engine): reads data from hdb and pushes it to the A, receives order commands from A and emulates their execution.
Process C (client, specific strategy): subscribes to data from A, to manage orders sends sync requests to A.
From the process B, I send data in portions asynchronously and flush them at the end of every portion:
/ For every 100ms time interval:
/ Async send data from current interval
while[…; (neg h) (“.u.upd”;`fut_trades__deal; …); …];
while[…; (neg h) (“.u.upd”;`opt_trades__deal; …); …];
while[…; (neg h) (“.u.upd”;`fut_common__common; …); …];
while[…; (neg h) (“.u.upd”;`opt_common__common; …); …];
while[…; (neg h) (“.u.upd”;`orders_aggr__orders_aggr; …); …];
/ Flush pending messages
neg[h];
Process A recieves this data and pushes it to C successfully.
The hard part is when I’m trying to send async request from A to B (e.g. AddOrder) while historical feed is active (B sends a lot of data to A in the manner described earlier).
I have handlers for such requests and they are executed, but it happens only when B stops feeding A with historical data. Until then all such order management requests are queued.
Of course, I want theese requests to be handled ASAP, at the end of every time interval, after flushing data to A.
/ …
/ Flush pending messages
neg[h];
/ Read incoming async messages, execute their handlers
???
Is it possible in KDB?
I have C++ application, which replaces process B in production system to interact with broker and there it uses a separate thread, which repeatedely calls r = k(kdbh,(S)0); to check for incoming messages. It works perfect.
Best regards,
Yury Smykalov