Hi,<br><br>I am trying to "persuade" quantstrat, working with daily data, to execute orders at the close on the day that signal is telling "short" and exit(cover short) a day after "move to cash" signal is generated. Unfortunately, quantstrat does is not easily presuaded to do this...<br>
<br>I have searched all possible lists and e-mails but it seems to me that either quantstrat was not designed for delaying order execution on daily data with prefer option column or there is a bug in quantstrat or my understanding is limited(again)... I tried to play with all possible combinations of delay (-1, 0, 1) and prefer (Open, PreviousOpen) arguments but without success (following discussion here <a href="https://stat.ethz.ch/pipermail/r-sig-finance/2011q3/008356.html">https://stat.ethz.ch/pipermail/r-sig-finance/2011q3/008356.html</a> and here <a href="https://stat.ethz.ch/pipermail/r-sig-finance/2012q2/010224.html).">https://stat.ethz.ch/pipermail/r-sig-finance/2012q2/010224.html).</a>.. Am I missing something here or I do not understand something about quantstrat?<br>
<br>I have prepared a reproducible example (based on Jan Humme excellent demos). It also contains expected result and actual result from quantstrat. Please see attached R script file. Looking at OrderBook, txns and maktdata it just does not make sense to me...<br>
<br>> print(getOrderBook(p))<br>$qs.test<br>$qs.test$VXX<br>           Order.Qty Order.Price Order.Type Order.Side Order.Threshold Order.Status Order.StatusTime      Prefer  Order.Set Txn.Fees Rule            <br>2009-01-30 "0"       NA          "init"     "long"     "0"             "closed"     "2009-01-30"          ""      ""        "0"      ""              <br>
2009-02-10 "-1"      "418.4"     "market"   "short"    NA              "closed"     "2009-02-11 00:00:00" "Close" NA        "-1.9"   "EnterSHORT"    <br>
2009-02-12 "all"     "421"       "market"   "short"    NA              "closed"     "2009-02-12 00:00:00" "NextO" NA        "-1.9"   "ExitShort2CASH"<br>
<br><br>attr(,"class")<br>[1] "order_book"<br>> <br>> txns <- getTxns(p, "VXX")<br>> txns<br>           Txn.Qty Txn.Price Txn.Fees Txn.Value Txn.Avg.Cost <a href="http://Net.Txn.Realized.PL">Net.Txn.Realized.PL</a><br>
2009-01-30       0      0.00      0.0      0.00         0.00                0.00<br>2009-02-11      -1    412.28     -1.9   -412.28       412.28               -1.90<br>2009-02-12       1    411.04     -1.9    411.04       411.04               -0.66<br>
> <br>> mktdata["2009-02-10/2009-02-12"]<br>           VXX.Open VXX.High VXX.Low VXX.Close VXX.Volume VXX.Adjusted PreviousC  NextO signal cash long short<br>2009-02-10    404.0   422.64  395.12    418.40      64200       418.40    397.32 416.20     -1    0    0     1<br>
2009-02-11    416.2   419.32  408.40    412.28      21500       412.28    418.40 421.00      0    1    0     0<br>2009-02-12    421.0   432.00  411.04    411.04      25500       411.04    412.28 412.96      0    0    0     0<br>
<br><br>I would appreciate any hints on how to accomplish what I want.<br><br>Best,<br>Samo<br>