[R-SIG-Finance] blotter update MM & weights without recalculation all

Brian G. Peterson brian at braverock.com
Sat Feb 26 14:15:32 CET 2011


On 02/26/2011 06:50 AM, Immanuel wrote:
> Hello all,
>
> I just had a first glimpse at the blotter package and
> found it quite amazing. The demos are great to understand
> the basic principles but it would be great I some of the experts
> could give me advice on how to approach the following.

Note that blotter is designed to be used for trade P&L, it is really 
just a trade blotter.  Strategy creation is outside the scope of the 
blotter package.  The demos are there to demonstrate how it can be used, 
but this isn't the way I would recommend building strategies.

We are aware that some users of the package are taking trades from other 
scripts or systems and using blotter for P&L.  This makes sense, and is 
in line with its intended purpose.  I do not use blotter for strategy 
development, and hide it behind a real strategy framework. The package 
we wrote to be 'in front' of blotter for strategy testing is 
'quantstrat'. Other approaches are possible, of course, but I use 
quantstrat 'at the office', and my personal development effort in this 
direction is focused here.


> 1) use blotter to run one trading system on differed symbols
> 2) use P/L per trade to calculate optimal position size per symbol

Aren't 2> and 5> trying to accomplish the same thing?  See below.

> 3) rerun blotter with optimal position size.
> 4) use returns per symbol, to calculate weights for each symbol
> (Markowitz on trading system equity curves)
> 5) rerun blotter using weights to calculate portfolio return.
>
> The steps I'm not sure how to accomplish are:
>
> 3) do I need to run the whole trade creation process again, or can
> I somehow update the trade records to the new position size rules

You should probably run the trade creation process again.  Per the 
documentation, blotter does not allow trades to be entered out of order, 
or to be modified after the fact.  updatePortf and updateAcct may be run 
multiple times, but they throw out all prior calculations.

You can likely improve performance if you keep indicators and signals 
that would be invariant to position sizing. So think about how to 
separate that part from the rest.

> 5) I don't know how to do that at all

blotter is a transaction/P&L based framework, not a weights/returns 
framework. (there are several other packages for that in R)

You can extract returns from blotter that will be return on account 
equity.  These may be used as inputs for a more traditional returns 
based portfolio optimization.

Typically, I will backtest strategies on 'one lots', the smallest unit 
that may be reasonably bought/sold in a given 'product' (this term is 
intentionally loose, and may include synthetics).  Another approach 
which has merit is to backtest a 'neutral allocation' where all 
positions taken across products have the same notional size.  When 
converted to returns, this would create an 'equal weight' portfolio.

Now that you have returns from the 'equal weight' portfolio, you can 
apply traditional portfolio optimization. For example, with twenty 
products, each product in the equal weight portfolio would have a 
portfolio weight of 5%.  If the optimization suggests an ideal weight of 
20%, you would take your equal weight position sizing and make it four 
times larger.

I'll note that Markowitz optimization is not likely what you want.  It 
will penalize positive skew and a long right tail on the distribution, 
which are precisely the features you would want to emphasize in a 
portfolio of trading strategies or products traded in a single strategy.

> any advice is very much appreciated!

Hope this helps,

    - Brian



More information about the R-SIG-Finance mailing list