Skip to content
All library documents

Backtesting Frameworks and a Basic R Strategy Workflow

Article Quant Q&A · Author: Tester

Summary

The discussion surveys ways to build or choose software for testing trading strategies. It contrasts vectorized or iterative backtests, which process data in a loop, with event-driven systems that respond to incoming data. The answer suggests that simpler iterative approaches suit many strategies, while the appropriate design depends on the trading style. It also points readers toward existing frameworks and educational resources rather than assuming custom software is necessary.

A second answer outlines a basic R workflow: load data and libraries, create an indicator, use it to construct an equity curve, and evaluate performance. The discussion does not explain the mechanics of cumulative performance calculations, provide code, or compare results from different methods. It is an introductory map of implementation choices and learning resources, so more detailed guidance is needed to account for costs, execution, data quality, and strategy-specific backtest assumptions.

Key ideas

  • Backtesting systems may process data iteratively or respond to events as they arrive.
  • The choice of backtest design depends on the strategy’s trading style.
  • Existing packages and frameworks may meet a researcher’s needs without custom development.
  • A basic R workflow moves from data loading to indicator creation, equity curve construction, and performance evaluation.

Tags

Full text
# Backtesting algorithms


# Backtesting algorithms












Are there any books/papers/articles to describe how to develop a backtesting software? Something like backtest in quantopian website. How do they calculate the Cumulative performance?

## Answer by MJB (score 2)

https://quant.stackexchange.com/a/27489

There are many resources on the web but you need to think why you would want to do this in the first place. Are there not packages or frameworks out there already that will do what you need?

Also backtesting or any financial trading platform will be suited to a specific style or method of backtesting. Some are vectorised iterative processes (e.g. just a big for loop with some whistles added on) and others are reactive CEP based solutions (they rely on events coming in from a data feed then reacting to these in some ways) so unless you have a specific style of trading the former will work for most people.

http://www.quantstart.com has interesting articles on back testing and there are plenty others. Rob Carvers site is quite informative also: http://qoppac.blogspot.com/

## Answer by vonjd (score 2)

https://quant.stackexchange.com/a/59104

In this blog post I describe how to backtest trading strategies with R:

Backtest Trading Strategies Like a Real Quant

It gives a step-by-step template which consists of the following steps:

- Load libraries and data

- Create your indicator

- Use indicator to create equity curve

- Evaluate strategy performance

Details and the fully documented code can be found in the post.

Shown in full with attribution under the source's licence. Licence: CC BY-SA 4.0 (Stack Exchange)

This summary was written by Stratmill's research agent from the original; it is not a copy of the source.