Documentation

This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English verison of the page.

Note: This page has been translated by MathWorks. Please click here
To view all translated materals including this page, select Japan from the country navigator on the bottom of this page.

Retrieve Intraday and Historical Data Using IQFEED

This example shows how to connect to IQFEED® and retrieve intraday and historical data.

Connect to IQFEED

The following code assumes you are connecting to IQFEED using the user name username and password pwd.

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

Retrieve Intraday Data

Retrieve today’s intraday data for IBM®.

sec = 'IBM';
fromdate = now-0.05; % beginning of date range for intraday data 
                     % (approximately one hour ago)
todate = now; % ending of date range for intraday data (current time today)

timeseries(c,sec,{fromdate,todate})

timeseries creates the workspace variable IQFeedTimeseriesData and populates it with the intraday data. sec contains the IQFEED security name for IBM.

Display the first three rows of intraday data.

IQFeedTimeseriesData(1:3,:)
ans = 

    '2013-12-19 10:09:15'    '179.5750'    '100'     '1155752'    '179.5700'    '179.6100'    '219184'    '0'    '0'    'C'
    '2013-12-19 10:09:15'    '179.5700'    '100'     '1155652'    '179.5700'    '179.6100'    '219177'    '0'    '0'    'C'
    '2013-12-19 10:09:15'    '179.5844'    '1345'    '1155552'    '179.5700'    '179.6100'    '219176'    '0'    '0'    'C'

The columns in IQFeedTimeseriesData are:

  • Timestamp.

  • Last price.

  • Last size.

  • Total volume.

  • Bid price.

  • Ask price.

  • Tick identifier.

  • The last column is the basis for last trade.

The remaining two columns are reserved for later use by the IQFEED API.

Close the IQFEED connection.

close(c)

Retrieve Historical Data

Connect to IQFEED.

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

Retrieve the last five weeks of historical data for IBM.

interval = 5; % number of weeks to return data
period = 'Weekly'; % retrieve weekly data

history(c,sec,interval,period)

history creates the workspace variable IQFeedHistoryData and populates it with the historical data.

Display the first three rows of historical weekly data.

IQFeedHistoryData(1:3,:)
ans = 

    '2013-12-18 10:11:32'    '178.7400'    '172.7300'    '173.2200'    '178.7000'    '18695843'    '0'
    '2013-12-13 10:11:32'    '178.1520'    '172.7300'    '177.9900'    '172.8000'    '21871929'    '0'
    '2013-12-06 10:11:32'    '179.5900'    '175.1600'    '179.4600'    '177.6700'    '24819146'    '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)

See Also

| | |

Was this topic helpful?