5 Historical and intra-day data

Historical data can be retrieved via the 'history' action, subject to your account subscription rights, and IQFeed’s pacing limitations. Several data-types are available, which can be set using the DataType parameter (default: 'day').69

5.1 Daily data

To retrieve historic daily data bars, set DataType to 'd' or 'day' (or just leave this parameter out, since 'day' is the default data type), and set the asset’s Symbol:

>> data = IQML('history', 'symbol','IBM');
>> data = IQML(
'history', 'symbol','IBM', 'dataType','day') %equivalent
data =
100×1 struct array with fields:
Symbol
Datestamp
Datenum
High
Low
Open
Close
PeriodVolume
OpenInterest

We received an array of Matlab structs containing daily bars, one per each of the last N trading days (excluding currently-trading day’s bar for IQFeed clients 6.0 or older; including the current day’s bar for 6.1 or newer). By default, we receive up to N=100 data bars, ordered from oldest to newest. We ran the query above using IQFeed client 5.2 on March 6, 2018 so we received daily data from 2017-10-10 until 2018-03-05:

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

>> data(end)
ans =
Symbol: 'IBM'
Datestamp: '2018-03-05'
Datenum: 737124
High: 157.49
Low: 153.75
Open: 154.12
Close: 156.95
PeriodVolume: 3670630
OpenInterest: 0

You can aggregate the numeric values into Matlab arrays as follows:

dates = {data.Datestamp}; % cell-array of strings
closes = [data.Close]; % array of numeric values

You can then use these arrays for vectorized processing, plotting etc. For example:

dates2 = datetime(dates); % array of datetime objects
[maxVal, maxIdx] = max(closes); % maximal value and location index
[minVal, minIdx] = min(closes);
% minimal value and location index

plot(dates2, closes); hold on;
plot(dates2(maxIdx), maxVal, '^g');
% maximal data point – green ▲
plot(dates2(minIdx), minVal, 'vr');
% minimal data point – red ▼

???

You can change the order at which the data bars are reported, using the DataDirection parameter (1 means oldest-to-newest (default); -1 means newest-to-oldest):

>> data = IQML('history', 'symbol','IBM', 'dataDirection',-1);
>> data(1)
ans =
Symbol: 'IBM'
Datestamp: '2018-03-05'
Datenum: 737124
High: 157.49
Low: 153.75
Open: 154.12
Close: 156.95
PeriodVolume: 3670630
OpenInterest: 0

It is possible that there may be fewer than N=100 daily bars for an asset. For example, the symbol @EMF19 (1-month Euro-Dollar Jan 2019 future on CME) started trading on 2018-01-12, so we only get 35 daily bars when we run the query on 2018-03-06:

>> data = IQML('history', 'symbol','@EMF19');
data =
35×1 struct array with fields:
Symbol
...

You can ask IQFeed to limit the maximal number of data bars (N) using the MaxItems parameter:

>> data = IQML('history', 'symbol','IBM', 'maxItems',20)
data =
20×1 struct array with fields:
Symbol
...

In this example, data(1).Datestamp='2018-02-05', i.e. 20 trading days ago.

Note that the MaxItems parameter only has an effect if the additional data bars actually exist. In other words, it controls the maximum number of returned data bars – the actual number of bars may be less than this value.70

When the number of data bars that IQFeed sends is very large, it could take a while for the information to be sent. In such a case, IQML might time-out on the request and return only partial data. Such a case is detected and reported by IQML:

>> data = IQML('history', 'symbol','IBM', 'maxItems',-1)

Warning: IQML timeout: only partial data is returned: the Timeout parameter should be set to a value larger than 5

data =
1274×1 struct array with fields:
Symbol
...

As suggested by the message, you can set the Timeout parameter to a high value in order to allow IQML more time to gather the data before returning the results:

>> data = IQML('history', 'symbol','IBM', 'maxItems',-1, 'timeout',60) %oldest:1/2/96
data =
5577×1 struct array with fields:
Symbol
...

You can also specify a BeginDate/EndDate interval for the returned data. Dates can be specified in several formats: numeric Matlab datenum (737089), Matlab datetime object, numeric yyyymmdd (20180129), string ('2018/01/29', '2018-01-29', '20180129'). Note that MaxItems takes precedence over BeginDate, regardless of DataDirection. For example, if MaxItems=5, you will only get the 5 latest bars, for any BeginDate.71

You can request historical data for multiple symbols at the same time, in a single IQML command, by specifying a colon-delimited or cell-array list of symbols. For example:

>> data = IQML('history', 'symbol',{'IBM','GOOG','AAPL'}, 'maxItems',20)

>> data = IQML('history', 'symbol','IBM:GOOG:AAPL', 'maxItems',20) %equivalent

The result will be an array of Matlab structs that correspond to the requested symbols (3 symbols with 20 data-points each, in this example):

data =
20×3 struct array with fields:
Symbol
...

>> data(1,2) % 2nd index (column) is the symbol; GOOG data is in data(:,2)
ans =
struct with fields:
Symbol: 'GOOG'
Datestamp: '2018-07-10'
Datenum: 737251
High: 1159.59
Low: 1149.59
Open: 1156.98
Close: 1152.84
PeriodVolume: 798412
OpenInterest: 0

In certain cases, when you request historic data for multiple symbols, you might receive a different number of data bars for different symbols, depending on data availability. In such cases, the result will not be an N-by-M struct array, but a cell array (one cell for each symbol) that contains struct arrays. For example:

data =
1×3 cell array
{77×1 struct} {100×1 struct} {55×1 struct}

IQML queries for multiple symbols or dates (if BeginDate and EndDate are specified) can be parallelized using the UseParallel parameter, if you have a Professional IQML license and Matlab’s Parallel Computing Toolbox (§3.6):

>> data = IQML('history', 'UseParallel',true, 'symbol',symbols) %multi-symbols

>> data = IQML('history', 'UseParallel',true, 'symbol','IBM',...
'BeginDate',19900102, 'EndDate',20181028) %date range

By default, IQML reports 9 data fields for each daily history bar: Symbol, Datestamp, Datenum, High, Low, Open, Close, PeriodVolume, and OpenInterest. If the Fields parameter is set to an empty value ({} or ''), the current set of fields and the full list of available fields, are reported (in this case, a Symbol parameter is unnecessary):

>> data = IQML('history', 'fields',{})
data =
struct with fields:
CurrentFields: {1×9 cell}
AvailableFields: {1×9 cell}

>> data.AvailableFields
ans =
1×9 cell array
Columns 1 through 6
{'Symbol'} {'Datestamp'} {'Datenum'} {'High'} {'Low'} {'Open'}
Columns 7 through 9
{'Close'} {'PeriodVolume'} {'OpenInterest'}

If you have the Professional (or trial) IQML license, you can request IQML to report fewer data fields, and/or change the reported fields order, using the optional Fields parameter. Fields can be set to any subset of AvailableFields, as either a cell-array of strings, or as a comma-separated string. All subsequent daily history queries will report the requested fields, in the specified order, until Fields is changed again. For example:

>> data = IQML('history', 'Symbol','IBM', 'Fields',{'Datenum','Close'})
>> data = IQML(
'history', 'Symbol','IBM', 'Fields','Datenum,Close') %equivalent
data =
100×1 struct array with fields:
Datenum
Close

>> data(1)
ans =
struct with fields:
Datenum: 737751
Close: 134.34

The order of the specified Fields indicates the order in which the data fields will be reported. For example, to change the order of the reported data fields above:

>> data = IQML('history', 'Symbol', 'IBM', 'Fields','Close,Datenum ')
data =
100×1 struct array with fields:
Close
Datenum

