[R-SIG-Finance] [quantstrat] Trading a synthetic asset

Brian G. Peterson brian at braverock.com
Wed Dec 22 15:56:43 CET 2010


On 12/22/2010 08:24 AM, Anass Mouhsine wrote:
> Hi all,
>
> While using the demos in package quantstrat ( btw a very nice and useful
> package), I wondered about the application on a synthetic asset.
> I've seen the possibilities offered by the FinancialInstrument package
> on the subject. This package enables us to define a synthetic asset e.g.
> a spread between two stocks.

Yes.  I use it in this way.

> My question is about the way of using this synthetic asset in a
> quantstrat strategy.
> How is it constructed? How is it handled by the getSymbols function used.

There are two answers to this question, the 'simple' answer, and the 
more complex one.  I'll describe the 'simple' answer in some depth, and 
the more complex one more briefly.

> My problem can be seen in two ways:
>
> 1- I have a constructed a synthetic spread (of two stocks) as an xts
> object with a varying ratios through time.
> How can use it in a quantstrategy as an asset itself? Specifically,
> since quantstrat uses mainly the getSymbols function, how the data
> loading is done?

This is the 'simple' approach, and the one I recommend.

You construct the spread time series as an xts object, and tell 
FinancialInstrument (FI) about your spread() instrument.

You can then either use quantmod's setSymbolLookup or FI's 
setSymbolLookup.FI to tell it where you're storing the files or objects, 
or you can just name your xts series for the primary_id of the 'spread' 
instrument, keep it in your .GlobalEnv, and get() and getSymbols() will 
'just find it'.

> 2-Suppose now I have the original symbols series and a time series of
> weights defining the spread ratio.
> I can use the getSymbols function to load original data. How can I
> construct my time-varying spread using the package FinancialInstrument
> and use it in a quantstrat framework?

This gets to be a little more complicated, but still quite feasible. 
There is a simple buildSpread() function in FI that uses OHLC data. 
We're sanitizing and cleaning up a version of this function with more 
functionality that works on tick TBBO data. If you're using the 
getSymbols function on free OHLC data, the existing buildSpread function 
may meet your needs.  Please let us know.

> I would like to know a little bit more about the logic intended when
> facing this kind of use of the quantstrat framework.

I hope this helps answer your direct questions.

I find when building/testing strategies that using a univariate spread 
series is much easier than modeling transactions on the underlying 
instruments. There are several reasons for this, including that most 
modern trading execution platforms have spread execution engines, and 
think of the spread as a single product with multiple execution legs. 
This means that logically, the spread is one product, not all of its 
legs.  Also, the complexity of modeling the orders (in quantstrat or any 
other package) for all the individual legs doesn't seem to add a lot of 
accuracy to your tests, and introduces significant additional 
complexity.  I've done it, but don't tend to do this level of modeling 
anymore, as it detracts from the time I could be spending creating and 
refining strategies by miring me down in execution details.  If that's 
part of your 'edge', then maybe that would be warranted, but it's not 
for me (right now).

Regards,

   - Brian

-- 
Brian G. Peterson
http://braverock.com/brian/
Ph: 773-459-4973
IM: bgpbraverock



More information about the R-SIG-Finance mailing list