To request intraday tick data for an instrument, create the connectioncusingcqgandstartUp. 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 Intraday Tick Data. SeeCQG API Reference Guideto learn more about event handlers and the API configuration properties.
Request intraday tick data for instrumentXYZ.XYZfor the last 2 days.XYZ.XYZis a sample instrument name. To request intraday tick data for your instrument, substitute the symbol name ininstrument.
仪器='XYZ.XYZ'; startdate = now - 2; enddate = now; timeseries(c,instrument,startdate,enddate)
MATLAB®writes the structure variablecqgTickDatato the Workspace browser.
cqgTickDatareturns intraday tick data for the specified instrument.
Display the data in theTimestampproperty ofcqgTickData.
cqgTickData.Timestamp
ans = '4/17/2013 2:14:00 PM' '4/18/2013 2:14:00 PM'
Close the CQG connection.
close(c)
RequestCQGIntraday Tick Data with Additional Properties
To request intraday tick data for an instrument with an additional property, create the connectioncusingcqgandstartUp. 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 Intraday Tick Data. SeeCQG API Reference Guideto learn more about event handlers and the API configuration properties.
Pass an additional optional request property by creating the structurex, and setting the optional property. To see only bid tick data, for example, setTickFilterto'tfBid'.
x.TickFilter ='tfBid';
TickFilterandSessionsFilter是唯一有效的额外可选properties for callingtimeserieswithout a timed bar request. For additional property values you can set, seeCQG API Reference Guide.
Request intraday tick data for instrumentXYZ.XYZfor the last 2 days using the additional optional request propertyx.XYZ.XYZis a sample instrument name. To request intraday tick data for your instrument, substitute the symbol name ininstrument.
仪器='XYZ.XYZ'; startdate = now - 2; enddate = now; timeseries(c,instrument,startdate,enddate,[],x)
MATLAB writes the variablecqgTickDatato the Workspace browser.
cqgTickDatareturns intraday tick data for the specified instrument.
Display the data in theTimestampproperty ofcqgTickData.
cqgTickData.Timestamp
ans = '4/17/2013 2:14:00 PM' '4/18/2013 2:14:00 PM'
Close the CQG connection.
close(c)
RequestCQGTimed Bar Data
To request timed bar data for an instrument, create the connectioncusingcqgandstartUp. 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 Intraday Tick Data. SeeCQG API Reference Guideto learn more about event handlers and the API configuration properties.
Request timed bar data for instrumentXYZ.XYZfor the last fraction of a day.XYZ.XYZis a sample instrument name. To request timed bar data for your instrument, substitute the symbol name ininstrument.
cqgTimedBarDatareturns timed bar data for the specified instrument. The columns ofcqgTimedBarDatadisplay data corresponding to the timestamp, open price, high price, low price, close price, mid-price, HLC3, average price, and tick volume.
Close the CQG connection.
close(c)
RequestCQGTimed Bar Data with Additional Properties
To request timed bar data for an instrument with an additional property, create the connectioncusingcqgandstartUp. 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 Intraday Tick Data. SeeCQG API Reference Guideto learn more about event handlers and the API configuration properties.
Pass an additional optional request property by creating the structurex, and setting the optional property.
x.UpdatesEnabled = false;
For additional optional properties you can set, seeCQG API Reference Guide.
Request timed bar data for instrumentXYZ.XYZfor the last fraction of a day using the additional optional request propertyx.XYZ.XYZis a sample instrument name. To request timed bar data for your instrument, substitute the symbol name ininstrument.
cqgTimedBarDatareturns timed bar data for the specified instrument. The columns ofcqgTimedBarDatadisplay data corresponding to the timestamp, open price, high price, low price, close price, mid-price, HLC3, average price, and tick volume.
CQG connection, specified as a CQG connection object created usingcqg.
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, seeTradable 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:双|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:双|char|string
intraday—Aggregated bar value numeric scalar|[]
Aggregated bar value, specified as a numeric scalar from 1.0 to 1440.0. If you want to calltimeseriesto return intraday tick data with additional properties without timed bar data, then enter[]for this argument.
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 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.