As noted, Fields can be set to any subset of the AvailableFields. If a bad field is specified (one which is not available in IQFeed), an error message will be displayed:

>> data = IQML('history', 'Symbol','IBM', 'Fields','Close, xyz')

Error using IQML
Bad field 'xyz' was requested in IQML history command (check the spelling).
Available fields are: Symbol,Timestamp,Datenum,High,Low,Open,Close,...

As noted above, whenever we change the set of fields (or even just their order), this new set of fields is used in all subsequent daily history queries in the current Matlab session.

To revert the reported set of fields to the default set (AvailableFields), set Fields to 'All' (or 'all'):

>> data = IQML('history', 'Symbol','IBM', 'Fields','all')
data =
100×1 struct array with fields:
Symbol
Datestamp
Datenum
High
Low
Open
Close
PeriodVolume
OpenInterest

warningNote: there are several important differences between the Fields parameter in history queries and in quotes queries (§4.1):

The Symbol field is not mandatory in history queries, and does not necessarily need to be the first reported data field, unlike in quotes queries.

IQML reports all available history data fields by default. You can use the Fields parameter to reduce the reported data fields, even down to just a single data field. In contrast, quotes queries report only some of the available fields by default.

The fewer fields that you request, the faster the processing time and the smaller the memory usage. To improve run-time performance and reduce memory consumption, request only those data fields that are actually needed by your program.

The following parameters affect daily history data queries:

Parameter

Data type

Default

Description

Symbol or Symbols 72

colon or comma-delimited string or cell-array of strings

(none)

Limits query to specified symbol(s). Examples:

'@VX#'

'IBM:AAPL:GOOG'

'IBM,AAPL,GOOG'

{'IBM', 'AAPL', 'GOOG'}

This parameter must be set to valid symbol name(s). Multiple symbols can be parallelized using the UseParallel parameter (see below).

DataDirection

integer

1
meaning oldest first, newest last

Sets the order of data bars in the returned struct array. One of the following values:

1 means oldest-to-newest (default)

-1 means newest-to-oldest

MaxItems

integer

100

Report up to specified number of data bars (if available). -1 or inf mean all available.

BeginDate

integer or string or datetime object

'1900/01/01' (i.e., from as early as data is available)

Earliest bar date to report. Examples:

737089 (Matlab datenum format)

datetime('Jan 29, 2018')

20180129 (yyyymmdd format)

'20180129'

'2018/01/29'

'2018-01-29'

Note: if there are more data points than MaxItems between BeginDateEndDate, only the last MaxItems data points (from EndDate backward) will be returned, regardless of BeginDate.

EndDate

integer or string or datetime

'2099/12/31' (i.e., until now)

Latest bar date to report.

See BeginDate parameter above for details.

Timeout

number

5.0

Max # of seconds to wait for incoming data (0-9000, where 0 means infinite)

UseParallel

logical (true/false)

false

If set to true or 1, and if Parallel Computing Toolbox is installed, then querying multiple symbols or dates will be done in parallel (see §3.6; Professional IQML license only).

MaxWorkers

integer
(1-∞)

(the current parallel pool size, up to 15)

Maximal number of parallel workers to use (up to the current pool size) when UseParallel =true. Note: increased parallelization might cause IQFeed run-time throttling errors.

Fields

colon or comma-separated string, or cell-array of strings

'Symbol, Datestamp, Datenum, High, Low, Open, Close, PeriodVolume, OpenInterest'

Sets the list of data fields reported by IQML for each data bar, as a sub-set of IQFeed’s default set of 9 fields.

If Fields is set to an empty value ({} or ''), the list of current, available fields is returned.

If Fields is not empty, subsequent history queries in the same Matlab session will return the specified fields, in the specified order (Professional IQML license only).

Examples:

'Datestamp:Open:Close'

'Datestamp,Open,Close'

{'Datestamp', 'Open', 'Close'}

'All' (indicates all available fields)

Progress

string

''
(empty string)

When Progress is set to 'console', the data download progress is displayed in the console. See §5.4 for details.

5.2 Weekly data

To retrieve historic weekly data bars, set DataType to 'w' or 'week':

>> data = IQML('history', 'symbol','FB', 'dataType','week')
data =
100×1 struct array with fields:
Symbol
Datestamp
Datenum
High
Low
Open
Close
PeriodVolume
OpenInterest

As with the daily bars, we received an array of Matlab structs containing weekly bars, one per each of the last N weeks (excluding currently-trading day for IQFeed clients 6.0 or older; including the current day for 6.1 or newer). By default we receive up to N=100 data bars (~2 years), ordered from oldest to newest. We ran the query above on Tuesday March 6, 2018 using IQFeed client 5.2 so we received weekly data from Friday 2016-04-15 (the data bar for April 11-15, 2016) until 2018-03-05 (the data bar for Monday March 5, 2018 only, excluding March 6). Each bar’s Datestamp indicates the end-date of the bar. Note that all data bars except for the latest have a Friday date.

As with the daily bars, you can change the data bars order, using the DataDirection parameter (1 means oldest-to-newest (default); -1 means newest-to-oldest).

>> data = IQML('history', 'symbol','FB', 'dataType','week', 'dataDirection',-1);

As with the daily bars, you can ask IQFeed to limit the maximal number of data bars (N) using the MaxItems parameter:

>> data = IQML('history', 'symbol','FB', 'dataType','week', 'maxItems',20);

In this example, data(1).Datestamp='2017-10-27', i.e. the Friday 20 weeks ago.

As with the daily bars, you can set the Timeout parameter to a high value in order to allow IQML more time to gather data before returning the results. This is typically not necessary for weekly data requests, because of the relatively small amount of data.

You can also specify a BeginDate for the returned data. Dates can be specified in various formats: as a numeric Matlab datenum (737089), a Matlab datetime object, numeric yyyymmdd (20180129), or as a string ('2018/01/29', '2018-01-29', '20180129').73

For example, if we a query with a BeginDate of Monday Jan 29, 2018, we will receive data bars starting on Friday Feb 2, 2018 (which includes the weekly data of Jan 29):

>> data = IQML('history','symbol','FB','dataType','week','BeginDate',20180129);

warningNote: IQFeed clients 6.0 or earlier do not report a data bar for the currently-trading day; clients 6.1 or newer do report a data bar that includes the current trading day.

Also note that MaxItems has precedence over BeginDate, regardless of DataDirection. For example, if MaxItems=5, we’ll only get the 5 latest bars, even if there are more than 5 weeks between BeginDate and EndDate.

As with daily data requests, you can request historical data for multiple symbols at the same time, in a single IQML command, by specifying a colon-delimited or cell-array list of symbols. For example:

>> data = IQML('history', 'symbol',{'IBM','GOOG','AAPL'}, ...
'dataType','week', 'maxItems',20)

>> data = IQML('history', 'symbol','IBM:GOOG:AAPL', ...
'dataType','week', 'maxItems',20) %equivalent

The result will be an array of Matlab structs that correspond to the requested symbols (3 symbols with 20 data-points each, in this example):

data =
20×3 struct array with fields:
Symbol
Datestamp
...

In certain cases, when you request historic data for multiple symbols, you might receive a different number of data bars for different symbols, depending on data availability. In such cases, the result will not be an N-by-M struct array, but a cell array (one cell for each symbol) that contains struct arrays. For example:

data =
1×3 cell array
{77×1 struct} {100×1 struct} {55×1 struct}

IQML queries for multiple symbols can be parallelized using the UseParallel parameter, if you have a Professional IQML license and Matlab’s Parallel Computing Toolbox (§3.6):

>> data = IQML('history', 'symbol',symbols, 'UseParallel',true, ...
'dataType','week', 'maxItems',20)

