主要内容

历史

RequestCQG.historical data

Description

example

历史(c,s,startdate,enddate,period)请求CQG.®historical data asynchronously with bar sizeperiodbetweenstartdateenddatefor CQG instrument nameswith CQG connectionc

example

历史(c,s,startdate,enddate,period,x)以附加请求属性异步请求CQG历史数据x

Examples

collapse all

To request daily historical data for an instrument, create the connectioncusingCQG.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, seeRequest CQG Historical Data。看到CQG.API参考指南to learn more about event handlers and the API configuration properties.

Request historical daily data for instrumentXYZ.XYZ在过去的10天。XYZ.XYZis a sample instrument name. To request historical data for your instrument, substitute the symbol name ininstrument

instrument = {'Close(XYZ.XYZ)','Open(XYZ.XYZ)'};startdate =楼层(现在) -  10;enddate =地板(现在);期间='hpDaily';历史(c,instrument,startdate,enddate,period) pause(1)

MATLAB®写变量cqghistorydata.to the Workspace browser.

Displaycqghistorydata.

cqghistorydata.
cqghistorydata.= 1.0e+05 * 7.3533 0.0063 0.0063 7.3533 0.0064 0.0064 7.3533 0.0065 0.0065 7.3534 0.0065 0.0065 7.3534 0.0066 0.0066 7.3534 0.0065 0.0065 7.3534 0.0066 0.0066 7.3534 0.0066 0.0066 7.3534 0.0064 0.0064

Each row incqghistorydata.represents data for 1 day. The columns incqghistorydata.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)

To request daily historical data for an instrument with an additional property, create the connectioncusingCQG.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, seeRequest CQG Historical Data。看到CQG.API参考指南to learn more about event handlers and the API configuration properties.

Pass an additional optional request property by creating the structurex和setting the optional property.

x.UpdatesEnabled = false;

For additional optional properties you can set, seeCQG.API参考指南

Request historical daily data for instrumentXYZ.XYZ使用其他可选请求属性的最后10天xXYZ.XYZis a sample instrument name. To request historical data for your instrument, substitute the symbol name ininstrument

instrument = {'Close(XYZ.XYZ)','Open(XYZ.XYZ)'};startdate =楼层(现在) -  10;enddate =地板(现在);期间='hpDaily';历史(c,internager,startdate,enddate,期间,x)暂停(1)

MATLAB writes the variablecqghistorydata.to the Workspace browser.

Displaycqghistorydata.

cqghistorydata.
cqghistorydata.= 1.0e+05 * 7.3533 0.0063 0.0063 7.3533 0.0064 0.0064 7.3533 0.0065 0.0065 7.3534 0.0065 0.0065 7.3534 0.0066 0.0066 7.3534 0.0065 0.0065 7.3534 0.0066 0.0066 7.3534 0.0066 0.0066 7.3534 0.0064 0.0064

Each row incqghistorydata.represents data for 1 day. The columns incqghistorydata.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)

Input Arguments

collapse all

CQG.connection, specified as a CQG connection object created usingCQG.

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可口符号

Data Types:char|string

Start date, specified as a character vector, string scalar, or numeric scalar.

Data Types:double|char|string

End date, specified as a character vector, string scalar, or numeric scalar.

Data Types:double|char|string

酒吧尺寸, specified as one of the above values predetermined by the CQG API that denotes the length of time to collect data.

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, seeCQG.API参考指南

Example:x.UpdatesEnabled = false;

Data Types:struct

介绍在R2013B.