Clear Filters
Clear Filters

How to effectively utilize listener and callback functions with iqfeed function realtime.

3 views (last 30 days)
I am currently trying to acquire realtime market data for a security. The end result that I am trying to achieve is to get interval based data (high, low, open, close, period volume) sampled at a rate that I specify. Thus far, I have written a simple elistner function and a trivial callback function. My functions are as follows: ------------------------
function [] = listen(A,B)
function [] = event()
The line that im executing at the command window is the following:
realtime(Q, '@QM#',{'Most Recent Trade', 'Most Recent Trade Size'},@listen,@event)
Where Q is my iqfeed connection with Q.Protocol set to 5.1. This is what I get at the command window:
A =
Socket with properties:
SupportsIPv4: 1
OSSupportsIPv4: 1
SupportsIPv6: 0
OSSupportsIPv6: 1
Available: 376
LocalEndPoint: [1x1 System.Net.IPEndPoint]
RemoteEndPoint: [1x1 System.Net.IPEndPoint]
Handle: [1x1 System.IntPtr]
Blocking: 1
UseOnlyOverlappedIO: 0
Connected: 1
AddressFamily: [1x1 System.Net.Sockets.AddressFamily]
SocketType: [1x1 System.Net.Sockets.SocketType]
ProtocolType: [1x1 System.Net.Sockets.ProtocolType]
IsBound: 1
ExclusiveAddressUse: 0
ReceiveBufferSize: 8192
SendBufferSize: 8192
ReceiveTimeout: 0
SendTimeout: 0
LingerState: [1x1 System.Net.Sockets.LingerOption]
NoDelay: 0
Ttl: 128
DontFragment: 1
The thing im confused about is why there are no fields in the socket object that are relevant to the data. I was looking at the v3stockticker example and I saw that the example relied on the fact that the socket object had fields relating to volume and price, but i see no such fields here. Also, why is the second input parameter of the listener function set to @event. In addition, this only seems to execute once, whereas the realtime function keeps producing data if no elistner or callback are specified. Any insight would be appreciated. A code example would work to if possible.
Thanks very much.....

Answers (1)

Yair Altman
Yair Altman on 12 Jan 2020
Consider using my IQML (IQFeed-Matlab) connector as an alternative. IQML enables both synchronous (blocking) and asynchronous (background) queries, that are fetched either serially or in parallel (using the Matlab Parallel Computing Toolbox). A simple usage example that fetches the interval data that you mentioned is:
>> data = IQML('intervalbars', 'Symbol','@ES#')
data =
Symbol: '@ES#'
BarType: 'Complete interval bar from history'
Timestamp: '2018-09-05 12:57:00'
Open: 2887.75
High: 2888.25
Low: 2887.5
Close: 2888.25
CummlativeVolume: 1117565
IntervalVolume: 913
NumberOfTrades: 0
IQML was developed with top performance, reliability and usability in mind. IQML supports 100% of IQFeed's API functionality. It is fully documented, continuously maintained/improved, and I am happy to provide support.
Note: I am an independent software developer and not a MathWorks employee. Don't get angry at me for bringing an independent alternative to the table...


Find more on Performance and Memory in Help Center and File Exchange


Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!