Documentation

history

IQFEED asynchronous historical end-of-period data

Syntax

  • history(c,s,interval) example
  • history(c,s,interval,period) example
  • history(c,s,interval,period,listener,eventhandler) example
  • history(c,s,{startdate,enddate}) example
  • history(c,s,{startdate,enddate},[],listener,eventhandler) example

Description

example

history(c,s,interval) returns asynchronous historical end-of-period data using the connection object c, a single security s, and a specified interval interval.

example

history(c,s,interval,period) returns asynchronous historical end-of-period data for a single security with a specified interval and period period.

example

history(c,s,interval,period,listener,eventhandler) returns asynchronous historical end-of-period data for a single security with a specified interval, period, socket listener listener, and event handler eventhandler.

example

history(c,s,{startdate,enddate}) returns asynchronous historical end-of-period data for a single security with a date range.

example

history(c,s,{startdate,enddate},[],listener,eventhandler) returns asynchronous historical end-of-period data for a single security with a date range, a specified socket listener listener, and event handler eventhandler.

Examples

expand all

Retrieve Daily Data

Create the IQFEED® connection with user name username and password pwd.

c = iqf('username','pwd');

Retrieve the Google® security data for the last five days.

history(c,'GOOG',5)

history returns the data in the MATLAB® cell array IQFeedHistoryData.

Display the returned data in IQFeedHistoryData.

IQFeedHistoryData
IQFeedHistoryData = 

    '2013-11-21 11:08:58'    '1038.31'    '1026.00'    '1027.00'    '1034.07'    '1092497'    '0'
    '2013-11-20 11:08:58'    '1033.36'    '1020.36'    '1029.95'    '1022.31'    '965535'     '0'
    '2013-11-19 11:08:58'    '1034.75'    '1023.05'    '1031.72'    '1025.20'    '1131619'    '0'
    '2013-11-18 11:08:58'    '1048.74'    '1029.24'    '1035.75'    '1031.55'    '1760249'    '0'
    '2013-11-15 11:08:58'    '1038.00'    '1030.31'    '1034.87'    '1033.56'    '1277772'    '0'

Each row of data represents one day. The columns in IQFeedHistoryData contain the following:

  • Date and time

  • High price

  • Low price

  • Open price

  • Closing price

  • Volume

  • Open interest

Close the IQFEED connection.

close(c)

Retrieve Weekly Data

Create the IQFEED connection with user name username and password pwd.

c = iqf('username','pwd');

Retrieve the Google security data for the last five weeks.

history(c,'GOOG',5,'Weekly')

history returns the data in the MATLAB cell array IQFeedHistoryData.

Display the returned data in IQFeedHistoryData.

IQFeedHistoryData
IQFeedHistoryData = 

    '2013-11-21 11:07:02'    '1048.74'    '1020.36'    '1035.75'    '1034.07'    '4949900'     '0'
    '2013-11-15 11:07:02'    '1039.75'    '1005.00'    '1009.51'    '1033.56'    '6361983'     '0'
    '2013-11-08 11:07:02'    '1032.37'    '1007.64'    '1031.50'    '1016.03'    '6209876'     '0'
    '2013-11-01 11:07:02'    '1041.52'    '1012.98'    '1015.20'    '1027.04'    '7025769'     '0'
    '2013-10-25 11:07:02'    '1040.57'    '995.79'     '1011.46'    '1015.20'    '12636223'    '0'

Each row of data represents the last day of a week. The first row contains data for the last business day in the current week. The columns in IQFeedHistoryData contain the following:

  • Date and time

  • High price

  • Low price

  • Open price

  • Closing price

  • Volume

  • Open interest

Close the IQFEED connection.

close(c)

Retrieve Monthly Data with Event Handlers

Create the IQFEED connection with user name username and password pwd.

c = iqf('username','pwd');

Retrieve the Google security data for the last five months. Use the event handler functions iqhistoryfeedlistener and iqhistoryfeedeventhandler to listen for the Google security and parse the resulting data.

history(c,'GOOG',5,'Monthly',@iqhistoryfeedlistener,...
        @iqhistoryfeedeventhandler)

history returns the data in the MATLAB cell array IQFeedHistoryData.

Display the returned data in IQFeedHistoryData.

IQFeedHistoryData
IQFeedHistoryData = 

    '2013-11-21 11:13:07'    '1048.74'    '1005.00'    '1031.79'    '1034.07'    '18805697'    '0'
    '2013-10-31 11:13:07'    '1041.52'    '842.98'     '880.25'     '1030.58'    '55288774'    '0'
    '2013-09-30 11:13:07'    '905.99'     '853.95'     '854.36'     '875.91'     '33147210'    '0'
    '2013-08-30 11:13:07'    '909.71'     '845.56'     '895.00'     '846.90'     '33509358'    '0'
    '2013-07-31 11:13:07'    '928.00'     '875.61'     '886.45'     '887.75'     '51277966'    '0'

