Skip to content
Prev 13302 / 15274 Next

Quantstrat for backtesting on tickdata (and creating a spread from tick)

On Mon, Jun 1, 2015 at 4:00 PM, bearwithme <daneedwards1 at hotmail.com> wrote:
I have some code that builds a similar spread like this:

syms <- c("BRN0615","BRNS120615")
currency('USD')
spread("BRNS","USD",syms,c(1,-3))
bid <- buildSpread("BRNS",onelot=FALSE,prefer="Bid",auto.assign=FALSE)
ask <- buildSpread("BRNS",onelot=FALSE,prefer="Ask",auto.assign=FALSE)
BRNS <- merge(bid, ask)

This code is a couple years old and I don't remember the precise
reason for constructing the spread that way... I think it had
something to do with not assuming you would be able to get the passive
price on both legs of the spread.  Hopefully someone else can
elaborate.
xts objects don't need a unique index.  Did you actually encounter a
problem, or are you just guessing that there will be one?
Use column names, Bid.Price and Ask.Price, respectively.  Then set
prefer = "Bid" or prefer = "Ask" in your quantstrat calls that care
about the side of the market (e.g. ruleSignal).