A Framework for Integrating Portfolio-level Backtesting with Price and Quantity Information

Kyle Balkissoon
May 25th 2015

Built with Rpres

Why are you doing this?

  • Asset management strategies in weight space neglect the frictions of price and quantity, by mapping them into transactions we can account for frictions and also generate more realistic backtests, simulating their performance on different amounts of starting capital can give investors more realistic expectations of performance.
  • Return space backtests may not map to actual transactions, by mapping them to transactions we can break out the required orders and also generate two layers of analytics (Price Space and Quantity Space).

Integrating PortfolioAnalytics and Blotter

  • By using the PortfolioAnalytics optimize.portfolio suite and the blotter method for recording transactions and holdings we can account for trades required to rebalance a portfolio and even impose round lots.
  • This simply allows users to get a transaction level analysis to portfolio style backtests.
  • This could help give validation to portfolio style backtests by having them map to actual transactions and would calculate performance closer to an actual account.

Integrating PortfolioAnalytics and Blotter

  • Simple methodology, map optimize.Portfolio to round lots, generate txn's based on equity and current holdings to desired round lot portfolio.
  • Gives trading like analytics using chart.Posn, tradeStats.
  • This allows users to have portfolio style backtesting, however with the ability to break down statistics using the full power of blotter/quantstrat and performanceanalytics to give analysis in both trade space and portfolio space.

Example (GMV)

  • Archetypal minimum variance using PortfolioAnalytics.
  • 11 Etfs (9 SPDRS, TLT, GLD).
  • Two Cases, $100,000 portfolio and $1bn Portfolio.
  • No leverage, full investment.
  • Round to nearest lot size (100 unit lots).
  • Allocate cash simply among remaining investments iteratively from largest weight gap to smallest.

Tracking error of 18bps on a 1B Portfolio vs 139 bps on $100,000K

  • This gives a very large difference in performance using similar methodology.
  • Too small of a difference that graphs show anything.
  • Can be a big performanace variation for SMAs.

1BN Portfolio

plot of chunk unnamed-chunk-1

100K Portfolio

plot of chunk unnamed-chunk-2

A Chart.Posn like this one can be generated for each symbol

  • Also any other analytics in quantstrat/blotter/PerformanceAnalytics/PortfolioAnalytics may be used (where applicable). plot of chunk unnamed-chunk-3

TradeStats can be generated for each symbol

    Portfolio Symbol Num.Txns Num.Trades Net.Trading.PL Avg.Trade.PL
GLD    stocks    GLD      113         55        8337297    163413.07
TLT    stocks    TLT      113         55        7111718    115109.24
XLB    stocks    XLB      113         58        9519949    158795.50
XLE    stocks    XLE      113         55        4873085     88600.87
XLF    stocks    XLF      113         57       -2313548    -45384.78
XLI    stocks    XLI      113         55        6091944    110661.80
XLK    stocks    XLK      113         55       10629826    177331.91
XLP    stocks    XLP      113         54        8806800    159103.52
XLU    stocks    XLU      113         53        8967339    183933.50
XLV    stocks    XLV      113         51       12485664    232553.26
XLY    stocks    XLY      113         56        7571563    121164.88
    Med.Trade.PL Largest.Winner Largest.Loser Gross.Profits Gross.Losses
GLD    102781.95            NaN           NaN      14352765     -5365047
TLT     37508.06        1847518     -567350.0       8122064     -1791056
XLB     29567.48        1576082     -885259.3      14360197     -5150058
XLE     45144.00        1545135     -861607.4      10003431     -5130383
XLF     34208.72        1388083    -2384140.3       9932331    -12519264
XLI    120488.58        1652301    -1984205.0      14070610     -7984211
XLK    135599.95        2003583    -1480358.9      15695545     -5942291
XLP     85680.42        1713236    -1042305.9      11537000     -2945410
XLU    106497.66        1980280    -1381440.9      14746457     -4997982
XLV    159541.71        1344284    -1335977.0      16413223     -4553007
XLY     97854.41        1704660    -2669871.4      15852626     -9067393
    Std.Dev.Trade.PL Percent.Positive Percent.Negative Profit.Factor
