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 (IQML@undocumentedmatlab.com) if you have any questions.

The following examples are listed below:
IQML's IQFeed-Matlab connectivity

  1. Get market data (snapshot) for a security
  2. Get fundamental data for a security
  3. Get latest interval bars for a security
  4. Calculate option Greeks, fair value and implied volatility
  5. Get historic/intra-day data
  6. Get streaming quotes data
  7. Get news data
  8. Get options/futures chain
  9. Connect/disconnect from IQFeed
  10. Get connection information/stats
  11. Specify message event callbacks

  1) Get market data (snapshot) for a security

Click to view the full IQML User Guide (PDF)
Click to view the IQML User Guide (PDF)
>> 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: Symbols, Timeout, NumOfEvents, MsgParsingLevel, Fields, UseParallel.

  2) Get fundamental data for a security

>> data = IQML('fundamental', 'symbol','IBM')
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: Symbols, Timeout, MsgParsingLevel.

  3) Get the latest interval bars for a security

>> data = IQML('intervalbars', 'Symbol','@VX#', 'NumOfEvents',4)
data =
  4×1 struct array with fields:
    Symbol
    BarType
    Timestamp
    Open
    High
    Low
    Close
    CummlativeVolume
    IntervalVolume
    NumberOfTrades
 
>> data(1)
ans =
    Symbol: '@VX#'
    BarType: 'Complete interval bar from history'
    Timestamp: '2018-09-05 12:36:00'
    Open: 14.45
    High: 14.5
    Low: 14.45
    Close: 14.45
    CummlativeVolume: 57077
    IntervalVolume: 17
    NumberOfTrades: 0

Available parameters that affect the query: Symbols, Timeout, NumOfEvents, MaxItems, MaxDays, IntervalType, IntervalSize, BeginFilterTime, EndFilterTime, BeginDateTime, MsgParsingLevel.

  4) Calculate option Greeks, fair value and implied volatility

>> data = IQML('greeks', 'symbol','IBM1814L116')
data = 
                            Symbol: 'IBM1814L116'
                        Asset_Name: 'IBM DEC 2018 C 116.00'
                      Strike_Price: 116
                   Expiration_Date: '12/14/2018'
                Days_To_Expiration: 30
               Inferred_Asset_Side: 'Call'
                 Underlying_Symbol: 'IBM'
                   Underlying_Spot: 121.3
    Underlying_Historic_Volatility: 37.1
            Assumed_Risk_Free_Rate: 0
            Assumed_Dividend_Yield: 0
                  Asset_Fair_Value: 8.1193
                Asset_Latest_Price: 7.05
                  Asset_Price_Diff: 1.0693
                Implied_Volatility: 0.28242
                             Delta: 0.68197
                              Vega: 0.12404
                             Theta: -0.076697
                               Rho: 6.1318
                              CRho: 6.7992
                             Omega: 10.189
                            Lambda: 10.189
                             Gamma: 0.027646
                             Vanna: -0.3527
                             Charm: 0.0021809
                             Vomma: 5.8043
                              Veta: 2.4262
                             Speed: -0.0012419
                             Zomma: -0.061581
                             Color: -0.00038078
                            Ultima: -45.238
                Annual_Factor_Used: 365
           This_Asset_Latest_Quote: [1×1 struct]
           Underlying_Latest_Quote: [1×1 struct]
           This_Asset_Fundamentals: [1×1 struct]
           Underlying_Fundamentals: [1×1 struct]

Available parameters that affect the query: Symbols, Timeout, UseParallel, UnderlyingSymbol, HistoricVolatility, RiskFreeRate, DividendsYield, Side, DaysToExpiration, AnnualFactor.

  5) Get historic/intra-day data

% Get historic daily data:
>> data = IQML('history', 'symbol','IBM', 'dataType','day')  % dataType is optional (default: 'day')
data = 
  100×1 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: Symbols, DataType (day/week/month/interval/ticks), DataDirection, MaxItems, Days, BeginDate, EndDate, BeginDateTime, EndDateTime, BeginFilterTime, EndFilterTime, IntervalType, IntervalSize, Timeout, UseParallel, MsgParsingLevel.

  6) 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, 'Symbols','@VX#:GOOG:AAPL');        % alternative #1
