如何在quantstrat中输入相互取消的订单?例如,一旦我进入交易,我立即开两个订单:“止损”和“止盈”。一旦一个被填满,另一个将被取消。
#Enter signal
strategy <- add.rule(strategy, name="ruleSignal",
arguments=list(sigcol="EnterBuy", sigval=TRUE, orderqty=100,
ordertype="market", orderside="long",
pricemethod="market", osFUN=osMaxPos),
type="enter", path.dep=TRUE)
#Stop loss
strategy <- add.rule(strategy, name="ruleSignal",
arguments=list(sigcol="EnterBuy", sigval=TRUE,
orderqty="all", ordertype="stoplimit",
orderside="short", threshold=-5,
tmult=FALSE),
type="exit", path.dep=TRUE)
#Take profit
strategy <- add.rule(strategy, name="ruleSignal",
arguments=list(sigcol="EnterBuy", sigval=TRUE,
orderqty="all", ordertype="stoplimit",
orderside="short", threshold=5,
tmult=FALSE),
type="exit", path.dep=TRUE)
目前,他们正在独立工作。