By default, IQML reports 9 data fields for each weekly history bar: Symbol, Datestamp, Datenum, High, Low, Open, Close, PeriodVolume, and OpenInterest. If the Fields parameter is set to an empty value ({} or ''), the current set of fields and the full list of available fields, are reported (in this case, a Symbol parameter is unnecessary). If you have the Professional (or trial) IQML license, you can request IQML to report fewer data fields, and/or change the reported fields order, using the optional Fields parameter. All subsequent weekly history queries will report only the requested fields, in the specified order. Fewer fields mean faster processing time and smaller memory usage. Refer to §5.1 for a description of the Fields parameter usage.

The following parameters affect weekly history data queries:

Parameter

Data type

Default

Description

Symbol or Symbols 74

colon or comma-delimited string or cell-array of strings

(none)

Limits the query to the specified symbol(s). Examples:

'@VX#'

'IBM:AAPL:GOOG'

'IBM,AAPL,GOOG'

{'IBM', 'AAPL', 'GOOG'}

This parameter must be set to valid symbol name(s). Multiple symbols can be parallelized using the UseParallel parameter (see below).

DataDirection

integer

1
meaning oldest bar is first, newest is last

Sets the order of data bars in the returned struct array. One of the following values:

1 means oldest-to-newest (default)

-1 means newest-to-oldest

MaxItems

integer

100

Reports up to specified number of data bars (if available). -1 or inf mean all available.

BeginDate

integer or string or datetime object

'1900/01/01' (i.e., from as early as data is available)

Earliest bar to report. Examples:

737089 (Matlab datenum format)

datetime('Jan 29, 2018')

20180129 (yyyymmdd format)

'20180129'

'2018/01/29'

'2018-01-29'

Note: if there are more data points than MaxItems between BeginDate and EndDate, only the latest MaxItems data points (from EndDate backward) will be returned, regardless of BeginDate.

EndDate

integer or string or datetime

'2099/12/31' (i.e., until now)

Latest bar date to report.

See BeginDate parameter above for details.

Timeout

number

5.0

Max number of seconds to wait for incoming data (0-9000, where 0 means infinite)

UseParallel

logical (true/false)

false

If set to true or 1, and if Parallel Computing Toolbox is installed, then querying multiple symbols will be done in parallel (see §3.6; Professional IQML license only).

MaxWorkers

integer
(1-∞)

(the current parallel pool size, up to 15)

Max number of parallel workers to use (up to the current pool size) when UseParallel=1
Increased parallelization might cause errors.

Fields

colon or comma-separated string, or cell-array of strings

'Symbol, Datestamp, Datenum, High, Low, Open, Close, PeriodVolume, OpenInterest'

Sets the list of data fields reported by IQML for each data bar, as a sub-set of IQFeed’s default set of 9 fields.

If Fields is set to an empty value ({} or ''), the list of current, available fields is returned.

If Fields is not empty, subsequent history queries in the same Matlab session will return the specified fields, in the specified order (Professional IQML license only).

Examples:

'Datestamp:Open:Close'

'Datestamp,Open,Close'

{'Datestamp', 'Open', 'Close'}

'All' (indicates all available fields)

5.3 Monthly data

To retrieve historic monthly data bars, set DataType to 'm' or 'month':

>> data = IQML('history', 'symbol','FB', 'dataType','month')
data =
100×1 struct array with fields:
Symbol
Datestamp
Datenum
High
Low
Open
Close
PeriodVolume
OpenInterest

As with the daily bars, we received an array of Matlab structs containing monthly bars, one per each of the last N months (excluding currently-trading day for IQFeed clients 6.0 or older; including the current day for IQFeed clients 6.1 or newer). By default we receive up to N=100 data bars (~8 years), ordered from oldest to newest. We ran the example query above on March 6, 2018 using IQFeed client 5.2 so we received monthly data from 2009-12-31 (the data bar for 12/2009) until 2018-03-05 (the data bar for March 2018 up to March 5, 2018, excluding data from March 6).

As with the daily bars, you can change the data bars order, using the DataDirection parameter (1 means oldest-to-newest (default); -1 means newest-to-oldest).

>> data = IQML('history', 'symbol','FB', 'dataType','month', ...
'dataDirection',-1);

As with the daily bars, you can ask IQFeed to limit the maximal number of data bars (N) using the MaxItems parameter:

>> data = IQML('history', 'symbol','FB', 'dataType','month', 'maxItems',20);

In this example, data(1).Datestamp='2016-08-31', i.e. 20 months ago.

As with the daily bars, you can set the Timeout parameter to a high value in order to allow IQML more time to gather data before returning the results. This is typically not necessary for monthly data requests, because of the relatively small amount of data.

You can also specify a BeginDate for the returned data. Dates can be specified in various formats: as a numeric Matlab datenum (737089), a Matlab datetime object, numeric yyyymmdd (20180129), or as a string ('2018/01/29', '2018-01-29', '20180129').

For example, if we a query with a BeginDate of Jan 29, 2018, we will receive data bars starting on Jan 31, 2018 (which includes the monthly data of Jan 29):

>> data = IQML('history','symbol','FB','dataType','month','BeginDate',20180129);

warningNote: IQFeed clients 6.0 or earlier do not report a data bar for the currently-trading day; clients 6.1 or newer do report a data bar that includes the current trading day.

Also note that MaxItems has precedence over BeginDate, regardless of DataDirection. For example, if MaxItems=5, we’ll only get the 5 latest bars, even if there are more than 5 months between BeginDate and EndDate.75

As with daily data requests, you can request historical data for multiple symbols at the same time, in a single IQML command, by specifying a colon-delimited or cell-array list of symbols. For example:

>> data = IQML('history', 'symbol',{'IBM','GOOG','AAPL'}, ...
'dataType','month', 'maxItems',20)

>> data = IQML('history', 'symbol','IBM:GOOG:AAPL', ...
'dataType','month', 'maxItems',20) %equivalent

The result will be an array of Matlab structs that correspond to the requested symbols (3 symbols with 20 data-points each, in this example):

data =
20×3 struct array with fields:
Symbol
Datestamp
...

In certain cases, when you request historic data for multiple symbols, you might receive a different number of data bars for different symbols, depending on data availability. In such cases, the result will not be an N-by-M struct array, but a cell array (one cell for each symbol) that contains struct arrays. For example:

data =
1×3 cell array
{77×1 struct} {100×1 struct} {55×1 struct}

IQML queries for multiple symbols can be parallelized using the UseParallel parameter, if you have a Professional IQML license and Matlab’s Parallel Computing Toolbox (§3.6):

>> data = IQML('history', 'symbol',symbols, 'UseParallel',true, ...
'dataType','month', 'maxItems',20)

By default, IQML reports 9 data fields for each monthly history bar: Symbol, Datestamp, Datenum, High, Low, Open, Close, PeriodVolume, and OpenInterest. If the Fields parameter is set to an empty value ({} or ''), the current set of fields and the full list of available fields, are reported (in this case, a Symbol parameter is unnecessary). If you have the Professional (or trial) IQML license, you can request IQML to report fewer data fields, and/or change the reported fields order, using the optional Fields parameter. All subsequent monthly history queries will report only the requested fields, in the specified order. Fewer fields mean faster processing time and smaller memory usage. Refer to §5.1 for a description of the Fields parameter usage.

The following parameters affect monthly history data queries:

Parameter

Data type

Default

Description

Symbol or Symbols 76

colon or comma-delimited string or cell-array of strings

(none)

Limits the query to the specified symbol(s). Examples:

'@VX#'

'IBM:AAPL:GOOG'

'IBM,AAPL,GOOG'

