history(c,s,startdate,enddate,period)
requests CQG® historical data asynchronously with bar size period
between startdate and enddate for CQG instrument name s with CQG connection c.
To request daily historical data for an instrument, create the
connection c using cqg and
startUp. Register an event handler for tracking events
associated with connection status. Set up the API configuration properties. Then,
register an event handler for tracking events associated with building and
initializing the output data structure. For an example demonstrating these
activities, see Request CQG Historical Data. See
CQG API Reference Guide to learn more about event handlers
and the API configuration properties.
Request historical daily data for instrument XYZ.XYZ for the
last 10 days. XYZ.XYZ is a sample instrument name. To request
historical data for your instrument, substitute the symbol name in
instrument.
Each row in cqgHistoryData represents data for 1 day. The
columns in cqgHistoryData show the numerical representation of
the timestamp, the close price, and the open price for the instrument during the
day.
Close the CQG connection.
close(c)
Request CQG Historical Data with Additional Request Properties
To request daily historical data for an instrument with an
additional property, create the connection c using
cqg and startUp. Register an event handler
for tracking events associated with connection status. Set up the API configuration
properties. Then, register an event handler for tracking events associated with
building and initializing the output data structure. For an example demonstrating
these activities, see Request CQG Historical Data. See
CQG API Reference Guide to learn more about event handlers
and the API configuration properties.
Pass an additional optional request property by creating the structure
x and setting the optional property.
x.UpdatesEnabled = false;
For additional optional properties you can set, see CQG API Reference Guide.
Request historical daily data for instrument XYZ.XYZ for the
last 10 days using the additional optional request property x.
XYZ.XYZ is a sample instrument name. To request historical
data for your instrument, substitute the symbol name in
instrument.
Each row in cqgHistoryData represents data for 1 day. The
columns in cqgHistoryData show the numerical representation of
the timestamp, the close price, and the open price for the instrument during the
day.
CQG connection, specified as a CQG connection object
created using cqg.
s — CQG instrument name character vector | string scalar
CQG instrument name, specified as a character vector or string scalar that
identifies the instrument or security. For a list of CQG instrument names, see Tradable
Symbols.
Data Types: char | string
startdate — Start date character vector | string scalar | numeric scalar
Start date, specified as a character vector, string scalar, or numeric scalar.
Data Types: double | char | string
enddate — End date character vector | string scalar | numeric scalar
End date, specified as a character vector, string scalar, or numeric scalar.
Data Types: double | char | string
period — Bar size 'hpDaily' (default) | 'hpWeekly' | 'hpMonthly' | 'hpQuarterly' | 'hpSemiannual' | 'hpYearly'
Bar size, specified as one of the above values predetermined by the CQG API that denotes the length of time to collect data.
x — CQG request properties request properties structure
CQG request properties, specified as a CQG request
properties structure. Create this structure by writing MATLAB code
to set additional optional request properties. For additional optional
properties you can set, see CQG API Reference Guide.
You can also select a web site from the following list:
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.