timeseries
Request CQG intraday tick data
Syntax
Description
Examples
Request CQG Intraday Tick Data
To request intraday tick 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 Intraday Tick Data. See
CQG API Reference Guide to learn more about event
handlers and the API configuration properties.
Request intraday tick data for instrument XYZ.XYZ
for
the last 2 days. XYZ.XYZ
is a sample instrument name. To
request intraday tick data for your instrument, substitute the symbol name
in instrument
.
instrument = 'XYZ.XYZ';
startdate = now - 2;
enddate = now;
timeseries(c,instrument,startdate,enddate)
MATLAB® writes the structure variable cqgTickData
to the Workspace browser.
Display cqgTickData
.
cqgTickData
cqgTickData = Timestamp: {2x1 cell} Price: [2x1 double] Volume: [2x1 double] PriceType: {2x1 cell} CorrectionType: {2x1 cell} SalesConditionLabel: {2x1 cell} SalesConditionCode: [2x1 double] ContributorId: {2x1 cell} ContributorIdCode: [2x1 double] MarketState: {2x1 cell}
cqgTickData
returns intraday tick data for the
specified instrument.
Display the data in the Timestamp
property of
cqgTickData
.
cqgTickData.Timestamp
ans = '4/17/2013 2:14:00 PM' '4/18/2013 2:14:00 PM'
Close the CQG connection.
close(c)
Request CQG Intraday Tick Data with Additional Properties
To request intraday tick 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 Intraday Tick 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. To see only bid
tick data, for example, set TickFilter
to
'tfBid'
.
x.TickFilter = 'tfBid';
TickFilter
and SessionsFilter
are
the only valid additional optional properties for calling
timeseries
without a timed bar request. For
additional property values you can set, see CQG API Reference Guide.
Request intraday tick data for instrument XYZ.XYZ
for
the last 2 days using the additional optional request property
x
. XYZ.XYZ
is a sample instrument
name. To request intraday tick data for your instrument, substitute the
symbol name in instrument
.
instrument = 'XYZ.XYZ';
startdate = now - 2;
enddate = now;
timeseries(c,instrument,startdate,enddate,[],x)
MATLAB writes the variable cqgTickData
to the
Workspace browser.
Display cqgTickData
.
cqgTickData
cqgTickData = Timestamp: {2x1 cell} Price: [2x1 double] Volume: [2x1 double] PriceType: {2x1 cell} CorrectionType: {2x1 cell} SalesConditionLabel: {2x1 cell} SalesConditionCode: [2x1 double] ContributorId: {2x1 cell} ContributorIdCode: [2x1 double] MarketState: {2x1 cell}
cqgTickData
returns intraday tick data for the
specified instrument.
Display the data in the Timestamp
property of
cqgTickData
.
cqgTickData.Timestamp
ans = '4/17/2013 2:14:00 PM' '4/18/2013 2:14:00 PM'
Close the CQG connection.
close(c)
Request CQG Timed Bar Data
To request timed bar 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 Intraday Tick Data. See
CQG API Reference Guide to learn more about event
handlers and the API configuration properties.
Request timed bar data for instrument XYZ.XYZ
for the
last fraction of a day. XYZ.XYZ
is a sample instrument
name. To request timed bar data for your instrument, substitute the symbol
name in instrument
.
instrument = 'XYZ.XYZ';
startdate = now - .1;
enddate = now;
intraday = 1;
timeseries(c,instrument,startdate,enddate,intraday)
MATLAB writes variable cqgTimedBarData
to the
Workspace browser.
Display cqgTimedBarData
.
cqgTimedBarData
cqgTimedBarData = 1.0e+09 * 0.0007 -2.1475 -2.1475 -2.1475 -2.1475 -2.1475 -2.1475 -2.1475 -2.1475 0.0007 -2.1475 -2.1475 -2.1475 -2.1475 -2.1475 -2.1475 -2.1475 -2.1475 0.0007 -2.1475 -2.1475 -2.1475 -2.1475 -2.1475 -2.1475 -2.1475 -2.1475 0.0007 -2.1475 -2.1475 -2.1475 -2.1475 -2.1475 -2.1475 -2.1475 -2.1475 0.0007 -2.1475 -2.1475 -2.1475 -2.1475 -2.1475 -2.1475 -2.1475 -2.1475 ...
cqgTimedBarData
returns timed bar data for the
specified instrument. The columns of cqgTimedBarData
display 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)
Request CQG Timed Bar Data with Additional Properties
To request timed bar 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 Intraday Tick 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 timed bar data for instrument XYZ.XYZ
for the
last fraction of a day using the additional optional request property
x
. XYZ.XYZ
is a sample instrument
name. To request timed bar data for your instrument, substitute the symbol
name in instrument
.
instrument = 'XYZ.XYZ';
startdate = now - .1;
enddate = now;
intraday = 1;
timeseries(c,instrument,startdate,enddate,intraday,x)
MATLAB writes the variable cqgTimedBarData
to the
Workspace browser.
Display cqgTimedBarData
.
cqgTimedBarData
cqgTimedBarData = 1.0e+09 * 0.0007 -2.1475 -2.1475 -2.1475 -2.1475 -2.1475 -2.1475 -2.1475 -2.1475 0.0007 -2.1475 -2.1475 -2.1475 -2.1475 -2.1475 -2.1475 -2.1475 -2.1475 0.0007 -2.1475 -2.1475 -2.1475 -2.1475 -2.1475 -2.1475 -2.1475 -2.1475 0.0007 -2.1475 -2.1475 -2.1475 -2.1475 -2.1475 -2.1475 -2.1475 -2.1475 0.0007 -2.1475 -2.1475 -2.1475 -2.1475 -2.1475 -2.1475 -2.1475 -2.1475 ...
cqgTimedBarData
returns timed bar data for the
specified instrument. The columns of cqgTimedBarData
display 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)
Input Arguments
c
— CQG connection
connection object
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
intraday
— Aggregated bar value
numeric scalar | []
Aggregated bar value, specified as a numeric scalar from 1.0 to 1440.0. If
you want to call timeseries
to return intraday tick data
with additional properties without timed bar data, then enter
[]
for this argument.
Data Types: double
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.
Example: x.UpdatesEnabled = false;
Data Types: struct
Version History
Introduced in R2013b
Commande MATLAB
Vous avez cliqué sur un lien qui correspond à cette commande MATLAB :
Pour exécuter la commande, saisissez-la dans la fenêtre de commande de MATLAB. Les navigateurs web ne supportent pas les commandes MATLAB.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
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.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)