Version 15, last updated by pracplay-support2 at November 30, 2011 11:30 UTC
BridgeExampleR
These examples are provided as a help but are not comprehensive examples.
If you have problems, you should still consult the BridgeGettingStarted, BridgeReference and BridgeTroubleshooting guides.
R (open a ticket if you encounter a problem)
You should also check out the QUANTMOD package in R. You can use QUANTMOD with Bridge.
# GETTING STARTED
# import bridge r script (you can skip this step if you auto-sourced R on bridge install, the default)
source("c:\\program files\\bridge\\bridge.r")
# start using the bridge
# MARKET EXAMPLE
# get an order id
id<-tsl_nextorderid()
# send market order
tsl_sendorder('IBM',TRUE,100,0,0,id,'','')
# verify sent
tsl_sentsize(id)
# verify fill
tsl_filledsize(id)
tsl_possize('IBM')
# close the position
tsl_sendorder('IBM',FALSE,100,0,0,id,'','')
# LIMIT EXAMPLE WITH CANCEL
# send limit order
id<-tsl_nextorderid()
tsl_sendorder('AAPL',TRUE,100,150,0,id,'','')
# verify order
tsl_sentsize(id)
tsl_filledsize(id)
# cancel order
tsl_sendcancel(id)
# verify cancel
tsl_iscanceled(id)
# STOP AND PROFIT BRACKETING EXAMPLE
# set bracket, profit 1.5 points, stop 1/2 point. 100% of position size for each
tsl_setoffset('AAPL',1.5,.5,1,1)
# enter position
tsl_sendorder('AAPL',TRUE,100,0,0,tsl_nextorderid(),'','')
# see stops and limits sent
# add or change position
tsl_sendorder('AAPL',TRUE,100,0,0,tsl_nextorderid(),'','')
# see stops and limits update