GLD         510179.4         74.54545         25.45455     2.6752359
TLT         343208.8         65.45455         34.54545     4.5347905
XLB         458689.4         60.34483         39.65517     2.7883562
XLE         406420.5         69.09091         30.90909     1.9498411
XLF         654037.4         66.66667         33.33333     0.7933638
XLI         610303.4         70.90909         29.09091     1.7623044
XLK         537100.3         72.72727         27.27273     2.6413292
XLP         406692.7         77.77778         22.22222     3.9169422
XLU         530022.6         64.15094         35.84906     2.9504825
XLV         509215.7         70.58824         29.41176     3.6049196
XLY         648963.1         66.07143         33.92857     1.7483113
    Avg.Win.Trade Med.Win.Trade Avg.Losing.Trade Med.Losing.Trade
GLD      350067.4     236818.85       -383217.61       -284173.82
TLT      225612.9      96344.51        -94266.11        -41886.65
XLB      410291.4     291938.82       -223915.58        -92357.68
XLE      263248.2     166255.82       -301787.21       -198848.42
XLF      261377.1     152481.33       -658908.63       -369075.65
XLI      360784.9     231451.62       -499013.17       -148935.25
XLK      392388.6     358322.30       -396152.71       -228697.91
XLP      274690.5     138374.78       -245450.81       -167579.04
XLU      433719.3     317134.15       -263051.66       -168321.97
XLV      455922.9     424486.47       -303533.77       -144171.69
XLY      428449.4     330140.06       -477231.22       -197297.54
    Avg.Daily.PL Med.Daily.PL Std.Dev.Daily.PL Ann.Sharpe Max.Drawdown
GLD    163413.07    102781.95         510179.4   5.084686     -8970537
TLT    115109.24     37508.06         343208.8   5.324172     -4437538
XLB    158795.50     29567.48         458689.4   5.495659     -5608110
XLE     88600.87     45144.00         406420.5   3.460690     -3867295
XLF    -45384.78     34208.72         654037.4  -1.101560    -14202397
XLI    110661.80    120488.58         610303.4   2.878407    -10240948
XLK    177331.91    135599.95         537100.3   5.241212     -5893791
XLP    159103.52     85680.42         406692.7   6.210316     -5802778
XLU    183933.50    106497.66         530022.6   5.508923     -4666546
XLV    232553.26    159541.71         509215.7   7.249714     -5339685
XLY    121164.88     97854.41         648963.1   2.963855     -9142546
    Profit.To.Max.Draw Avg.WinLoss.Ratio Med.WinLoss.Ratio Max.Equity
GLD          0.9294089         0.9134952         0.8333591   16181902
TLT          1.6026270         2.3933616         2.3001242    9739487
XLB          1.6975325         1.8323484         3.1609588   10028442
XLE          1.2600758         0.8722973         0.8360933    6301985
XLF         -0.1628984         0.3966819         0.4131438    1569283
XLI          0.5948613         0.7229967         1.5540419    6745828
XLK          1.8035634         0.9904984         1.5667931   10966384
XLP          1.5176869         1.1191263         0.8257284    9784957
XLU          1.9216223         1.6487991         1.8840924   11138687
XLV          2.3382773         1.5020498         2.9443122   12878286
XLY          0.8281679         0.8977815         1.6733106    7751270
    Min.Equity End.Equity
GLD    -788508    8337297
TLT   -1575931    7111718
XLB    -304290    9519949
XLE    -639562    4873085
XLF  -12633114   -2313548
XLI   -8320201    6091944
XLK   -2229578   10629826
XLP   -3001078    8806800
XLU    -698971    8967339
XLV   -2950126   12485664
XLY   -8290692    7571563

Recap

  • Performance of a strategy in return space may vary with capital and lot sizes.
  • Practictioners who offer strategies to clients of varying can simulate the estimate tracking error as a function of portfolio size.
  • Further work in mapping to various execution strategies and order types.