# Backtesting a Trading Strategy - Considerations

Backtesting a trading strategy refers to testing the strategy with historical data and observe their metrics, results and performance. Commonly, backtesting has some pitfalls that should be considered by any trader before they put a strategy in production.

Data Scientist and developers should take into account issues such as ** Optimization Bias**,

**and**

*Survivorship Bias*

*Market Impact**when backtesting their trading strategies*.

### Optimization Bias

**Optimization Bias** takes place when a trading strategy was built based on a large number of parameters.

The excess of parameters can lead the strategy to outperform the market with sample data, but with live market data or out of sample data, the strategy might have poor performance. Therefore, a good practice is to keep the strategy simple with fewer parameters.

### Survivorship Bias

** Survivorship Bias** means that the dataset used for backtesting doesn’t contain the full list of stocks at every point in time, but only consider those stocks that have “survived”.

If we use a dataset that only considers stocks that have overcome drawdowns periods, and not those stocks that were delisted, or stocks that got in bankruptcy, we are introducing ** Survivorship Bias** and the strategy returns can increase artificially.

### Market Impact

** Market Impact** could be important for large transactions that are executed to rebalance portfolios. This can cause price movements that are reflected by the difference between the transaction price and what the market price would have been in the absence of the transaction.

On the other hand, the ** market impact** could increase the bid ask spread. More illiquid assets have large spreads (difference between the bid and ask price). Depending on the supply and demand dynamics of the stock and the exchange that is used to trade, the spread can vary and increase transaction costs.

**can be addressed by taking a conservative perspective about trade prices while backtesting.**

*Market impact*When backtesting and sourcing trading ideas, it is a good practice to consider other insights beyond the strategy returns. These insights are the leverage, volatility required, capital requirements, and risk metrics such as maximum drawdown tolerance and Sharpe ratio.

#### Course Downloads

- Introduction to Quantitative Trading
- Quantitative Trading - Advantages and Disadvantages
- Types of Quantitative Trading Strategies
- Momentum Strategies
- Mean Reversion Strategies
- Market Making Strategies and Day Trading Strategies
- How to Generate Trading Ideas
- Designing A Trading Strategy For Profit
- Backtesting a Trading Strategy - Considerations
- Risk Management of a Trading Strategy
- Risk Indicators - VIX Index and TED Spread
- Plotting the VIX Index and TED Spread in R
- Introduction to Quantmod in R
- Downloading Data Using Quantmod Package in R
- Creating Charts with Quantmod
- Data Analysis with Quantmod in R
- Measuring Overall ETFs Performance
- Quantstrat Example in R - EMA Crossover Strategy
- Quantstrat - EMA Crossover Strategy - Performance and Risk Metrics
- Quantstrat Example in R - RSI Strategy
- Quantstrat Case Study - Multiple Symbol Portfolio

# R Programming Bundle: 25% OFF

**R Programming - Data Science for Finance Bundle**for just $29 $39.