Main Content

timeseries

Request CQG intraday tick data

Description

example

timeseries(c,s,startdate,enddate) requests CQG® raw intraday tick data asynchronously between startdate and enddate for CQG instrument name s with CQG connection c.

example

timeseries(c,s,startdate,enddate,[],x) requests CQG raw intraday tick data asynchronously without timed bar data using additional request properties x.

example

timeseries(c,s,startdate,enddate,intraday) requests CQG timed bar data asynchronously with the aggregated bar value intraday.

example

timeseries(c,s,startdate,enddate,intraday,x) requests CQG timed bar data asynchronously with additional request properties x.

Examples

collapse all

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)

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)

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)

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

collapse all

CQG connection, specified as a CQG connection object created using cqg.

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

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

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

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