{'IBM', 'AAPL', 'GOOG'}

This parameter must be set to valid symbol name(s). Multiple symbols can be parallelized using the UseParallel parameter (see below).

DataDirection

integer

1
meaning oldest bar is first, newest is last

Sets the order of data bars in the returned struct array. One of the following values:

1 means oldest-to-newest (default)

-1 means newest-to-oldest

MaxItems

integer

100

Returns up to the specified number of data bars (if available). -1 means all available.

BeginDate

integer or string or datetime object

'1900/01/01' (i.e., from as early as data is available)

Earliest bar that includes a date. Examples:

737089 (Matlab datenum format)

datetime('Jan 29, 2018')

20180129 (yyyymmdd format)

'20180129'

'2018/01/29'

'2018-01-29'

Note: if there are more data points than MaxItems between BeginDate and EndDate, only the last MaxItems data points (from EndDate backward) will be returned, regardless of BeginDate.

EndDate

integer or string or datetime

'2099/12/31' (i.e., until now)

Latest bar date to report.

See BeginDate parameter above for details.

Timeout

number

5.0

Max number of seconds to wait for incoming data (0-9000, where 0 means infinite)

UseParallel

logical (true/false)

false

If set to true or 1, and if Parallel Computing Toolbox is installed, then querying multiple symbols will be done in parallel (see §3.6; Professional IQML license only).

MaxWorkers

integer
(1-∞)

(the current parallel pool size, up to 15)

Max number of parallel workers to use (up to the current pool size) when UseParallel=1
Increased parallelization might cause errors.

Fields

colon or comma-separated string, or cell-array of strings

'Symbol, Datestamp, Datenum, High, Low, Open, Close, PeriodVolume, OpenInterest'

Sets the list of data fields reported by IQML for each data bar, as a sub-set of IQFeed’s default set of 9 fields.

If Fields is set to an empty value ({} or ''), the list of current, available fields is returned.

If Fields is not empty, subsequent history queries in the same Matlab session will return the specified fields, in the specified order (Professional IQML license only).

Examples:

'Datestamp:Open:Close'

'Datestamp,Open,Close'

{'Datestamp', 'Open', 'Close'}

'All' (indicates all available fields)

5.4 Interval data

To retrieve historic data bars having a custom width, possibly as short as a single second, set DataType to 'i' or 'interval', and set the asset’s Symbol:

>> data = IQML('history', 'symbol','FB', 'dataType','interval')
data =
100×1 struct array with fields:
Symbol
Timestamp
Datenum
High
Low
Open
Close
TotalVolume
PeriodVolume
NumberOfTrades

>> data(end)
ans =
Symbol: 'IBM'
Timestamp: '2018-03-07 09:43:00'
Datenum: 737126.404861111
High: 156.97
Low: 156.77
Open: 156.83
Close: 156.77
TotalVolume: 215082
PeriodVolume: 16080
NumberOfTrades: 0

The returned data struct here is similar to the struct returned by the daily, weekly and monthly historical data queries. Unlike those queries, interval-query result does not include an OpenInterest field, but does include two new fields: TotalVolume (which indicates the total daily volume up to that bar), and NumberOfTrades. Also note that we get a Timestamp field (US Eastern timezone), not Datestamp as with other history queries.

Bars that had no trading action are not reported. In the example query above, we see the following Timestamp values, where we clearly see a gap during non-trading hours:

>> {data.Timestamp}'
ans =
100×1 cell array
{'2018-03-06 14:59:00'}
{'2018-03-06 15:00:00'}
{'2018-03-06 15:01:00'}
...
% contiguous data bars
{'2018-03-06 15:59:00'}
{'2018-03-06 16:00:00'}
{'2018-03-06 16:03:00'}
{'2018-03-06 16:11:00'}
...
{'2018-03-07 08:45:00'}
{'2018-03-07 09:22:00'}
{'2018-03-07 09:31:00'}
{'2018-03-07 09:32:00'}
...
% contiguous data bars
{'2018-03-07 09:43:00'}
{'2018-03-07 09:44:00'}

As with the other queries, the current (partial) interval bar is never reported, nor bars that have no data (e.g., 16:04-16:10, 8:34-8:44, 8:46-9:21 in the example above).

The default interval size is 60 secs (aligned on the full-minute mark). You can specify different interval sizes using the IntervalSize parameter. For example, a 15-sec interval:

>> data=IQML('history','symbol','FB','dataType','interval','intervalSize',15);

IQFeed is smart enough to automatically align data bars to full minutes/hours when the requested IntervalSize enables this (as is the case for 15 or 60-sec intervals). For example, with 15-sec IntervalSize we may get bars for 10:04:30, 10:04:45, 10:05:00. When such alignment is not possible, you will get non-aligned bars. For example, with a 13-sec IntervalSize: 09:59:18, 09:59:31, 09:59:57, 10:00:10.

By default, IntervalSize specifies the interval’s size in seconds and all the bars have this same duration. You can change this by setting the IntervalType parameter (default: 'secs') to 'volume' or 'ticks'/'trades'. Naturally, if you change IntervalType, the data bars will now have non-equal durations.

>> data = IQML('history', 'symbol','FB', 'dataType','interval', ...
'intervalType','ticks');

The IntervalType (default: 'secs') and IntervalSize (default: 60) parameters should typically be specified together. Note that IntervalSize must be a positive integer value (i.e. its value cannot be 4.5 or 0). If IntervalType is 'ticks'/'trades', IntervalSize must be 2 or higher; If IntervalType is 'volume', IntervalSize must be 100 or higher; If IntervalType is 'secs', IntervalSize must be between 1 and 86400 (1 day).77

By default, IQML reports data in intervals whose labels are set at the end of the interval. For example, a data item at 11:12:34 with IntervalSize=60 (1 minute) will be included in the interval labeled ‘11:13:00’. You can modify this default behavior by setting the LabelAtBeginning parameter to 1 (or true), so that the labels are set at the beginning. In this example, the data item will be reported in the ‘11:12:00’ interval. Note: using LabelAtBeginning parameter requires IQFeed client version 6.0 or newer.

warningBy default, IQML only reports interval data from today. This means that if you run a query during the weekend, you will not see any data:78

>> data = IQML('history', 'symbol','FB', 'dataType','interval')
data =
1×0 empty double row vector

You can ask to see additional (older) calendar days by specifying a positive Days parameter value. If you set Days to -1, then all available information will be reported, subject to the other filter criteria.

Similarly, you can specify a date/time window for the returned data: only bars between the specified BeginDateTime and EndDateTime (US Eastern time) will be reported, regardless of the value of the Days parameter.

Note: queries having UseParallel=true are only parallelized if BeginDateTime is specified, or if multiple Symbols are specified (see below). Single-Symbol queries that have an empty (unspecified) BeginDateTime are not parallelizable.

In addition, you can specify a daily time-window: only bars between BeginFilterTime and EndFilterTime in each day (US Eastern time-zone) will be reported. This could be useful, for example, to limit the results only to the regular trading hours.

As with the daily bars, you can change the data bars order, using the DataDirection parameter (1 means oldest-to-newest (default); -1 means newest-to-oldest).

>> data=IQML('history','symbol','FB','dataType','interval','dataDirection',-1);

As with the daily bars, you can ask IQFeed to limit the maximal number of data bars (N) using the MaxItems parameter:

>> data = IQML('history', 'symbol','FB', 'dataType','interval', 'maxItems',20);

Note that MaxItems takes precedence over BeginDateTime, regardless of DataDirection. For example, if MaxItems=5, you will only get the 5 latest bars (before EndDateTime), regardless of the specified BeginDateTime.

