In Windows, applications can expose their internal functions/data as COM objects called ROM automation. Then, Excel can tap into these interfaces using the RTD (Real Time Data) feature.
// Creating a RTD server
public class SampleRTDServer : IRtdServer {
public object ConnectData(int topicCount, ref Array topicIds, ref Array strings, ref Array realTimeData) {
// fetch and return data
}
}
A standard synrax to get data from a RTD server looks like:
=RTD(ProgId, topicId (optional), arg1, arg2)
A popular trading platform, ThinkOrSwim, supports this feature by creating a COM server (IRTDServer) from which Excel can hook into and receive live data.
// Example in Excel
=RTD("tos.rtd",,"LAST”, “AAPL”) //141.00
Custom RTD client
We can quickly implement a program to hook into this interface and get data without needing for Excel.
interface IRTDServer {
// ConnectData(topicId, parameters, newValue)
}
Use GUID to create a reference to a specific COM server instance. Use ConnectData method to connect to a specific topic and get data.