# Is there a good backtesting package in R?

My model exports a vector that have for each day b-buy s-sell or h- hold it's look like this:

sig [1] b b s s b b b s s b s b s s b s b s s s s b b s s b b b b b b s b b b b b b b

I want to backtest that it will buy or sell all the equity in the portfolio at the end of each day and for hold will do nothing. what is the best way to backtest in R or other method this strategy?

Thanks

• Take a look at the quantstrat package @alonch7 – Rime Oct 6 '15 at 20:02
• Hi Rime, I know quanstart but I find it difficult to use it with the output my model is making. – alonch7 Oct 7 '15 at 18:05
• You can find much information on how to use the package. here is a link to Guy Yollin's page where you can download the code he uses to go over a strategy in quantstrat: r-programming.org/papers @alonch7 an alternative would be converting the b and s signals into 1 for long, -1 for short, and 0 for do nothing... and then multiplying them by the returns – Rime Oct 7 '15 at 18:31

1. In R, there are basically two packages to backtest your strategy: SIT and quantstrat. I personally prefer the former because it's much faster and more transparent in terms of how your positions are managed. In addition, SIT gives your more flexibility in how your trading signals are formed.