As with the daily bars, you can set the Timeout parameter to a high value in order to allow IQML more time to gather data before returning the results (or set to -1 to disable the timeout entirely). This is especially important for historic interval and ticks data queries, since they could return a huge number of data points, which can take a lot of time to download and process.

In addition to Timeout, for long queries it is advisable to set the Progress parameter to 'console', in order to display a periodic progress update message in the console every 1000 data points (every ~1-2 secs), as well as at the end of the query:

>> data = IQML('history', 'symbol','IBM', 'dataType','interval', ...
'IntervalType','ticks', 'IntervalSize',10, ...
'BeginDateTime','20200623 100000', ...
'EndDateTime', '20200623 160000', ...
'MaxItems',-1, 'timeout',-1, 'progress','console');

1000 history data points processed for IBM. Latest: 2020-06-23 13:30:42 ...
2000 history data points processed for IBM. Latest: 2020-06-23 15:34:06 ...
2460 history data points processed for IBM. Latest: 2020-06-23 15:59:59

As with daily data requests, you can request historical data for multiple symbols at the same time, in a single IQML command, by specifying a colon-delimited or cell-array list of symbols. For example:

>> data = IQML('history', 'symbol',{'IBM','GOOG','AAPL'}, ...
'dataType','interval', 'maxItems',20)

>> data = IQML('history', 'symbol','IBM:GOOG:AAPL', ...
'dataType','interval', 'maxItems',20) %equivalent

The result will be an array of Matlab structs that correspond to the requested symbols (3 symbols with 20 data-points each, in this example):

data =
20×3 struct array with fields:
Symbol
Datestamp
...

In certain cases, when you request historic data for multiple symbols, you might receive a different number of data bars for different symbols, depending on data availability. In such cases, the result will not be an N-by-M struct array, but a cell array (one cell for each symbol) that contains struct arrays. For example:

data =
1×3 cell array
{77×1 struct} {100×1 struct} {55×1 struct}

IQML queries for multiple symbols or a date/time range (i.e., if BeginDateTime is specified) can be parallelized using the UseParallel parameter, if you have a Professional IQML license and Matlab’s Parallel Computing Toolbox (see §3.6):

>> data = IQML('history', 'dataType','interval', 'UseParallel',true, ...
'symbol',symbols) % multiple symbols parallelized

>> data = IQML('history', 'dataType','interval', 'UseParallel',true, ...
'symbol','IBM' ,... % single-symbol date-range parallelized
'BeginDateTime',20181026100000, ...
'EndDateTime', 20181026110000)

In some cases, users may be tempted to use the historical data mechanism to retrieve real-time data. This is relatively easy to set-up. For example, using an endless Matlab loop that sleeps for 60 seconds, requests the latest historical data for the past minute and then goes to sleep again, or using a periodic timer object that wakes up every minute. In such cases, consider using streaming rather than historical queries (see §6).

Some software vendors make a distinction between intra-day and historical information. However, as far as IQFeed and IQML are concerned, this is merely a semantic difference and there is no practical difference.

Note: IQFeed limits interval data to the past 180 calendar days if you make the request outside trading hours, but just past 8 days for requests during US trading hours (9:30-16:30 US Eastern time, Mon-Fri). So, if you request month-old data during trading hours you will get empty results, even if the request was just for a single hour.79

The only exception to the 8/180-day limitation are interval bars of full minutes (IntervalType='secs' and IntervalSize a multiple of 60), since these bars are pre-computed and have a lesser impact on IQFeed’s servers. The other interval types are computed on-the-fly from tick data, and so are limited in duration in order not to overload IQFeed’s servers, especially during trading hours when server load is high.

IQFeed imposes other limitations based on interval size: minute data is only available since 2005-2007;80 longer intervals (daily/weekly/monthly) can access up to 15+ years.81

IQFeed subscriptions for daily and intra-day data are different. If you only subscribed for daily data, you will receive a run-time error when fetching intra-day interval data:

IQML historic data query (EURGBP.FXCM) error: Unauthorized user ID (your IQFeed account is not authorized for this data)

Also note that IQFeed’s interval data typically exclude irregular “O” trades (see §5.5).

By default, IQML reports 10 data fields for each interval bar: Symbol, Timestamp, Datenum, High, Low, Open, Close, TotalVolume, PeriodVolume, and NumberOfTrades. If the Fields parameter is set to an empty value ({} or ''), the current set of fields and the full list of available fields, are reported (in this case, a Symbol parameter is unnecessary). If you have the Professional (or trial) IQML license, you can request IQML to report fewer data fields, and/or change the reported fields order, using the optional Fields parameter. All subsequent interval history queries will report only the requested fields, in the specified order. Fewer fields mean faster processing time and smaller memory usage. Refer to §5.1 for a description of the Fields parameter usage.

Finally, note that whereas sub-daily data may report data from non-trading days (e.g., Sunday night, when ES starts trading), these are typically added to the following trading day’s bar with daily/weekly/monthly bars.82

The following parameters affect interval history data queries:

Parameter

Data type

Default

Description

Symbol or Symbols 83

colon or comma-delimited string or cell-array of strings

(none)

Limits the query to the specified symbol(s). Examples:

'@VX#'

'IBM:AAPL:GOOG'

'IBM,AAPL,GOOG'

{'IBM', 'AAPL', 'GOOG'}

This parameter must be set to valid symbol name(s). Multiple symbols can be parallelized using the UseParallel parameter (see below).

DataDirection

integer

1, meaning oldest bar is first, newest is last

Sets the order of data bars in the returned struct array. One of the following values:

1 means oldest-to-newest (default)

-1 means newest-to-oldest

LabelAtBeginning

logical (true/false)

false

0: data at 11:17:41 is reported as ‘11:18’

1: same data is reported as ‘11:17’

MaxItems

integer

100

Returns up to the specified number of data bars (if available). -1 means all available.

Days

integer

1
meaning today only

Number of preceding calendar days to process. -1 means unlimited (all available data, subject to the other criteria), 1 means today, 2 means today & yesterday, etc.

IntervalType

string

'secs'

Sets the type of interval size. One of the following values:

's' or 'secs' – time [seconds] (default)

'v' or 'volume' – traded volume

't', 'trades' or 'ticks' – number of ticks

IntervalSize

integer

60

Size of bars in IntervalType units. Must be ≥1 for secs, ≥2 for ticks, ≥100 for volume bars

BeginFilterTime

string

'00:00:00'

Only return bars that begin after this time of day (US Eastern time-zone). Only relevant when Days>0 or BeginDateTime is not ''.
Format: hhmm, hh:mm, hhmmss or hh:mm:ss

EndFilterTime

string

'23:59:59'

Only return bars that end before this time of day (US Eastern time-zone). Only relevant when Days>0 or BeginDateTime is not ''.
Format: hhmm, hh:mm, hhmmss or hh:mm:ss

BeginDateTime

integer or string or datetime object

''
(empty string) meaning from as early as data is available

Only return bars that begin after this date/time (US Eastern time-zone).
Overrides the Days parameter.
Format: Matlab datenum, or 'yyyymmdd hhmmss', or 'yyyy-mm-dd hh:mm:ss' etc.

Note: MaxItems has precedence over BeginDateTime: If there are more data points than MaxItems between Begin/ EndDateTime, only the last MaxItems data points (from EndDateTime backward) are returned, regardless of BeginDateTime.

EndDateTime

integer or string or datetime object

''
(empty string) meaning now

Only return bars that end before this date/time (US Eastern time-zone).
Overrides the Days parameter.
Format: Matlab datenum, or 'yyyymmdd hhmmss', or 'yyyy-mm-dd hh:mm:ss' etc.

Timeout

number

5.0

