I need to get some specific market data for my studies, and it seems like the most convenient way for me to do this is to use IQFeed data feed and MATLAB. But unfortunately, since I'm not a seasoned MATLAB user i can't put live data into an array in order to save them, while I'm listening to real time function.
So your question is how to use MatLab (specifically the IQFeed) for dealing with real-time data?
I am going to assume you are using a MatLab version older than 2011 / 2012, and if not post any problems / comments and I will see what I can do. (There is also plenty of documentation for using this feature you can find here). Once you get use to the MatLab syntax it is not very difficult.
The way the API works is by creating an object in the IQF function, this object represents / deals with the IQFeed API for MatLab (all available in the documentation). The API provides intraday, tick, historical data as well as major financial news (although this feature specifically is a bit outdated / poor in my opinion, you can find better from other APIs). The API also provides level 1 and 2 market data. For initialising the connection to a pre-existing session, use the following command.
c = iqf(username,password) c = iqf(username,password,portname)
I have never dealt with the IQFeed however it shouldn't be anything different from storing real-time streaming data into an array. Using the discrete/tapped delay box you can basically throttle the sample periods and how they are stored. Also, using the
To File block a signal is inputted and written to the file into a matrix containing two (or more) rows. MatLab will write one column to the matrix for each specified data sample.
This is how I would go about storing real-time IQFeed data into an array in MatLab.
As a replacement for the Trading Toolbox, try IQML (Matlab connector to IQFeed), which runs in Matlab and connects directly to IQFeed.
IQML is an independent 3rd-party product that works on all recent Matlab/IQFeed releases and platforms (Windows, Linux, Mac). The connector is super-reliable, easy-to-use, and lightning-fast (including parallelization). It comes with a detailed User Guide packed with usage examples, sample Matlab scripts, and implementation tips.
IQML needs only the core Matlab to run - no toolboxes are required (parallelization uses the Parallel Computing Toolbox, but IQML runs well even without it).
In answer to the OP question, here's an example of fetching live IQFeed data into Matlab using IQML:
>> data = IQML('quotes', 'Symbol','GOOG') data = Symbol: 'GOOG' Most_Recent_Trade: 1092.14 Most_Recent_Trade_Size: 1 Most_Recent_Trade_Time: '09:46:31.960276' Most_Recent_Trade_Market_Center: 25 Total_Volume: 113677 Bid: 1092.13 Bid_Size: 100 Ask: 1092.99 Ask_Size: 100 Open: 1099.22 High: 1099.22 Low: 1092.38 Close: 1090.93 Message_Contents: 'Cbaohlc' Message_Description: 'Last qualified trade; A bid update occurred, An ask update occurred; An open declaration occurred; A high declaration occurred; A low declaration occurred; A close declaration occurred' Most_Recent_Trade_Conditions: '3D87' Trade_Conditions_Description: 'Intramaket Sweep; Odd lot trade' Most_Recent_Market_Name: 'Direct Edge A (EDGA)'
IQML supports the entire IQFeed API, including:
- Both blocking (snapshot) and non-blocking (streaming) data queries
- Live Level1 top-of-book market data (quotes and trades)
- Live Level2 market-depth data
- Historic, intra-day and live market data (individual ticks or interval bars)
- Fundamental info on assets
- Options and futures chains lookup (with latest market data and Greeks)
- Symbols and market codes lookup
- News headlines, story-counts and complete news stories, with user-specified filters
- Ability to attach user-defined Matlab callback functions to IQFeed messages and market events
- User-defined custom alerts on streaming market events (news/quotes/interval-bar/regional triggers)
- Connection stats and programmatic connect/disconnect
Users can combine all of the above functionality for a full-fledged end-to-end automated trading system using plain Matlab.
IQML was developed independently as a commercial 3rd-party product; it is not affiliated with MathWorks or DTN. As a late-comer competing with an existing product, IQML offers distinct advantages in functionality, performance, reliability, documentation, support, and cost-effectiveness. Give it a try and check for yourself.