[R-SIG-Finance] How to backtest in R

Joshua Ulrich josh.m.ulrich at gmail.com
Tue Nov 30 05:37:02 CET 2010


Hi Aaditya,

On Mon, Nov 29, 2010 at 9:58 PM, Aaditya Nanduri
<aaditya.nanduri at gmail.com> wrote:
> Hello All,
>
> This is a rather general question about backtesting : How is it done?
> (People of my age would usually write "lol" immediately after that question)
>
> My current situation (Im a beginner at this):
>
> I'm working on a variation of the TAA strategy that was written by Mr. Faber
> and while its simple enough, I have no idea how to backtest.
>
> This is what I think is backtesting:
>  - Must be a walk-forward (or decisions must only be based on events already
> happened)
>  - Must return a set of entry points and exit points
>  - Must take some initial amount of money and provide PL of each open/close
> and a running PL
>  - Overall percentage increase during holding period (monthly, in my case)
>  - Volatility (SD of price-movement or SD of percentage change in each
> month?)
>  - Sharpe
>
>
> Is this usually done in a function? a loop? provided in a package? (I looked
> at backtest but I have no idea what that does. Im still reading up on it)
>
> I know this is a lot to ask but can anyone show me an example?
>
There are several examples in the quantstrat and blotter packages.
There are examples of other strategies as well, but those three
replicate Faber.  I would recommend you stick with quantstrat, since
it will help you test strategies (blotter is more infrastructure).
Try:
library(quantstrat)
demo(faber)  # quantstrat demo
demo(faberMC)   # quantstrat demo
demo(longtrend)  # blotter demo

And there are some other examples that perform simple backtesting
without using any package <shameless plug>on my blog</shameless plug>.

Best,
--
Joshua Ulrich  |  FOSS Trading: www.fosstrading.com


> I sincerely appreciate all the help anyone provides.
>
>
> --
> Aaditya Nanduri
> aaditya.nanduri at gmail.com
>
>        [[alternative HTML version deleted]]
>
> _______________________________________________
> R-SIG-Finance at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-sig-finance
> -- Subscriber-posting only. If you want to post, subscribe first.
> -- Also note that this is not the r-help list where general R questions should go.
>



More information about the R-SIG-Finance mailing list