Max number of seconds to wait for incoming data (0-9000, where 0 means infinite)

UseParallel

logical (true/false)

false

If true or 1, and Parallel Computing Toolbox is installed, then querying multiple symbols or a date/time range will be done in parallel (see §3.6; Professional IQML license only).

MaxWorkers

integer
(1-∞)

(the current parallel pool size, up to 15)

Maximal number of parallel workers to use (up to the current pool size) when UseParallel =true. Note: increased parallelization might cause IQFeed run-time throttling errors.

Fields

colon or comma-separated string, or cell-array of strings

'Symbol, Timestamp, Datenum, High, Low, Open, Close, TotalVolume, PeriodVolume NumberOfTrades'

Sets the list of data fields reported by IQML for each data bar, as a sub-set of IQFeed’s default set of 10 fields.

If Fields is set to an empty value ({} or ''), the list of current, available fields is returned.

If Fields is not empty, subsequent history queries in the same Matlab session will return the specified fields, in the specified order (Professional IQML license only).

Examples:

'Timestamp:Open:Close'

'Timestamp,Open,Close'

{'Timestamp', 'Open', 'Close'}

'All' (indicates all available fields)

Progress

string

''
(empty string)

When Progress is set to 'console', the download progress is displayed in the console.

5.5 Tick data

Unlike data bars, which aggregate ticks and provide summary information, it is also possible to retrieve historic individual trades (“ticks”). To retrieve this data, set DataType to 't' or 'ticks', and set the asset’s Symbol:

>> data = IQML('history', 'symbol','AAPL', 'dataType','ticks')
data =
100×1 struct array with fields:
Symbol
Timestamp
Datenum
Last
LastSize
TotalVolume
Bid
Ask
TickID
BasisForLast
TradeMarketCenter
TradeConditions
TradeAggressorCode
DayOfMonth
BasisDescription
TradeMarketName
TradeDescription
AggressorDescription

>> data(end)
ans =
Symbol: 'AAPL'
Timestamp: '2019-10-04 09:45:03.862626'
Datenum: 737702.406294699
Last: 224.67
LastSize: 100
TotalVolume: 5226196
Bid: 224.66
Ask: 224.68
TickID: 7432
BasisForLast: 'C'
TradeMarketCenter: 19
TradeConditions: '01'
TradeAggressorCode: 0
DayOfMonth: 4
BasisDescription: 'Last qualified trade'
TradeMarketName: 'Nasdaq Trade Reporting Facility (NTRF)'
TradeDescription: 'Normal Trade'
AggressorDescription: 'Unknown/unsupported'

The data struct here is quite different than the historical bar queries above. Notice the Timestamp field, specified in micro-second precision (US Eastern time-zone). See a discussion of the time resolution in the next page. The DayOfMonth, TradeAggressorCode and AggressorDescription fields only appear if you use IQFeed client 6.1 or newer.

Note that the textual Description fields depend on the MsgParsingLevel parameter having a value of 2 or higher (see §3.2 and §8)

Also note that only trade ticks are provided, along with the Bid and Ask prices at the time of the trade. IQFeed does not report historic non-trading ticks (i.e., Bid/Ask changes that occurred between the trades).

The Last and LastSize fields typically refer to the last trade. The type (“basis”) of data in these fields is determined according to the BasisForLast field, which is explained in the BasisDescription field for convenience.84 Possible basis values are:85

C – Last qualified trade (during regular trading hours).

E – Extended trade = form T trade (outside regular trading hours).

O – Other trade = any trade not accounted for by C or E.

S – Settle = daily settle (only applicable to commodities).

In general, algo-trading should rely only on “C” trades, and possibly also “E” trades. “O” trades often have wide price swings (i.e. large variation from mainstream trading prices); this adds noise to charts and may confuse data analytics.86 IQFeed’s interval data (§5.4) typically exclude such irregular “O” trades.

Note that the difference between TotalVolume values from one tick to the next does not always equal LastSize, since some trade types (e.g. implied and block trades) are not reported with a separate tick, but are included in the next tick’s TotalVolume.87

Also note that TickID values are not always increasing, and almost never contiguous. They are generally provided by the exchange as unique trade identifiers and so should not be used as an indicator of missing data, and their order is not quarantined. Instead, it is better to rely on the Timestamp or Datenum fields.

