Version 14, last updated by pracplay-support2 at December 20, 2011 21:00 UTC

 

These examples are provided as a help but are not comprehensive.


If you have problems, you should still consult the BridgeGettingStartedBridgeReference and BridgeTroubleshooting guides.

 

MATLAB (open a ticket if you encounter problems)


% you can skip these steps if you chose 'auto start bridge in matlab' upon install

% add path to whereever you installed bridge

addpath('c:\program files\bridge\')

% start bridge

bridge()


% BASICS

% send buy market order

tsl_sendorder('IBM',1,100,0,0,tsl_nextorderidsmall(),'','')

% see if it filled

tsl_possize('IBM')

% send limit order

limitid = tsl_nextorderidsmall()

tsl_sendorder('AAPL',1,300,250,0,limitid,'','')

% verify sent

tsl_sentsize(limitid)

% cancel limit

tsl_sendcancel(limitid)

% verify cancel

tsl_iscanceled(limitid)

% send stop to a specific destination

tsl_sendorder('AAPL',1,300,500,tsl_nextorderidsmall(),'','ARCA')

% close position

tsl_sendorder('AAPL',0,tsl_possize('AAPL'),0,0,tsl_nextorderidsmall(),'','')


% SPECIAL ORDERS

% configure standing profit and stop orders (offsets aka brackets) for a position

tsl_setoffset('CLV8 FUT NYMEX',10,5,1,1)

% configure standing trailing stop for same position

tsl_settrail('CLV8 FUT NYMEX',1,1)

% take a position and see the offsets

tsl_sendorder('CLV8 FUT NYMEXT',1,1,0,0,tsl_nextorderidsmall(),'','')

% change position and watch offsets update

tsl_sendorder('CLV8 FUT NYMEXT',1,1,0,0,tsl_nextorderidsmall(),'','')

% flatt position and watch offsets cancel

tsl_sendorder('CLV8 FUT NYMEXT',0,2,0,0,tsl_nextorderidsmall(),'','')


% DATA IMPORT (matlab only)

% update matlab tick cache with any new data

tsl_cacheupdate()

% pull specific data into matlab

wag = fliptickdata(tsl_cacheload('WAG',20070926));

% get financial time series object from trade data

fts = fints(tickdata2ftdate(wag),nonanprices(wag.trade))

% get moving average

movavg = tsmovavg(fts,'s',10);

% plot normally

plot(fts2mat(movavg));

% chart using financial time series object

chartfts(movavg);



% MATLAB BRIDGE STUDY EXAMPLE

% grab some data to work with

wag = fliptickdata(tsl_cacheload('WAG',20070926))


% BUILD AN INDICATOR : intention strong buying behavior should drive up price

% buying behavior idea.... if buyers order is taken at bid price, sellers are in control (and vice verca)


% first lets shift our prices to compare "before" and "after"

next = circshift(wag.trade,-1)


% then compute our indicators

hitbid=next==wag.bid

takeoffer=next==wag.ask


% compute directional indicator for comparison

direction = nan2zero(next-wag.trade)


% check our work =~ 1.6

sum(direction)


% compare raw price, we see about 1.5+ change upward

plot(wag.time,niceprice(wag.trade))

axis([93000 160000 45 50])

set(gca,'XTickLabel',nyseequitytimes)


% look for correlation and p values

[r,p] = corrcoef(hitbid*-1,direction)   % ensure that bearish behavior matches bearish price direction

[r,p] = corrcoef(takeoffer,direction)


% none found on this data set.   1) expand set and/or 2) describe buyers and sellers with more nuance or in another way, and try try again