[R-SIG-Finance] quanstrat rule to exit same day close (using daily data)
OpenTrades
jan at opentrades.nl
Wed May 16 21:25:04 CEST 2012
Garrett,
On 15-05-12 19:02, Brian G. Peterson wrote:
>
> On Tue, 2012-05-15 at 09:45 -0700, algotr8der wrote:
>> Hi Brian - I think that change would be desirable. Not sure what everyone in
>> your development team thinks.
> OK, it's a one or two line change (order of rule execution) , I'll work
> on it.
>
> Jan Humme (opentrades) has a patch basically completed that will allow
> multiple trades on the same bar, though things may of course happen 'out
> of order' depending on the order of rule evaluation operations.
Yep, patch committed now, rev 1025. There was a problem with the new
orderset feature (committed a couple of weeks ago), causing the
enter-orders to be canceled.
This leaves us with the following situation:
=> if you use a hard-coded order position for the exit-order (eg, -100)
this will still be ruthlessly followed; the order size will not be
adjusted to match the (max) current position. As a result, you will end
up with a -100 position after the first exit order gets executed.
However with your modification (lt changed to gte) the enter order will
be executed at the same bar, leaving you with a 0-position again.
> [1] "2001-06-26 AAPL -100 @ 11.88"
> [1] "2001-06-26 AAPL 100 @ 11.88"
=> if you use the 'all'-argument for the exit-order, the first
exit-order will be skipped due to the 0-position, but the first
enter-order (on the same bar) will be executed. In this case you end up
with a 100-position, which will be exited and immediately entered again
at the next bar that has a signal.
> [1] "2001-06-26 AAPL 100 @ 11.88"
> [1] "2002-01-04 AAPL -100 @ 11.85"
> [1] "2002-01-04 AAPL 100 @ 11.85"
> [1] "2003-05-15 AAPL -100 @ 9.36"
> [1] "2003-05-15 AAPL 100 @ 9.36"
Best regards,
--
Jan Humme - OpenTrades
WWW: http://www.opentrades.nl
Email: jan at opentrades.nl
Twitter: @opentrades
More information about the R-SIG-Finance
mailing list