X_Trader Price Update example

This example show how to set up a listener and callback for a change in price. Note that X_Trader is a 32-bit application and will only work with 32-bit Windows installations of MATLAB.

Contents

Start or connect to XTrader

x = xtrdr
x = xtrdr处理属性:门:(1x1 COM.Xtapi_TTGate_1] InstrNotify: [] Instrument: [] OrderSet: []

Available methods

methods(x)
Methods for class xtrdr: addlistener eq le close findobj lt createInstrument findprop ne createNotifier ge notify createOrderProfile getData xtrdr createOrderSet gt delete isvalid

Available properties

属性(x)
Properties for class xtrdr: Gate InstrNotify Instrument OrderSet

Create event notifier

x.createNotifier

Create an instruments

x.createInstrument('Exchange','TTSIM-G','Product','IPE e-Brent',...'ProdType','Future','Contract','Oct12','Alias','Demo6a_PriceUdate')

Attach instruments to a notifier

x.InstrNotify(1).AttachInstrument(x.Instrument(1))

Define events

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

Set the update filter to monitor only desired fields

x.InstrNotify(1).UpdateFilter ='Last$,LastQty$,~LastQty$,Change$';

Listen for event data

x.Instrument(1).Open(0)

Display prices for 10 seconds, then shut down

pause(10) disp('Shutting down communications to X_Trader.') close(x)
Exchange: TTSIM-G, Product: IPE e-Brent, ProdType: FUTURE, Contract: IPE e-Brent Oct12 Last: 113.88, LastQty: 1 Exchange: TTSIM-G, Product: IPE e-Brent, ProdType: FUTURE, Contract: IPE e-Brent Oct12 Last: 113.89, LastQty: 1 Exchange: TTSIM-G, Product: IPE e-Brent, ProdType: FUTURE, Contract: IPE e-Brent Oct12 Last: 113.87, LastQty: 1 Exchange: TTSIM-G, Product: IPE e-Brent, ProdType: FUTURE, Contract: IPE e-Brent Oct12 Last: 113.88, LastQty: 1 Exchange: TTSIM-G, Product: IPE e-Brent, ProdType: FUTURE, Contract: IPE e-Brent Oct12 Last: 113.89, LastQty: 1 Exchange: TTSIM-G, Product: IPE e-Brent, ProdType: FUTURE, Contract: IPE e-Brent Oct12 Last: 113.87, LastQty: 1 Exchange: TTSIM-G, Product: IPE e-Brent, ProdType: FUTURE, Contract: IPE e-Brent Oct12 Last: 113.87, LastQty: 2 Exchange: TTSIM-G, Product: IPE e-Brent, ProdType: FUTURE, Contract: IPE e-Brent Oct12 Last: 113.86, LastQty: 2 Exchange: TTSIM-G, Product: IPE e-Brent, ProdType: FUTURE, Contract: IPE e-Brent Oct12 Last: 113.86, LastQty: 1 Exchange: TTSIM-G, Product: IPE e-Brent, ProdType: FUTURE, Contract: IPE e-Brent Oct12 Last: 113.86, LastQty: 4 Exchange: TTSIM-G, Product: IPE e-Brent, ProdType: FUTURE, Contract: IPE e-Brent Oct12 Last: 113.85, LastQty: 1 Exchange: TTSIM-G, Product: IPE e-Brent, ProdType: FUTURE, Contract: IPE e-Brent Oct12 Last: 113.84, LastQty: 1 Exchange: TTSIM-G, Product: IPE e-Brent, ProdType: FUTURE, Contract: IPE e-Brent Oct12 Last: 113.85, LastQty: 1 Exchange: TTSIM-G, Product: IPE e-Brent, ProdType: FUTURE, Contract: IPE e-Brent Oct12 Last: 113.84, LastQty: 1 Exchange: TTSIM-G, Product: IPE e-Brent, ProdType: FUTURE, Contract: IPE e-Brent Oct12 Last: 113.85, LastQty: 1 Exchange: TTSIM-G, Product: IPE e-Brent, ProdType: FUTURE, Contract: IPE e-Brent Oct12 Last: 113.85, LastQty: 2 Shutting down communications to X_Trader.