[R-SIG-Finance] Backtesting trade systems

Adrian Dragulescu adrian_d at eskimo.com
Thu Jul 16 16:28:23 CEST 2009


I have been working on such a package too.  I am currently testing it, and 
was planning to have a small user group release in about a month or so.

>From the vignette introduction (that I am still expanding):

The goal of the package {\tt\textbf{AlgoTrader}} is to provide such a
framework using an object oriented approach\footnote{See Section
   \ref{appendixProto} for a discussion on the design decision.}.  There
are two main classes.  An {\tt Algo} class from which all user
algorithms inherit and a {\tt Trader} class used for performace
tracking and reporting.  By convention, the parent classes {\tt Algo}
and {\tt Trader} are capitalized, while lower case names, say {\tt
   algo1} and {\tt trader1} are used for instances of these classes.
Conceptually, a model is represented by an algorithm and a trader.

The functionality provided in this package allows the user to define
multiple trading algorithms.  He could gradually refine these
algorithms by using the inheritance mechanism, or use the same
algorithms with different parameters to instantiate different
\code{Algo} objects.

The \code{Algo} object contains all the historical data necessary, a
set of parameters, functions that generate trading signals, and a set
of functions that modify the positions given a trading signal.  Using
an algorithm {\tt algo}, the user can create a {\tt trader} that uses
the algoritm over a specified time interval to arrive at a trading
decision for each time step.  A trade log is kept by the trader, so
that an analysis of the trading performance can be done.  The
\code{trader} has different methods to summarize/plot/evaluate his
performance.  For strategy selection or for tuning the algorithm
parameters, the performance of several traders can be compared side by
side.  As the \code{AlgoTrader} package does backtesting, it is best
if only deterministic trading algorithms are used so performance
results are reproducible.

Let me know if you want to take part in testing.

Thanks,
Adrian

On Thu, 16 Jul 2009, Mark Breman wrote:

> Hello,
> I have spend quit some time now looking for a package that allows me to
> backtest (technical) trading systems based on single financial instruments
> with R.
>
> I had a look at Rmetrics, blotter, fTrading, PerformanceAnalytics, backtest,
> quantmod, TTR etc, but not one of these fill my requirements. It's not that
> they are not usefull, on the contrary, they are all filled with terrific
> statistical stuff, but it's not the simple, practical and straightforward
> approach that I am looking for as a trader rather than as a statisticus.
>
> So I have decided to build my own solution, reusing as much as possible from
> these existing packages. (As a former software engineer I know how much time
> and effort goes into buiding reliable software, so the more reuse the
> better). As I am quite new to R and statistics in general, there is a lot to
> learn for me here...
>
> What I have build so far is a very basic set of functions called
> "tradesim.R" (I have attached it to this post). A very basic example of how
> these functions can be used for a backtest-run can be found in
> "tradesim_example.R". The example runs a backtest with end-of-day data from
> AAPL, using a (rather poor) trading system based on the RSI indicator (from
> the TTR package).
>
> Now I have read in some older post on this list that others were also
> searching for a backtesting package. I even read a post proposing to start a
> group effort creating such a package. I suspect that some of you might be
> interested in what I made so far and maybe would like to put in a effort
> creating such a package together. I certainly know that it's a lot easier to
> create good software as a group, rather than by a single person...
>
> So if you are interested have a look at what I got so far and let me know
> what you think.
>
> Regards,
>
> -Mark-
>



More information about the R-SIG-Finance mailing list