Documentation Center

  • Trial Software
  • Product Updates

X_TRADER Price Update

This example shows how to connect to X_TRADER® and listen for price update event data.

Connect to X_TRADER.

X = xtrdr;

Create an event notifier.

The event notifier is the X_TRADER mechanism that lets you define MATLAB® functions to use as callbacks for specific events.

createNotifier(X);

Create an instrument.

Create an instrument and attach it to the notifier.

createInstrument(X,'Exchange','CME','Product','2F',...
                'ProdType','Future','Contract','Aug13',...
                'Alias','PriceInstrument1');
X.InstrNotify(1).AttachInstrument(X.Instrument(1));

Define events.

Assign callbacks for validating or invalidating an instrument, and for handling data updates for a previously validated instrument.

X.InstrNotify(1).registerevent({'OnNotifyFound',...
                      @(varargin)ttinstrumentfound(varargin{:})});
X.InstrNotify(1).registerevent({'OnNotifyNotFound',...
                      @(varargin)ttinstrumentnotfound(varargin{:})});
X.InstrNotify(1).registerevent({'OnNotifyUpdate',...
                      @(varargin)ttinstrumentupdate(varargin{:})});

Monitor events.

Set the update filter to monitor the desired fields. In this example, events are monitored for updates to last price, last quantity, previous last quantity, and a change in prices. Listen for this event data.

X.InstrNotify(1).UpdateFilter = 'Last$,LastQty$,~LastQty$,Change$';
X.Instrument(1).Open(0);

The last command tells X_TRADER to start monitoring the attached instruments using the specified event settings.

Close the connection.

close(X)

See Also

| | |

Related Examples

More About

Was this topic helpful?