[R-SIG-Finance] Long Enter Position do not "block" Short Enter Orders
Diego Peroni
diegoperoni at vodafone.it
Mon Apr 11 12:39:53 CEST 2016
Hi all,
my simple strategy sets long/short ENTER orders and relative long/short
EXIT orders.
I don't understand why, if I have an open LONG position, SHORT enter
order triggers (wrongly closing open position...).
My desire is that if I already have an OPEN position (long) "opposite"
orders (short enter) do not triggers.
Thanks in advance for your help
Diego
#################################
# MAX POSITION (1 future)
#################################
addPosLimit(portfolio = qs.strategy, symbol = symbol, timestamp =
initDate, maxpos = 1)
#################################
# LONG STRATEGY
#################################
add.rule(qs.strategy, name='ruleSignal',
arguments = list(sigcol="upTrend", sigval=TRUE,
replace=TRUE,
prefer='Open',
orderside='long',
ordertype='stoplimit',
order.price=quote(mktdata$price.enter.long[timestamp]),
orderqty=1,
osFUN='osMaxPos',
time.in.force=quote(timeInForceLong)),
type='enter',
label='LE')
add.rule(qs.strategy, name='ruleSignal',
arguments=list(sigcol='exitLong', sigval=TRUE,
replace=FALSE,
orderside='long',
ordertype='market',
orderqty='all',
prefer='Open'
),
type='exit',
label='ExitLong',
enabled=TRUE)
#################################
# SHORT STRATEGY
#################################
add.rule(qs.strategy, name='ruleSignal',
arguments=list(sigcol="downTrend", sigval=TRUE,
replace=TRUE,
prefer='Open',
orderside='short',
ordertype='stoplimit',
order.price=quote(mktdata$price.enter.short[timestamp]),
orderqty=-1,
osFUN='osMaxPos',
time.in.force=quote(timeInForceShort)),
type='enter',
label='SE')
add.rule(qs.strategy, name='ruleSignal',
arguments=list(sigcol='exitShort', sigval=TRUE,
replace=FALSE,
orderside='short',
ordertype='market',
orderqty='all',
prefer='Open'
),
type='exit',
label='ExitShort',
enabled=TRUE)
More information about the R-SIG-Finance
mailing list