[R-SIG-Finance] Long Enter Position do not "block" Short Enter Orders
Diego Peroni
diegoperoni at vodafone.it
Mon Apr 11 17:07:49 CEST 2016
Thank you Ilya,
I've placed orderset='ocoall' in both ENTER orders (named "LE" and "SE")
as in the following code but testing them I have the same problem: long
positions are closed by short (enter) positions...
Can you please tell me what I'm doing wrong?
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',
orderset='ocoall',
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',
orderset='ocoall',
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)
On 11/04/2016 15:05, Ilya Kipnis wrote:
> Short orders do not by default cancel long orders. You need to have
> them in the same order set.
>
> On Mon, Apr 11, 2016 at 6:39 AM, Diego Peroni <diegoperoni at vodafone.it
> <mailto:diegoperoni at vodafone.it>> wrote:
>
> 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)
>
> _______________________________________________
> R-SIG-Finance at r-project.org <mailto:R-SIG-Finance at r-project.org>
> mailing list
> https://stat.ethz.ch/mailman/listinfo/r-sig-finance
> -- Subscriber-posting only. If you want to post, subscribe first.
> -- Also note that this is not the r-help list where general R
> questions should go.
>
>
[[alternative HTML version deleted]]
More information about the R-SIG-Finance
mailing list