Skip to content
Prev 10535 / 15274 Next

quantstrat order execution

Hi Jan,

Thanks for your answer.

I have been searching all over the quantstrat code for the "switch" where I
could change (that daily data would be processed in the same way as
monthly, quarterly and yearly) default behaviour as you described it:
"=> for monthly, quarterly and yearly data, quantstrat will use the current
bar to get the price. => for anything with a higher frequency (eg. weekly,
daily, intraday), quantstrat will use the next bar to get the price."
The more I looked the more it seems to me there is no such "switch" since
it seems to me that the whole logic of quantstrat::applyRules is based on
nextIndex. I could not find a way to change quantstrat::applyRules in such
a way that would solve my "problem". Any hint on what and how to change
highly appreciated.

Next, I still do not get the prefer option. For me it still does not work
as I would like to. I have modified the script I attached with my first
post (please see attachment) in such a way that I have lagged signals so
that I now get transactions occurring on the correct date (on the same bar
as true signal occurs). But, then looking at the transactions, they are
still done at the close (quntstrat ignoring prefer option). I have used
prefer='Open' when using addRule, but it is ignored and transaction happens
on Close price.
$qs.test
$qs.test$VXX
           Order.Qty Order.Price Order.Type Order.Side Order.Threshold
Order.Status Order.StatusTime      Prefer  Order.Set Txn.Fees
Rule
2011-02-01 "0"       NA          "init"     "long"     "0"
"closed"     "2011-02-01"          ""      ""        "0"
""
2011-02-08 "-1"      "28.42"     "market"   "short"    NA
"closed"     "2011-02-09 00:00:00" "Close" NA        "-1.9"
"EnterSHORT"
2011-02-10 "all"     "29.14"     "market"   "short"    NA
"closed"     "2011-02-11 00:00:00" "Open"  NA        "-1.9"
"ExitShort2CASH"


attr(,"class")
[1] "order_book"
Txn.Qty Txn.Price Txn.Fees Txn.Value Txn.Avg.Cost
Net.Txn.Realized.PL
2011-02-01       0      0.00      0.0      0.00         0.00
0.00
2011-02-09      -1     28.51     -1.9    -28.51        28.51
-1.90
2011-02-11       1     28.02     -1.9     28.02        28.02
-1.41
VXX.Open VXX.High VXX.Low VXX.Close VXX.Volume VXX.Adjusted
PreviousC NextO signal.enter signal.exit cash short
2011-02-08    28.62    29.19   28.25     28.42   13997600        28.42
28.77 28.69           -1           0    0     1
2011-02-09    28.69    29.11   28.35     28.51   18603000        28.51
28.42 29.14            0          -1    0     0
2011-02-10    29.14    29.25   28.30     28.51   17734000        28.51
28.51 28.75            0           0    1     0
2011-02-11    28.75    28.80   27.93     28.02   14826100        28.02
28.51 28.00            0           0    0     0

I would appreciate any help to sort this prefer option thing. Thnx.

Best regards,
Samo


__________________________________________________

Hi Samo,

Currently, the following is hard-coded in the quantstrat software:
=> for monthly, quarterly and yearly data, quantstrat will use the
current bar to get the price.
=> for anything with a higher frequency (eg. weekly, daily, intraday),
quantstrat will use the next bar to get the price.

The idea is that you once a bar is complete, there is no more trading
possible within that bar, so you can only trade within the next bar.

I suggest that you use prefer='Open' to use the opening rate of the next
bar instead. Be aware that your results will be unrealistic though,
because in practice you will usually not get the opening price of the
next bar.

Another option is to adjust your strategy a bit, and use higher
frequency data, for example 15min rates, and decide on the on-but-last
bar of the day, then trade on the last one.

HTH,

Jan.



Quantstrat
On 19-07-12 21:48, Samo Pahor wrote: