Get startedGet started for free

Setting up a strategy I

1. Setting up a strategy I

While quantstrat is powerful, it does need some setup. This video and the next will take you through the process of initializing the various moving parts found in quantstrat.

2. Three important dates

To begin with, every quantstrat backtest--that is, a simulation of your strategy on past data--needs three dates -- an initialization date for all of the various background systems, the start of your actual trading backtest, and its end. These are what I refer to as an initDate, a from date, and a to date, all of which are defined with date strings in the standard format, such as YYYY-MM-DD for January 1st, 2000.

3. Setting up quantstrat

Next, in order to properly align dates, quantstrat needs to know what time zone it's dealing with. For our purposes, this time zone will be UTC, and you can see how to initialize this here. Next, quantstrat needs to know what currency it will be using. For our purposes, we will stick to USD, or U.S. Dollars. Furthermore, quantstrat needs to know which instruments will be present in the backtest. In order for this to occur, the financial data must already be present in the working environment, and should always be loaded up during the initialization phase. The stock command lets quantstrat know that there is an instrument that should be treated as a basic equity in its underlying analytics environments.

4. Overview

As mentioned in the previous chapter, we will be using the ETF LQD for our video examples.

5. Let's practice!

You will now be tasked with beginning the initialization of your own quantstrat strategy for SPY.