[R-SIG-Finance] quanstrat rule to exit same day close (using daily data)

Brian G. Peterson brian at braverock.com
Sun May 13 23:18:30 CEST 2012


Garrett is correct, sorry, I'm still a little sleep-deprived from
R/Finance.  

Rule execution order is discussed in the documentation for add.rule, and
'enter' rules are processed last.

I wonder if we should consider moving 'rebalance' rules to the end of
the order, or adding a exit rule type that is specifically evaluated
after entry rules.   The code change would be trivial, as that is
processed in a switch statement.


On Sun, 2012-05-13 at 15:46 -0500, G See wrote:
> Brian,
> 
> I can't get that to work.  It used to be that exit orders would fire
> before enter orders and if you did not have a position, they were
> effectively not sent.
> 
> I tried to test this by making a tiny change to the maCross.R demo.  I
> changed the second add.signal call so that it had
>     relationship="gte"
> just like the first add.signal call.  In other words, you should get
> an enter and exit at the same time.  So, you should never have a
> position.  Nevertheless,  you end up with a position of short 600
> shares.  If that's not right, then I doubt that adding prefer="Open"
> to one and prefer="Close" to the other will work.
> 
> Garrett
> On Sun, May 13, 2012 at 3:20 PM, Brian G. Peterson <brian at braverock.com> wrote:
> > On Sun, 2012-05-13 at 15:55 -0400, s p wrote:
> >> okay so that means I can't use quantstrat for strategies where the
> >> entry and exit are on the same bar (in this case daily bar).
> >
> > Sure you can, if the signal is on the same observation.
> >
> > I'm not sure how realistic a backtest of market on open and market on
> > close is going to be, of course, because of slippage, but it should
> > 'work' in quantstrat.
> >
> > Your entry rule would use prefer='Open' and your exit rule would use
> > prefer='Close'.
> >
> > --
> > Brian G. Peterson
> > http://braverock.com/brian/
> > Ph: 773-459-4973
> > IM: bgpbraverock
> >
> > _______________________________________________
> > 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.
> 
> _______________________________________________
> 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.

-- 
Brian G. Peterson
http://braverock.com/brian/
Ph: 773-459-4973
IM: bgpbraverock



More information about the R-SIG-Finance mailing list