Each row of data represents the last day of a month. The first row contains data for the last business day in the current month. The columns in IQFeedHistoryData contain the following:

  • Date and time

  • High price

  • Low price

  • Open price

  • Closing price

  • Volume

  • Open interest

Close the IQFEED connection.

close(c)

Retrieve Data for a Date Range

Create the IQFEED connection with user name username and password pwd.

c = iqf('username','pwd');

Retrieve IBM® security data for the last five days.

history(c,'IBM',{floor(now-5),floor(now)})

history returns the data in the MATLAB cell array IQFeedHistoryData.

Display the returned data in IQFeedHistoryData.

IQFeedHistoryData
IQFeedHistoryData = 

    '2013-11-21 10:59:51'    '185.7500'    '183.4110'    '185.5400'    '184.1300'    '4459451'    '0'
    '2013-11-20 10:59:51'    '186.2400'    '184.6450'    '185.2200'    '185.1900'    '3646117'    '0'
    '2013-11-19 10:59:51'    '186.2000'    '184.1500'    '184.6300'    '185.2500'    '4577037'    '0'
    '2013-11-18 10:59:51'    '184.9900'    '183.2700'    '183.5200'    '184.4700'    '5344864'    '0'

Each row of data represents one day. Since this example is run on a Friday, the return data has only four days. The columns in IQFeedHistoryData contain the following:

  • Date and time

  • High price

  • Low price

  • Open price

  • Closing price

  • Volume

  • Open interest

Close the IQFEED connection.

close(c)

Retrieve Data for a Date Range with Event Handlers

Create the IQFEED connection with user name username and password pwd.

c = iqf('username','pwd');

Retrieve the Google security data for the last five days. Use the event handler functions iqhistoryfeedlistener and iqhistoryfeedeventhandler to listen for the Google security and parse the resulting data. The period [] specifies the default period for daily data.

history(c,'GOOG',{floor(now-5),floor(now)},[],...
        @iqhistoryfeedlistener,@iqhistoryfeedeventhandler)

history returns the data in the MATLAB cell array IQFeedHistoryData.

Display the returned data in IQFeedHistoryData.

IQFeedHistoryData
IQFeedHistoryData = 

    '2013-11-21 11:12:15'    '1038.31'    '1026.00'    '1027.00'    '1034.07'    '1092497'    '0'
    '2013-11-20 11:12:15'    '1033.36'    '1020.36'    '1029.95'    '1022.31'    '965535'     '0'
    '2013-11-19 11:12:15'    '1034.75'    '1023.05'    '1031.72'    '1025.20'    '1131619'    '0'
    '2013-11-18 11:12:15'    '1048.74'    '1029.24'    '1035.75'    '1031.55'    '1760249'    '0'

Each row of data represents one day. Since this example is run on a Friday, the return data has only four days. The columns in IQFeedHistoryData contain the following:

  • Date and time

  • High price

  • Low price

  • Open price

  • Closing price

  • Volume

  • Open interest

Close the IQFEED connection.

close(c)

Input Arguments

expand all

c — IQFEED connectionconnection object

IQFEED connection, specified as a connection object created using iqf.

s — Securitystring

Security, specified as a string for a single security.

Example: 'IBM'

Data Types: char

interval — Time intervalscalar

Time interval, specified as a scalar to denote the number of days of data to return.

Data Types: double

period — Period'Daily' (default) | 'Weekly' | 'Monthly'

Period, specified as one of the above enumerated strings to denote daily, weekly, or monthly return data. When this argument is specified along with interval, history returns the number of daily, weekly, or monthly data where the number of output rows corresponds to the interval. When this argument is omitted by specifying [], history returns daily data.

Data Types: char

listener — Listener event handlerfunction

Listener event handler, specified as a function to listen for the IQFEED data. You can modify the existing listener function or define your own. You can find the code for the existing listener function in the history.m file.

Data Types: function_handle

eventhandler — Event handlerfunction

Event handler, specified as a function to process the IQFEED data. The existing event handler displays the IQFEED data in the MATLAB Command Window. You can modify the existing event handler function or define your own. You can find the code for the existing event handler function in the history.m file.

Data Types: function_handle

startdate — Start datescalar | string

Start date, specified as a scalar or string to denote the start date of the date range for the returned data.

Example: floor(now-1)

Data Types: double | char

enddate — End datescalar | string

End date, specified as a scalar or string to denote the end date of the date range for the returned data.

Example: floor(now)

Data Types: double | char

More About

expand all

Tips

  • When you make multiple requests with multiple messages, this error might occur:

    Warning: Error occurred while executing delegate callback: Message: The IAsyncResult object was not returned from the corresponding asynchronous method on this class.

    To fix this, restart MATLAB.

Was this topic helpful?