Documentation

realtime

Subscribe toCQGinstrument

Syntax

Description

example

realtime(c,s)subscribes to a CQG®instrumentsusing CQG connectionc.

Examples

collapse all

To subscribe to the CQG instrument and get current data, 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 instrument subscription. For an example demonstrating these activities, seeRequest CQG Real-Time Data. SeeCQG API Reference Guideto learn more about event handlers and the API configuration properties.

With the connection established, subscribe to the instrument. The instrument name must be formatted in the CQG long symbol view. For example, to subscribe to a security tied to corn, type the following.

instrument =“F.US.EZC”; realtime(c,instrument)

MATLAB®writes the structure variablecqgDataEZCto the Workspace browser.

DisplaycqgDataEZC.

cqgDataEZC(1,1)
ans = Price: {15x1 cell} Volume: {15x1 cell} ServerTimestamp: {15x1 cell} Timestamp: {15x1 cell} Type: {15x1 cell} Name: {15x1 cell} IsValid: {15x1 cell} Instrument: {15x1 cell} HasVolume: {15x1 cell}

cqgDataEZCreturns the current quotes for the security.

Display data in thePriceproperty ofcqgDataEZC.

cqgDataEZC(1,1).Price
ans = [-2.1475e+09] [-2.1475e+09] [-2.1475e+09] [ 660.5000] [] [] [-2.1475e+09] [-2.1475e+09] [-2.1475e+09] [-2.1475e+09] [-2.1475e+09] [-2.1475e+09] [-2.1475e+09] [ 660.5000] [-2.1475e+09]

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, seeTradable Symbols.

Data Types:char|string

Introduced in R2013b