How to connect MATLAB to a DolphinDB stream table?

8 hours ago 3
ARTICLE AD BOX

I'm working on a quant strategy where DolphinDB has a real-time stream table on the server side, and MATLAB needs to subscribe and consume the data for downstream computation. Looking for a solution with low latency and reasonable integration cost.

Two approaches come to mind:

The first is to subscribe via the C++ API and wrap it as a MATLAB-callable library using MEX:

// sketch of C++ API subscription DBConnection conn; conn.connect("localhost", 8848); conn.subscribe("localhost", 8848, "streamTable", "subHandler", MessageHandler, -1, true);

This should give the lowest latency in theory, but requires writing the MEX wrapper from scratch — not sure how much work that actually is, or whether any ready-made wrapper already exists.

The second is to subscribe via Python or C++, write incoming data to a .mat file, and have MATLAB poll the file:

import dolphindb as ddb import scipy.io as sio s = ddb.session() s.connect("localhost", 8848) def handler(msg): data = msg.toDF().to_dict("list") sio.savemat("latest.mat", data) s.subscribe("localhost", 8848, handler, "streamTable")

This is straightforward to implement, but the polling interval and file I/O overhead add latency — not sure if that's acceptable for time-sensitive use cases.

Is there a more direct way to connect MATLAB to a DolphinDB stream table? If the C++ MEX route is the only real option, is there any reference implementation or example to start from?

Read Entire Article