IQML('quotes', 'NumOfEvents',100, 'Symbols',{'@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: [10×1 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, Fields.

Similarly, streaming interval bars, regional updates and Level-2 market depth updates can be requested using IQML('intervalbars',...), IQML('regional',...) and IQML('marketdepth',...) commands.

  7) 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 = 
  1000×1 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 = 
  687×1 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, GetStory, NumOfEvents, Timeout, UseParallel.

  8) Get options/futures chains

% Report GOOG options having strike price between $1000-$1010 in next 4 months
>> symbols = IQML('chain', 'symbol','goog', 'NearMonths',4, 'MinStrike',1000, 'MaxStrike',1010)'
symbols =
  1×58 cell array
  Columns 1 through 4
    'GOOG1803H1000' 'GOOG1803H1010' 'GOOG1810H1000' 'GOOG1810H1005'
  Columns 5 through 8
    'GOOG1810H1010' 'GOOG1813G1000' 'GOOG1813G1002.5' 'GOOG1813G1005'
  Columns 9 through 12
    'GOOG1813G1007.5' 'GOOG1813G1010' 'GOOG1817H1000' 'GOOG1817H1005'
  ...
 
% Fetch the options chain for a symbol along with the latest quotes for all options
>> data = IQML('chain', 'symbol','GOOG', 'NearMonths',4, 'MinStrike',1000, 'MaxStrike',1010, 'WhatToShow','quotes')
data =
  58×1 struct array with fields:
    Symbol
    Most_Recent_Trade
    Most_Recent_Trade_Size
    Most_Recent_Trade_Time
    Most_Recent_Trade_Market_Center
    Total_Volume
    Bid
    Bid_Size
    Ask
    Ask_Size
    Open
    High
    Low
    Close
    ...
>> data(1)
ans =
    Symbol: 'GOOG1803H1000'
    Most_Recent_Trade: 120
    Most_Recent_Trade_Size: 1
    Most_Recent_Trade_Time: '15:57:12.930497'
    Most_Recent_Trade_Market_Center: 156
    Total_Volume: 0
    Bid: 140.5
    Bid_Size: 3
    Ask: 150.1
    Ask_Size: 1
    Open: []
    High: []
    Low: []
    Close: 120
    Message_Contents: 'Cbacv'
    Message_Description: 'Last qualified trade; A bid update occurred;
    An ask update occurred; A close declaration occurred; A volume update occurred'
    Most_Recent_Trade_Conditions: 1
    Trade_Conditions_Description: 'Normal Trade'
    Most_Recent_Market_Name: 'MIAX PEARL Options exchange'
 
% Fetch the options chain for a symbol along with the fundamental data for all options
>> data = IQML('chain', 'symbol','GOOG', 'NearMonths',4, 'MinStrike',1000, 'MaxStrike',1010, 'WhatToShow','fundamental')
data =
  58×1 struct array with fields:
    Symbol
    Exchange_ID
    PE
    Average_Volume
    x52_Week_High
    x52_Week_Low
    Calendar_Year_High
    Calendar_Year_Low
    ...

Available parameters that affect the query: Symbols, DataType (options/futures/spread/foptions), Side, WhatToShow, Months, NearMonths, Years, IncludeBinary, MinStrike, MaxStrike, NumInMoney, NumOutOfMoney, UseParallel.

  9) Connect/disconnect from IQFeed

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

  10) 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
                      Exchanges: {1×16 cell}
                  ServerVersion: '6.0.0.5'
                    ServiceType: 'real_time'

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

  11) 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

This was just a short sampling of IQML’s functionality. The product contains many more features and query types. Review the full IQML User Guide for a detailed description of the available functionality.

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 IQML@undocumentedmatlab.com 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 (15 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 15-day trial now! (or email us at IQML@undocumentedmatlab.com 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)

Print This Page Print This Page