IQML usage examples

IQML free trial

Here are representative usage examples of IQML. Many more examples and detailed information are available in the IQML User Guide. Please email us (info@IQML.net) if you have any questions.

The following examples are listed below:

  1. Get market data (snapshot) for a security
  2. Get fundamental data for a security
  3. Get historic/intra-day data
  4. Get streaming quotes data
  5. Get news data
  6. Connect/disconnect from IQFeed
  7. Get connection information/stats
  8. Specify message event callbacks

  1) Get market data (snapshot) for a security

IQML's IQFeed-Matlab connectivity

>> 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: 'Cbaohlcv'
               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; A volume update occurred'
      Most_Recent_Trade_Conditions: '3D87'
      Trade_Conditions_Description: 'Intramaket Sweep; Odd lot trade'
           Most_Recent_Market_Name: 'Direct Edge A (EDGA)'

Available parameters that affect the query: Symbol, Timeout, NumOfEvents, MsgParsingLevel.

  2) Get fundamental data for a security

Click to view the full IQML User Guide (PDF)

Click to view the IQML User Guide (PDF)

>> data = IQML('fundamental', 'symbol','GOOG')
data = 
                     Exchange_ID: 7
                              PE: 25.7
                  Average_Volume: 4588000
                   x52_Week_High: 180.95
                    x52_Week_Low: 139.13
              Calendar_Year_High: 171.13
               Calendar_Year_Low: 144.395
                  Dividend_Yield: 3.79
                 Dividend_Amount: 1.5
                   Dividend_Rate: 6
                        Pay_Date: '03/10/2018'
                Ex_dividend_Date: '02/08/2018'
                  Short_Interest: 17484332
                Current_Year_EPS: 6.17
                   Next_Year_EPS: []
     Five_year_Growth_Percentage: -0.16
                 Fiscal_Year_End: 12
                    Company_Name: 'INTERNATIONAL BUSINESS MACHINE'
              Root_Option_Symbol: 'IBM'
    Percent_Held_By_Institutions: 59.9
                            Beta: 1.05
                           Leaps: []
                  Current_Assets: 49735
             Current_Liabilities: 37363
              Balance_Sheet_Date: '12/31/2017'
                  Long_term_Debt: 39837
       Common_Shares_Outstanding: 921168
                  Split_Factor_1: '0.50 05/27/1999'
                  Split_Factor_2: '0.50 05/28/1997'
                   Market_Center: []
                     Format_Code: 14
                       Precision: 4
                             SIC: 7373
           Historical_Volatility: 25.79
                   Security_Type: 1
                   Listed_Market: 7
              x52_Week_High_Date: '03/08/2017'
               x52_Week_Low_Date: '08/21/2017'
         Calendar_Year_High_Date: '01/18/2018'
          Calendar_Year_Low_Date: '02/09/2018'
                  Year_End_Close: 153.42
                   Maturity_Date: []
                     Coupon_Rate: []
                 Expiration_Date: []
                    Strike_Price: []
                           NAICS: 541512
                   Exchange_Root: []
       Option_Premium_Multiplier: []
     Option_Multiple_Deliverable: []
        Price_Format_Description: 'Four decimal places'
            Exchange_Description: 'New York Stock Exchange (NYSE)'
       Security_Type_Description: 'Equity'
                 SIC_Description: 'COMPUTER INTEGRATED SYSTEMS DESIGN'
               NAICS_Description: 'Computer Systems Design Services'

Available parameters that affect the query: Symbol, Timeout, MsgParsingLevel.

  3) Get historic/intra-day data

% Get historic daily data:
>> data = IQML('history', 'symbol','IBM', 'dataType','day')  % dataType is optional (default: 'day')
data = 
  1×100 struct array with fields:
    Symbol
    Datestamp
    Datenum
    High
    Low
    Open
    Close
    PeriodVolume
    OpenInterest
 
>> data(1)
ans = 
          Symbol: 'IBM'
       Datestamp: '2017-10-10'
         Datenum: 736978
            High: 148.95
             Low: 147.65
            Open: 147.71
           Close: 148.5
    PeriodVolume: 4032601
    OpenInterest: 0
 
>> highs = [data.High];  % array of High values
 
% Get historic ticks data for the VIX continuous future (@VX#):
>> data = IQML('history', 'symbol','@VX#', 'dataType','ticks');
>> data(1)
ans = 
               Symbol: '@VX#'
            Timestamp: '2018-03-09 06:47:57.899000'
              Datenum: 737128.283309016
                 Last: 17.12
             LastSize: 1
          TotalVolume: 3605
                  Bid: 17.1
                  Ask: 17.15
               TickID: 4377589
         BasisForLast: 'O'
     BasisDescription: 'Other trade = any trade not accounted for by C or E'
    TradeMarketCenter: 32
      TradeMarketName: 'CBOE Futures Exchange (CFE)'
      TradeConditions: '4D'
     TradeDescription: 'Implied'

Available parameters that affect the query: Symbol, DataType (day/week/month/interval/ticks), DataDirection, MaxItems, Days, BeginDate, EndDate, BeginDateTime, EndDateTime, BeginFilterTime, EndFilterTime, IntervalType, IntervalSize, Timeout, MsgParsingLevel.

  4) Get streaming quotes data

The initial request to send streaming quotes for the VIX continuous future (@VX#):

IQML('quotes', 'Symbol','@VX#', 'NumOfEvents',100, 'MaxItems',10);

Multiple symbols can be specified, as a cell-array or colon-delimited string:

IQML('quotes', 'NumOfEvents',100, 'Symbol','@VX#:GOOG:AAPL');        % alternative #1
IQML('quotes', 'NumOfEvents',100, 'Symbol',{'@VX#','GOOG','AAPL'});  % alternative #2

Subsequent requests to retrieve the latest accumulated data for a symbol, return a data struct that looks like this:

>> data = IQML('quotes', 'Symbol','@VX#', 'NumOfEvents',-1)
data = 
                 Command: 'w@VX#'
                isActive: 1
         EventsToProcess: 100
         EventsProcessed: 43
      LatestEventDatenum: 737128.637260451
    LatestEventTimestamp: '20180309 15:17:39.303'
                DataType: 'quotes and trades'
             ProcessType: 'stream'
              BufferSize: 10
                  Buffer: [1×10 struct]
              LatestData: [1×1 struct]
 
>> data.LatestData
ans =
                             Symbol: '@VX#'
                  Most_Recent_Trade: 17.08
             Most_Recent_Trade_Size: []
             Most_Recent_Trade_Time: '08:06:20.716000'
    Most_Recent_Trade_Market_Center: 32
                       Total_Volume: 4507
                                Bid: 17.05
                           Bid_Size: 63
                                Ask: 17.1
                           Ask_Size: 244
                               Open: 17.2
                               High: 17.35
                                Low: 17
                              Close: 17.23
                   Message_Contents: 'Cbasohlcv'
                Message_Description: 'Last qualified trade; A bid update occurred; An ask update occurred; A settlement 
                                      occurred; An open declaration occurred; A high declaration occurred; A low
                                      declaration occurred; A close declaration occurred; A volume update occurred'
       Most_Recent_Trade_Conditions: '4D'
       Trade_Conditions_Description: 'Implied'
            Most_Recent_Market_Name: 'CBOE Futures Exchange (CFE)'

Available parameters that affect the query: Symbols, DataType (quotes/trades), NumOfEvents, MaxItems, Timeout.

Similarly, streaming interval bars and regional updates can be requested using IQML('intervalbars',...) and IQML('regional',...) commands.

  5) Get news data

News configuration:

>> data = IQML('news', 'DataType','config')
data = 
    Category: 'All News'
      Majors: [1×7 struct]
 
>> {data.Majors.Description}
ans =
  1×7 cell array
    {'DTN News'}  {'PR Newswire'}  {'Business Wire'}  {'Real-Time Trader'}  {'GlobeNewswire Inc'}  {'Marketwire'}  {'Benzinga Pro'}
 
% This shows that we are connected to 7 major news sources. We can drill-down for details about these news sources:
>> data.Majors(1)  % first of 7 Major news sources
ans = 
                Source: 'DTN'
           Description: 'DTN News'
    AuthenticationCode: '1D'
                IconID: 10
                Minors: [1×4 struct]
 
>> data.Majors(1).Minors(1)  % 1st of 4 Minor DTN sources
ans = 
                Source: 'DT5'
           Description: 'Treasuries, Most Actives, Gainers, Losers'
    AuthenticationCode: '1D'
 
>> data.Majors(1).Minors(2)  % 2nd of 4 Minor DTN sources
ans = 
                Source: 'RTL'
           Description: 'Derivatives - Selected Futures and Options'
    AuthenticationCode: '2Ab'
                IconID: 10

News story headlines:

>> data = IQML('news', 'DataType','headlines')
data = 
  1×1000 struct array with fields:
    Source
    ID
    Symbols
    Timestamp
    Text
 
>> data(1)
ans = 
       Source: 'BEN'
           ID: 21991162633
      Symbols: {'BZRatings'  'MNTX'}
    Timestamp: 20180305064533
         Text: 'Manitex International Sees Q4 Sales $64.40M vs $64.45M Est...'
 
% Limiting the headlines to specific symbols, events and/or news-sources:
>> data = IQML('news', 'DataType','headlines', 'Symbols',{'IBM','GOOG','BZRatings'}, 'Sources',{'DTN','CPR','BEN'});
>> data = IQML('news', 'DataType','headlines', 'Symbols','IBM:GOOG:BZRatings', 'Sources','DTN:CPR:BEN');  % equivalent alternative
data = 
  1×687 struct array with fields:
    Source
    ID
    ...

News story full text:

>> data = IQML('news', 'DataType','story', 'ID',21991162633)
data = 
         ID: 21991162633
    Symbols: {'BZRatings'  'MNTX'}
       Text: 'Manitex International Sees Q4 Sales $64.40M vs $64.45M Est. 
              Manitex International (NASDAQ: MNTX) sees Q4 sales of $64.40M vs $64.45M estimate.'

News story count:

>> data = IQML('news', 'DataType','number', 'Symbols','BSX:AAPL:GOOG')
data = 
    AAPL: 7
     BSX: 14
    GOOG: 2
 
% The query can be limited by symbol(s), news-source(s), and date(s):
>> data = IQML('news', 'DataType','number', 'Symbols','BSX:GOOG:AAPL', 'BeginDate',20180301, 'EndDate',20180303)
data = 
    AAPL: 37
     BSX: 3
    GOOG: 13

Available parameters that affect the query: Symbols, Sources, DataType, Date, BeginDate, EndDate, MaxItems, NumOfEvents, Timeout.

  6) Connect/disconnect from IQFeed

IQML('disconnect');  % disconnect from IQFeed (IQConnect)
 
IQML('reconnect');  % disconnect and then automatically re-connect (optional parameters: Username, Password)

  7) Get connection information/stats

>> data = IQML('stats')
data =
                       ServerIP: '66.112.148.226'
                     ServerPort: 60002
                     MaxSymbols: 1300
          NumOfStreamingSymbols: 0
          NumOfClientsConnected: 3
         SecondsSinceLastUpdate: 1
             NumOfReconnections: 0
    NumOfAttemptedReconnections: 0
                      StartTime: 'Mar 07 11:03AM'
                     MarketTime: 'Mar 07 04:34AM'
               ConnectionStatus: 'Connected'
                  IQFeedVersion: '5.2.7.0'
                        LoginID: '123456-1'
                   TotalKBsRecv: 42.98
              KBsRecvLastSecond: 0.02
               AvgKBsPerSecRecv: 0.02
                   TotalKBsSent: 361.62
              KBsSentLastSecond: 0.22
               AvgKBsPerSecSent: 0.19

Additional port-specific stats can be requested using the optional AddPortStats parameter:

>> data = IQML('stats', 'AddPortStats',1)
data =
                       ServerIP: '66.112.148.224'
                     ServerPort: 60005
                            ...
                         Level2: [1×1 struct]
           Level2SymbolsWatched: 2
                         Lookup: [1×1 struct]
         RegionalSymbolsWatched: 2
                          Admin: [1×1 struct]
                         Level1: [1×1 struct]
           Level1SymbolsWatched: 0

  8) Specify message event callbacks

We can attach a user callback function to all IQFeed messages:

IQML('ProcessFunc',@IQML_Callback);  % set a single callback function for all message types

We can also specify specific callbacks for various message types, and a default callback for all other message types:

% Alternative #1: using the struct() function:
callbacks = struct('System',      [], ...   % ignore System messages
                   'Quote_update',@IQML_Quote_Update_Callback, ...  % Level-1 quote updates
                   'Market_depth',@IQML_Market_Depth_Callback, ...  % Level-2 market-depth updates
                   'Default',     @IQML_Default_Callback);  % default callback for all other messages
 
% Alternative #2: using direct field assignments:
callbacks.System       = [];  % ignore System messages
callbacks.Quote_update = @IQML_Quote_Update_Callback;
callbacks.Market_depth = @IQML_Market_Depth_Callback;
callbacks.Default      = @IQML_Default_Callback);
 
% Now update IQML with these callbacks:
IQML('time', 'processFunc',callbacks);

where the callback functions are defined similarly to the following (for example, in a file called IQML_Callback.m):

function IQML_Callback(iqObject, eventData, varargin)
 
    % Extract the basic event data components
    event_timestamp  = eventData.Timestamp;     % local time in Matlab's datenum format
    event_msg_port   = eventData.MessagePort;   % e.g. 'Level2' for a Market_depth event
    event_msg_type   = eventData.MessageType;   % e.g. 'Market_depth'
    event_msg_header = eventData.MessageHeader; % e.g. 'Z' for a Market_depth event
    event_msg_string = eventData.MessageString; % the complete message string from IQFeed
    event_msg_parts  = eventData.MessageParts;  % the parsed message, split into a cell-array
 
    % Now do something useful with all this information...
    ...
 
end  % IQML_Callback

No other solution provides this rich set of features – not even close.

Don’t take our word for it – request a fully-functional free trial version, and check for yourself! You will not be disappointed.

If you have any question, don’t hesitate to email us at info@iqml.net for additional information.

Free trial version

IQML free trialDownload a free trial of IQML with detailed installation and usage instructions. There are absolutely no strings attached: the trial is completely free and fully functional, just limited in duration (30 days).

You only need the basic Matlab, no toolbox is required. You can be up and running within minutes. We are confident that you will love the product, so we encourage you to test it:

Download your free 30-day trial now! (or email us at info@iqml.net for additional information)

Legal disclaimer

THIS SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES, LOSS OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
(detailed disclaimer is available in IQML’s User Guide)

Comments are closed.