In some cases, implied (rather than normal trade) ticks are reported. For example, the following tick was retrieved for the VIX index continuous future (@VX#):

>> data = IQML('history', 'symbol','@VX#', 'dataType','ticks');
>> data(1)
ans =
Symbol: '@VX#'
Timestamp: '2019-10-04 09:42:41.499000'
Datenum: 737702.404646979
Last: 18.68
LastSize: 1
TotalVolume: 16711
Bid: 18.65
Ask: 18.7
TickID: 6118279
BasisForLast: 'O'
TradeMarketCenter: 32
TradeConditions: '4D'
TradeAggressorCode: 0
DayOfMonth: 4
BasisDescription: 'Other trade = any trade not accounted for by C or E'
TradeMarketName: 'CBOE Futures Exchange (CFE)'
TradeDescription: 'Implied'
AggressorDescription: 'Unknown/unsupported'

Note that in the case of @VX# on CBOE, the ticks are only reported in millisecond resolution, not microseconds as for IBM. In this case, Timestamp still shows 6 digits after the seconds decimal, but they always end in 000 (…:57.899000). The actual time resolution of reported ticks depends on the specific exchange and security type.88

warningBy default, IQML only reports ticks data from today. This means that if you run a query during the weekend or any other non-trading day, you will not see any data:89

>> data = IQML('history', 'symbol','FB', 'dataType','ticks')
data =
1×0 empty double row vector

You can ask to see additional (older) calendar days by specifying a positive Days parameter value. If you set Days to -1, then all available information will be reported, subject to the other filter criteria.

Similarly, you can specify a date/time window for the returned data: only bars between the specified BeginDateTime and EndDateTime (both of them US Eastern time-zone) will be reported, regardless of the value of the Days parameter.

Note: queries having UseParallel=true are only parallelized if BeginDateTime is specified, or if multiple Symbols are specified (see below). Single-Symbol queries that have an empty (unspecified) BeginDateTime are not parallelizable.

In addition, you can specify a daily time-window: only ticks between BeginFilterTime and EndFilterTime in each day (US Eastern time-zone) will be reported. This could be useful, for example, to limit the results only to the regular trading hours.

You can also limit the maximal number of ticks using the MaxItems parameter.

Note: by default IQFeed limits ticks data to the past 180 calendar days if you make the request outside trading hours, but just past 8 days for requests during US trading hours (9:30-16:30 US Eastern time).90 This means that if during trading hours you request historic data from a month ago, you will get none (empty results), even if the request was just for a single hour of data.91

You can change the order of the reported ticks, using the DataDirection parameter (1 means oldest-to-newest (default); -1 means newest-to-oldest). MaxItems has precedence over BeginDateTime, regardless of DataDirection. For example, if MaxItems=5, we’ll only get the 5 latest ticks (before EndDateTime), regardless of BeginDateTime.

As with daily data requests, you can request data for multiple symbols at the same time, in a single IQML command by specifying a colon-delimited or cell-array list of Symbols:

>> data = IQML('history', 'symbol',{'IBM','GOOG','AAPL'}, ...
'dataType','ticks', 'maxItems',20)

>> data = IQML('history', 'symbol','IBM:GOOG:AAPL', ...
'dataType','ticks', 'maxItems',20) %equivalent

The result will be an array of Matlab structs that correspond to the requested symbols (3 symbols with 20 data-points each, in this example):

data =
20×3 struct array with fields:
Symbol
Datestamp
...

In certain cases, when you request historic data for multiple symbols, you might receive a different number of data bars for different symbols, depending on data availability. In such cases, the result will not be an N-by-M struct array, but a cell array (one cell for each symbol) that contains struct arrays. For example:

data =
1×3 cell array
{77×1 struct} {100×1 struct} {55×1 struct}

IQML queries for multiple symbols or a date/time range (i.e., if BeginDateTime is specified) can be parallelized using the UseParallel parameter, if you have a Professional IQML license and Matlab’s Parallel Computing Toolbox (see §3.6):

>> data = IQML('history', 'dataType','ticks', 'UseParallel',true, ...
'symbol',symbols) % multiple symbols parallelized

>> data = IQML('history', 'dataType','ticks', 'UseParallel',true, ...
'symbol','IBM' ,... % single-symbol date-range parallelized
'BeginDateTime',20181026100000, ...
'EndDateTime', 20181026110000)

By default, IQML reports 18 data fields for each tick: Symbol, Timestamp, Datenum, Last, LastSize, TotalVolume, Bid, Ask, TickID, BasisForLast, TradeMarketCenter, TradeConditions, TradeAggressorCode, DayOfMonth, BasisDescription, TradeMarketName, TradeDescription, and AggressorDescription.92 If the Fields parameter is set to an empty value ({} or ''), the current set of fields and the full list of available fields, are reported (in this case, a Symbol parameter is unnecessary). If you have the Professional (or trial) IQML license, you can request IQML to report fewer data fields, and/or change the reported fields order, using the optional Fields parameter. All subsequent tick history queries will report only the requested fields, in the specified order. Fewer fields mean faster processing time and smaller memory usage. Refer to §5.1 for a description of the Fields parameter usage.

Finally, as with other IQML commands, you can set the Timeout parameter to a high value in order to allow IQML more time to gather data before returning the results (or set to -1 to disable the timeout entirely). This is especially important for historic interval and ticks data queries, since they could return a huge number of data points, which can take a lot of time to download and process.

In addition to Timeout, for long queries it is advisable to set the Progress parameter to 'console', in order to display a periodic progress update message in the console every 1000 data points (every ~1-2 secs), as well as at the end of the query:

>> data = IQML('history', 'symbol','IBM', 'dataType','ticks', ...
'BeginDateTime','20200623 150000', ...
'EndDateTime', '20200623 152000', ...
'MaxItems',-1, 'timeout',-1, 'progress','console');

1000 history data points processed for IBM. Latest: 2020-06-23 15:05:06.665127...
2000 history data points processed for IBM. Latest: 2020-06-23 15:11:43.512718...
3000 history data points processed for IBM. Latest: 2020-06-23 15:16:47.954088...
3489 history data points processed for IBM. Latest: 2020-06-23 15:20:00.076970

The following parameters affect ticks history data queries:

Parameter

Data type

Default

Description

Symbol or Symbols 93

colon or comma-delimited string or cell-array of strings

(none)

Limits the query to the specified symbol(s). Examples:

'@VX#'

'IBM:AAPL:GOOG'

'IBM,AAPL,GOOG'

{'IBM', 'AAPL', 'GOOG'}

This parameter must be set to valid symbol name(s). Multiple symbols can be parallelized using the UseParallel parameter (see below).

DataDirection

integer

1
meaning oldest tick is first, newest last

Sets the order of ticks in the returned struct array. One of the following values:

1 means oldest-to-newest (default)

-1 means newest-to-oldest

MaxItems

integer

100

Returns up to the specified number of ticks (if available). -1 means all available.

Days

integer

1
meaning today only

Number of preceding calendar days to process. -1 means unlimited (all available data, subject to the other criteria), 1 means today, 2 means today & yesterday, etc.

BeginFilterTime

string

'00:00:00'

Only return ticks that begin after this time of day (US Eastern). Only relevant when Days>0 or BeginDateTime is not ''. Format: ‘hhmm’, ‘hh:mm’, ‘hhmmss’ or ‘hh:mm:ss’.

EndFilterTime

string

'23:59:59'

Only return ticks that end before this time of day (US Eastern). Only relevant when Days>0 or BeginDateTime is not ''. Format: ‘hhmm’, ‘hh:mm’, ‘hhmmss’ or ‘hh:mm:ss’.

BeginDateTime

integer or string or datetime object

''
(empty string) meaning from as early as data is available

Only return ticks that begin after this date/time (US Eastern time-zone).

Overrides the Days parameter.

Format: Matlab datenum, or 'yyyymmdd hhmmss', or 'yyyy-mm-dd hh:mm:ss' etc.

Note: MaxItems has precedence over BeginDateTime: If there are more data points than MaxItems between BeginDateTime and EndDateTime, only the last MaxItems data points (from EndDateTime backward) will be returned, regardless of BeginDateTime.

EndDateTime

integer or string or datetime object

''
(empty string) meaning now

Only return ticks that end before this date/time (US Eastern time-zone)

Overrides the Days parameter.

Format: Matlab datenum, or 'yyyymmdd hhmmss', or 'yyyy-mm-dd hh:mm:ss' etc.

Timeout

number

5.0

Max number of seconds to wait for incoming data (0-9000, where 0 means infinite)

UseParallel

logical (true/false)

false

If set to true or 1, and if Parallel Computing Toolbox is installed, then querying multiple symbols or a date/time range will be done in parallel (see §3.6; Professional IQML license only).

MaxWorkers

integer
(1-∞)

(the current parallel pool size, up to 15)

Maximal number of parallel workers to use (up to the current pool size) when UseParallel =true. Note: increased parallelization might cause IQFeed run-time throttling errors.

Fields

colon or comma-separated string, or cell-array of strings

'Symbol, Timestamp, Datenum, Last, LastSize, TotalVolume, Bid, Ask, TickID, BasisForLast, TradeMarketCenter, TradeConditions, TradeAggressorCode, DayOfMonth, BasisDescription, TradeMarketName, TradeDescription, AggressorDescription'

Sets the list of data fields reported by IQML for each data bar, as a sub-set of IQFeed’s default set of 18 fields.

If Fields is set to an empty value ({} or ''), the list of current, available fields is returned.

If Fields is not empty, subsequent history queries in the same Matlab session will return the specified fields, in the specified order (Professional IQML license only).

Examples:

'Timestamp:Bid:Ask'

'Timestamp,Bid,Ask '

{'Timestamp', 'Bid', 'Ask'}

'All' (indicates all available fields)

Progress

string

''
(empty string)

When Progress is set to 'console', the data download progress is periodically displayed in the console.

5.6 Market summary data and scanner

All the queries described so far in this chapter return historic data for individually-specified Symbols. We can retrieve historic end-of-day market state (quotes/trades and fundamental data) of all traded securities as-of a single historic date (May 20, 2018 or later), using a 'summary' query (see §4.6) with a non-default Date parameter:

>> data = IQML('summary', 'Date',20190110) %all NYSE equities on Jan 10, 2019
data =
4706×1 struct array with fields:
Symbol
Exchange
Type
Last
...
(total of 28 data fields)

>> data(1)
ans =
struct with fields:
Symbol: 'A'
Exchange: 7
Type: 1
Last: 69.9
TradeSize: 3350
TradedMarket: 7
TradeDate: 20190110
TradeTime: 180131
Open: 69.05
High: 69.95
Low: 68.6
Close: 69.25
Bid: 50
BidMarket: 11
BidSize: 400
Ask: 69.9
AskMarket: 11
AskSize: 100
Volume: 1080882
PDayVolume: 2442291
UpVolume: 413506
DownVolume: 231604
NeutralVolume: 435772
TradeCount: 10340
UpTrades: 3070
DownTrades: 2819
NeutralTrades: 4447
VWAP: 69.5782

This query shows that 4706 equities were traded on NYSE on Jan 10, 2019. The data may change over time, as DTN retroactively fixes its historic records.

The default DataType parameter value ('snapshot') fetches end-of-day trading data. To fetch end-of-day fundamental data, set DataType='fundamental':94

>> data = IQML('summary', 'Date',20190110, 'DataType','fundamental');

Note that there is no Symbol parameter in a 'summary' query – data for all the symbols that match the specified SecType (default: 'equity'), Exchange (default: 'NYSE') and/or Date (default: now/latest) is returned. For historic snapshot trading data of specific symbols, use one of the other query types (§5.1-§5.5). Unfortunately, there is no corresponding alternative for historic fundamental data of specific symbols.

We can filter the returned data for various criteria using the Filter parameter (see §4.6), effectively serving as a market scanner for the requested historic date.

Using end-of-day historic summary query enables fetching the data for securities that are no longer traded (expired contacts95 and delisted equities96). Fetching historic data for such non-trading symbols using any other query type is not possible.

Note: Market summary is only available with IQFeed client 6.1 or newer, and only if you are subscribed to the requested DTN data, and only if IQFeed has relevant history data (data is only available for trading days since May 20, 2018, and only for some SecType/ Exchange combinations). Otherwise, you may receive an error such as one of these:

The 'summary' query is only supported by IQFeed client 6.1 or newer; you are using version 6.0.

IQFeed market summary query error: Code: 50004 - User not authorized for market summary file requested.

IQFeed market summary query error: Code: 50007 - No file available for NASDAQ on 2020-11-29 (possibly a non-trading day; try a different Date).

The following parameters affect historic market summary queries (see §4.6 for details):

Parameter

Data type

Default

Description

DataType

string

'snapshot'

Either 'snapshot' or 'fundamental' (not 'top')

Exchange

string

'NYSE'

One of the markets listed in §8.3

SecType

string

'Equity'

One of the security types listed in §8.4

Date

integer or string or datetime object

now

(latest available data)

Date for which to fetch the end-of-day data (May 20, 2018 or later). Examples:

737454 (Matlab datenum format)

datetime('Jan 29, 2019')

20190129 (yyyymmdd format)

'20190129'

'2019/01/29'

'2019-01-29'

ReportEmptyFields

logical

false or 0

If true, then irrelevant data fields (which contain empty [] values for all securities) are reported; if false (default), they are not

Filter

string or cell-array of strings

{}

Zero or more filter criteria (condition strings) – Matlab expression(s) involving the reported data fields, which result in a logical (true/false) value. Examples:

'MaturityDate > 20241231'

'MarketCap > 5000 & PeRatio < 9'

{'MarketCap > 5000', 'Beta >= 1.2'}

Timeout

number

300

Max number of seconds to wait for incoming data (0-9000, where 0 means infinite)

warningNote: market summary functionality is only available in the Professional IQML license


69 http://iqfeed.net/dev/api/docs/HistoricalviaTCPIP.cfm

70 For example, IQFeed’s trial account is limited to 1-year of daily data points; IQFeed automatically trims trial-account queries down to this limit: http://forums.dtn.com/index.cfm?page=topic&topicID=5535

71 Note: Regular IQFeed accounts have access to 15+ years of daily data, but IQFeed limits its trial account to just 365 days of historical daily data – see https://help.dtniq.com/support-faqs

72 In IQML, the Symbol and Symbols parameters are synonymous – you can use either of them, in any capitalization

73 Note: Regular IQFeed accounts can access 15+ years of historic data, but IQFeed limits trial accounts to just one year – see https://help.dtniq.com/support-faqs. Also note that in some cases, depending on current day-of-week compared to the requested BeginDate, an addidional (older) bar might be returned that includes the week that was prior to the requested BeginDate.

74 In IQML, the Symbol and Symbols parameters are synonymous – you can use either of them, in any capitalization

75 Note: Regular IQFeed accounts can access 15+ years of historic data, but IQFeed limits trial accounts to just one year – see https://help.dtniq.com/support-faqs

76 In IQML, the Symbol and Symbols parameters are synonymous – you can use either of them, in any capitalization

77 Note that IQFeed’s limitations on live 'secs' interval bars (§4.3, §6.3) are stricter than the limitations on historical interval bars: http://forums.dtn.com/index.cfm?page=topic&topicID=5529

78 IQML versions up to 2.42 reported a NO_DATA error in such cases; IQML returns [] without an error in version 2.43 or newer.

79 The above is true for IQFeed regular accounts; IQFeed trial accounts are limited to only 4 days of intraday data and just one year of daily data (see https://help.dtniq.com/support-faqs)

80 Specifically for minute (60 sec) intervals, IQFeed’s developer FAQ indicates that “Minute interval data dating back to mid 2005 for select contracts and mid 2007 for all others [is available]”.

81 Again, these values are for regular IQFeed accounts; IQFeed limits trial accounts (see note #79 above)

82 http://forums.dtn.com/index.cfm?page=topic&topicID=5608

83 In IQML, the Symbol and Symbols parameters are synonymous – you can use either of them, in any capitalization

84 Note that the textual Description fields depend on the MsgParsingLevel parameter having a value of 2 or higher (see §3.2)

85 Other tick types (basis codes) are NOT reported by IQFeed: http://forums.dtn.com/index.cfm?page=topic&topicID=5783 (these other tick types are usually rare). Additional tick types may possibly be added by IQFeed in the future.

86 http://forums.iqfeed.net/index.cfm?page=topic&topicID=3898

87 http://forums.dtn.com/index.cfm?page=topic&topicID=5855

88 Micro-second resolution is only available with IQFeed client 5.2 or newer, and only in certain setups (e.g. CMEGroup and equity markets). Contact IQFeed support if you are unsure about the resolution provided by a certain setup configuration.

89 IQML versions up to 2.42 reported a NO_DATA error in such cases; IQML returns [] without an error in version 2.43 or newer.

90 Historic ticks older than 180 days can be purchased from DTN http://forums.iqfeed.net/index.cfm?page=topic&topicID=4376

91 This is true for regular IQFeed accounts; IQFeed trials are limited to 4 days of intraday data (https://help.dtniq.com/support-faqs)

92 The textual fields BasisDescription, TradeMarketName, TradeDescription and AgressorDescription are IQML-generated textual interpretations of the codes in the IQFeed-generated BasisForLast, TradeMarketCenter, TradeConditions and TradeAggressorCode fields respectively, as governed by the MsgParsingLevel parameter (see §3.2)

93 In IQML, the Symbol and Symbols parameters are synonymous – you can use either of them, in any capitalization

94 Note that we only receive 4705 securities in the fundamental query compared to 4706 securities for the snapshot query (ASXw has snapshot data but no fundamentals) this is an IQFeed data error. NYSE bonds on the same date show a similar phenomemon: three symbols (CVS.24.CB, DUK.46B.CB, TXT27.CB) have snapshot data but no fundamentals. All these are IQFeed data errors.

95 A [huge] static text file containing a [very long] list of expired option symbols is available for download from DTN’s website (http://www.iqfeed.net/downloads/beta/IEOPTION.zip; see http://forums.iqfeed.net/index.cfm?page=topic&topicID=3326 for details). Note that this file is not actively maintained, so it is better to use the API functionality via IQML.

96 A static text file containing a list of delisted ticker symbols is available for download from DTN’s website (http://www.iqfeed.net/downloads/beta/EQUITY.zip; see http://forums.iqfeed.net/index.cfm?page=topic&topicID=5822 for details). Note that this file is not actively maintained, so it is better to use the API functionality via IQML.