All,

I finally answer my own question. I think it is useful to be aware of.
Thus, I am taking this opportunity to share with you. It has to do with the
structure of my data and how the ruleSignal is written (which I think it is
correct). It has to do with the following block of ruleSignal.

if (!is.na(timestamp) && nrow(mktdata[timestamp]) > 0 &&
        (ruletype == "chain" || (!is.na(mktdata[timestamp][,
            sigcol]) && mktdata[timestamp][, sigcol] == sigval)))
{
...

}

Imagine that you have multiple ticks with the same timestamp. However, ony
one of them has mktdata[timestamp][,sigcol]==sigval and the rest is NA. The
latter part of this if condition will invalidate that block of tick. The
result is that no order is created :) It took me a while to find out this.

So I decide to simplify my data by only picking the last observation if
there are multiple ticks with the same timestamp.

Robert




On Wed, Dec 26, 2012 at 7:07 PM, Robert A'gata <rhelpacc@gmail.com> wrote:

> Hi,
>
> I have a simple strategy that open a position when fast local vwap (vwap1)
> crosses above the slow local vwap (vwap2). My mktdata looks like below.
>
> > head(mktdata,2)
>                            vwap2  price   vwap1    bid    ask rawsigma
> sigma
> 2012-12-11 19:35:24.637 1710.874 1710.4 1710.58 1710.3 1710.5 56.19804
> 4.755039
> 2012-12-11 19:35:24.637 1710.873 1710.4 1710.58 1710.3 1710.5 56.19804
> 4.755039
>                             devsig pvcx.gt pvcx.lt
> 2012-12-11 19:35:24.637 -0.3609031      NA      NA
> 2012-12-11 19:35:24.637 -0.3593325      NA      NA
>
>
> In my code, whenever pvcx.gt=1, I will open a long position with 1 unit
> of my stock. However, when running my code (attached with data), quantstrat
> doesn't not want to create any order. I also checked that there are 17 rows
> where pvcx.gt=1. I do not understand why none of them is triggered. Any
> comment would be appreciated. Thank you.
>
> > idx <- which(mktdata$pvcx.gt==1)
> > length(idx)
> [1] 17
> > head(idx)
> [1]  213 2363 4104 4241 5793 7054
> > mktdata[idx[1],]
>                            vwap2  price    vwap1    bid  ask rawsigma
> sigma
> 2012-12-11 19:58:47.615 1710.612 1710.9 1710.614 1710.9 1711 58.92066
> 4.57865
>                              devsig pvcx.gt pvcx.lt
> 2012-12-11 19:58:47.615 0.002908604       1      NA
>
>
> Robert
>

	[[alternative HTML version deleted]]

