Setting up a strategy I

Financial Trading in R

Ilya Kipnis

Professional Quantitative Analyst and R programmer

Three important dates

  • Quantstrat needs an initDate, a from date, and a to date.

  • YYYY-MM-DD, eg “2000-01-01”

initdate <- "1999-01-01"
from <- "2003-01-01"
to <- "2015-12-31"
Financial Trading in R

Setting up quantstrat

# Set system environment timezone:
Sys.setenv(TZ = "UTC")
# Set currency (we’ll use USD for now):
currency("USD")
# Obtain financial data:
getSymbols("LQD", from = from, to = to, 
           src = "yahoo", adjust = TRUE)
# Treat as basic equity
stock("LQD", currency = "USD", multiplier = 1)
Financial Trading in R

Overview

initDate = "1999-01-01"
from = "2003-01-01"
to = “2015-12-31"
Sys.setenv(TZ = "UTC")
currency("USD")
getSymbols("LQD", from = from, to = to, src = "yahoo", 
           adjust = TRUE)        
Financial Trading in R

Let's practice!

Financial Trading in R

Preparing Video For Download...