Code covered by the BSD License  

Highlights from
Automated Trading with MATLAB - 2012

image thumbnail

Automated Trading with MATLAB - 2012

by

 

31 Aug 2012 (Updated )

Files from the Automated Trading webinar showing X_Trader and QuickFIX/J integration.

X_Trader Price Update example

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 handle

  Properties:
           Gate: [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

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.

Contact us