[R-SIG-Finance] quanstrat rule to exit same day close (using daily data)
G See
gsee000 at gmail.com
Sun May 13 22:46:22 CEST 2012
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.
More information about the R-SIG-Finance
mailing list