Ch. 1 - Trading basics

Why do people trade?

[Video]

Identifying types of trading philosophies - I

Hello and welcome to Financial Trading in R! This course will teach you how to construct a basic trading strategy in quantstrat, R’s industrial-strength backtesting platform developed by Brian Peterson, Director of Algorithmic Trading at DV Trading. Over the next few chapters, you’ll build a trading strategy in quantstrat from start to finish, including the code to set up a new strategy, as well as the design of indicators, signals, and rules for your strategy. By the end of the course, you’ll be ready to design and implement your own trading strategies directly in R!

quantstrat is currently only available on GitHub. If you want to install it on your own machine, you first need to remotes package.

install.packages("remotes")

Then you can install quantstrat using

remotes::install_github("braverock/quantstrat")

Before getting into the meat and potatoes of the course, let’s review some phrases and mechanics you may have heard in the world of financial trading, or even in pop culture. As you learned in the video, the mechanics of trading usually come in one of two forms:

  • Trend trading (also divergence or momentum), which is a bet that a quantity, such as a price, will keep moving in its current direction.
  • Reversion trading (also convergence, cycle, or oscillation), which is a bet that a quantity, such as a price, will reverse.

When someone says “the trend is your friend”, which type of trading philosophy is he or she referring to?

  • [*] Trend or momentum trading
  • Reversion or oscillation trading
  • Both

Identifying types of trading philosophies - II

Believe it or not, the following phrase is used to describe strategies ranging from holding securities over months to holding securities over days. However, the basic hypothesis is the same.

When someone criticizes a trading strategy for “trying to catch a falling knife”, what type of strategy is he or she most likely referring to?

  • Trend or momentum trading
  • [*] Reversion or oscillation trading
  • Both

Identifying types of trading philosophies - III

Often on television, when someone sees a stock rise in price, more experienced talking heads will say: “Don’t chase the price. Buy the dip.” What philosophy are they referring to?

In fact, this course will teach you the basics of putting together such a strategy.

  • Trend or momentum trading
  • Reversion or oscillation trading
  • [*] Both

Pitfalls of various trading systems

[Video]

How to prevent overfitting

When developing a trading system, a major pitfall that can creep into system development is the desire to find a strategy that worked phenomenally in the past. This is known as overfitting. Research by leading authors in the quantitative field has shown that not only is an overfitted system unlikely to generate profits in the future, but also that its performance can lead to losses.

According to the video, which of the following steps can you take to reduce the chance of overfitting a trading system?

  • Examining the robustness of system performance.
  • Reducing the number of parameters in the trading system.
  • Conducting tests to determine statistical significance of a strategy.
  • [*] All of the above.

Getting financial data

[Video]

Plotting financial data

# Get SPY from yahoo
getSymbols("SPY", 
           from = "2000-01-01", 
           to = "2016-06-30", 
           src = "yahoo", 
           adjust = TRUE)
## 'getSymbols' currently uses auto.assign=TRUE by default, but will
## use auto.assign=FALSE in 0.5-0. You will still be able to use
## 'loadSymbols' to automatically load data. getOption("getSymbols.env")
## and getOption("getSymbols.auto.assign") will still be checked for
## alternate defaults.
## 
## This message is shown once per session and may be disabled by setting 
## options("getSymbols.warning4.0"=FALSE). See ?getSymbols for details.
## Warning in read.table(file = file, header = header, sep = sep,
## quote = quote, : incomplete final line found by readTableHeader
## on 'https://query2.finance.yahoo.com/v7/finance/download/SPY?
## period1=-2208988800&period2=1591228800&interval=1d&events=split&crumb=7CoN7ycnWuC'
## Warning in read.table(file = file, header = header, sep = sep,
## quote = quote, : incomplete final line found by readTableHeader
## on 'https://query1.finance.yahoo.com/v7/finance/download/SPY?
## period1=-2208988800&period2=1591228800&interval=1d&events=split&crumb=7CoN7ycnWuC'
## [1] "SPY"
# Plot the closing price of SPY
plot(Cl(SPY))

Adding indicators to financial data

[Video]

Adding a moving average to financial data

# Plot the closing prices of SPY
plot(Cl(SPY))

# Add a 200-day SMA using lines()
lines(SMA(Cl(SPY), n = 200), col = "red")


Ch. 2 - A boilerplate for quantstrat strategies

Setting up a strategy I

[Video]

Understanding initialization settings - I

# Load the quantstrat-package
library(quantstrat)
## Loading required package: blotter
## Loading required package: FinancialInstrument
## Loading required package: PerformanceAnalytics
## 
## Attaching package: 'PerformanceAnalytics'
## The following object is masked from 'package:graphics':
## 
##     legend
## Loading required package: foreach
# Create initdate, from, and to strings
initdate <- "1999-01-01"
from <- "2003-01-01"
to <- "2015-12-31"

# Set the timezone to UTC
Sys.setenv(TZ = "UTC")

# Set the currency to USD 
currency("USD")
## [1] "USD"

Understanding initialization settings - II

# Load the quantmod package
library(quantmod)

# Retrieve SPY from yahoo
getSymbols("SPY", from = from, to = to, src = "yahoo", adjust = TRUE)
## Warning in read.table(file = file, header = header, sep = sep,
## quote = quote, : incomplete final line found by readTableHeader
## on 'https://query1.finance.yahoo.com/v7/finance/download/SPY?
## period1=-2208988800&period2=1591228800&interval=1d&events=split&crumb=7CoN7ycnWuC'

## Warning in read.table(file = file, header = header, sep = sep,
## quote = quote, : incomplete final line found by readTableHeader
## on 'https://query1.finance.yahoo.com/v7/finance/download/SPY?
## period1=-2208988800&period2=1591228800&interval=1d&events=split&crumb=7CoN7ycnWuC'
## [1] "SPY"
# Use stock() to initialize SPY and set currency to USD
stock("SPY", currency = "USD")
## [1] "SPY"

Setting up a strategy II

[Video]

Understanding initialization settings - III

# Define your trade size and initial equity
tradesize <- 100000
initeq <- 100000

# Define the names of your strategy, portfolio and account
strategy.st <- "firststrat"
portfolio.st <- "firststrat"
account.st <- "firststrat"

# Remove the existing strategy if it exists
rm.strat(strategy.st)

Understanding initialization settings - IV

# Initialize the portfolio
initPortf(portfolio.st, symbols = "SPY", initDate = initdate, currency = "USD")
## [1] "firststrat"
# Initialize the account
initAcct(account.st, portfolios = portfolio.st, initDate = initdate, currency = "USD", initEq = initeq)
## [1] "firststrat"
# Initialize the orders
initOrders(portfolio.st, initDate = initdate)

# Store the strategy
strategy(strategy.st, store = TRUE)

Ch. 3 - Indicators

Introduction to indicators

[Video]

The SMA and RSI functions

# Create a 200-day SMA
spy_sma <- SMA(x = Cl(SPY), n = 200)

# Create an RSI with a 3-day lookback period
spy_rsi <- RSI(price = Cl(SPY), n = 3)

Visualize an indicator and guess its purpose - I

# Plot the closing prices of SPY
plot(Cl(SPY))

# Overlay a 200-day SMA
lines(SMA(Cl(SPY), n = 200), col = "red")

# What kind of indicator?
"trend"
## [1] "trend"

Visualize an indicator and guess its purpose - II

# Plot the closing price of SPY
plot(Cl(SPY))

# Plot the RSI 2
plot(RSI(Cl(SPY), n = 2))

# What kind of indicator?
"reversion"
## [1] "reversion"

Indicator mechanics

[Video]

Implementing an indicator - I

# Add a 200-day SMA indicator to strategy.st
add.indicator(strategy = strategy.st, 
              
              # Add the SMA function
              name = "SMA", 
              
              # Create a lookback period
              arguments = list(x = quote(Cl(mktdata)), n = 200), 
              
              # Label your indicator SMA200
              label = "SMA200")
## [1] "firststrat"

Implementing an indicator - II

# Add a 50-day SMA indicator to strategy.st
add.indicator(strategy = strategy.st, 
              
              # Add the SMA function
              name = "SMA", 
              
              # Create a lookback period
              arguments = list(x = quote(Cl(mktdata)), n = 50), 
              
              # Label your indicator SMA50
              label = "SMA50")
## [1] "firststrat"

Implementing an indicator - III

# Add an RSI 3 indicator to strategy.st
add.indicator(strategy = strategy.st, 
              
              # Add the RSI 3 function
              name = "RSI", 
              
              # Create a lookback period
              arguments = list(price = quote(Cl(mktdata)), n = 3), 
              
              # Label your indicator RSI_3
              label = "RSI_3")
## [1] "firststrat"

Indicator structure review

[Video]

Code your own indicator - I

# Write the calc_RSI_avg function
calc_RSI_avg <- function(price, n1, n2) {
  
  # RSI 1 takes an input of the price and n1
  RSI_1 <- RSI(price = price, n = n1)
  
  # RSI 2 takes an input of the price and n2
  RSI_2 <- RSI(price = price, n = n2)
  
  # RSI_avg is the average of RSI_1 and RSI_2
  x <- (RSI_1 + RSI_2)/2
  
  # Your output of RSI_avg needs a column name of"RSI_avg"
  colnames(x) <- "RSI_avg"
  return(x)
}

# Add this function as RSI_3_4 to your strategy with n1 = 3 and n2 = 4
add.indicator(strategy.st, name = "calc_RSI_avg", arguments = list(price=quote(Cl(mktdata)), n1 = 3, n2 = 4), label = "RSI_3_4")
## [1] "firststrat"

Code your own indicator - II

# Delare the DVO function
DVO <- function(HLC, navg = 2, percentlookback = 126) {
  
  # Compute the ratio between closing prices to the average of high and low
  ratio <- Cl(HLC)/((Hi(HLC) + Lo(HLC))/2)
  
  # Smooth out the ratio outputs using a moving average
  avgratio <- SMA(ratio, n = navg)
  
  # Convert ratio into a 0-100 value using runPercentRank()
  out <- runPercentRank(avgratio, n = percentlookback, exact.multiplier = 1) * 100
  colnames(out) <- "DVO"
  return(out)
}

Apply your own indicator

# Add the DVO indicator to your strategy
add.indicator(strategy = strategy.st, name = "DVO",
              arguments = list(HLC = quote(HLC(mktdata)), navg = 2, percentlookback = 126),
              label = "DVO_2_126")
## [1] "firststrat"
# Use applyIndicators to test out your indicators
test <- applyIndicators(strategy = strategy.st, mktdata = OHLC(SPY))

# Subset your data between Sep. 1 and Sep. 5 of 2013
test_subset <- test["2013-09-01/2013-09-05"]

Ch. 4 - Signals

Introduction to signals

[Video]

Signal or not? - I

Welcome to the chapter on signals! A signal is an interaction of market data with indicators, or indicators with other indicators, which tells you whether you may wish to buy or sell an asset. Signals can be triggered for a variety of reasons. For example, a signal may be triggered by a shorter lookback moving average going from less than to greater than a longer lookback moving average. Another signal may be triggered when an oscillator goes from being above a certain set quantity (for example, 20) to below, and so on.

In this chapter, you will see various ways in which indicators interact with each other. You will focus on the strategy you developed in the previous chapter (strategy.st). To keep thing simple, you will remove all of the RSI indicators and stick to the DVO (David Varadi’s Oscillator) indicator you implemented near the end of Chapter 3.

For this exercise the dataset test is preloaded in your workspace. Subset test between September 10th, 2010, and October 10th, 2010, using

test["YYYY-MM-DD/YYYY-MM-DD"]

Is SMA50 greater than or less than SMA200 on September 20?

  • [*] SMA50 < SMA200
  • SMA50 > SMA200

Signal or not? - II

In this exercise, you will manually do a sigThreshold-type evaluation without yet calling the signal. Recall from the video that a sigThreshold is a signal threshold argument which assesses whether or not a value is above or below a certain static quantity. As in the previous exercise, you will be presented with a dataset called test that is the application of your simple moving averages and the DVO you implemented in Chapter Three.

The dataset test is loaded in your workspace. Subset test between September 10th, 2010, and October 10th, 2010, using

test["YYYY-MM-DD/YYYY-MM-DD"]

Is DVO greater or smaller than 20 on September 30?

  • [*] DVO < 20
  • DVO > 20

sigComparison and sigCrossover

[Video]

Using sigComparison

# Add a sigComparison which specifies that SMA50 must be greater than SMA200, call it longfilter
add.signal(strategy.st, name = "sigComparison", 
           
           # We are interested in the relationship between the SMA50 and the SMA200
           arguments = list(columns = c("SMA50", "SMA200"), 
                            
                            # Particularly, we are interested when the SMA50 is greater than the SMA200
                            relationship = "gt"),
           
           # Label this signal longfilter
           label = "longfilter")
## [1] "firststrat"

Using sigCrossover

# Add a sigCrossover which specifies that the SMA50 is less than the SMA200 and label it filterexit
add.signal(strategy.st, name = "sigCrossover",
           
           # We're interested in the relationship between the SMA50 and the SMA200
           arguments = list(columns = c("SMA50", "SMA200"),
                            
                            # The relationship is that the SMA50 crosses under the SMA200
                            relationship = "lt"),
           
           # Label it filterexit
           label = "filterexit")
## [1] "firststrat"

sigThreshold

[Video]

Using sigThreshold - I

# Implement a sigThreshold which specifies that DVO_2_126 must be less than 20, label it longthreshold
add.signal(strategy.st, name = "sigThreshold", 
           
           # Use the DVO_2_126 column
           arguments = list(column = "DVO_2_126", 
                            
                            # The threshold is 20
                            threshold = 20, 
                            
                            # We want the oscillator to be under this value
                            relationship = "lt", 
                            
                            # We're interested in every instance that the oscillator is less than 20
                            cross = FALSE), 
           
           # Label it longthreshold
           label = "longthreshold")
## [1] "firststrat"

Using sigThreshold() - II

# Add a sigThreshold signal to your strategy that specifies that DVO_2_126 must cross above 80 and label it thresholdexit
add.signal(strategy.st, name = "sigThreshold", 
           
           # Reference the column of DVO_2_126
           arguments = list(column = "DVO_2_126", 
                            
                            # Set a threshold of 80
                            threshold = 80, 
                            
                            # The oscillator must be greater than 80
                            relationship = "gt", 
                            
                            # We are interested only in the cross
                            cross = TRUE), 
           
           # Label it thresholdexit
           label = "thresholdexit")
## [1] "firststrat"

sigFormula

[Video]

Using sigFormula()

# Create your dataset: test
test_init <- applyIndicators(strategy.st, mktdata = OHLC(SPY))
test <- applySignals(strategy = strategy.st, mktdata = test_init)

Combining signals - I

In the previous exercise, you created a dataset test containing information about whether longfilter is equal to 1 AND longthreshold is equal to 1.

Next, you’ll want to create a signal when BOTH longfilter and longthreshold are equal to 1. You will learn how to do just this in the next exercise. For now, let’s inspect the data set test which was created in the previous exercise. This data is loaded in your workspace.

Have a look at test on October 8, 2013. Are longfilter and longthreshold both equal to 1 on that date?

  • longfilter = 1, longthreshold = 0
  • [*] longfilter = 1, longthreshold = 1
  • longfilter = 0, longthreshold = 1
  • longfilter = 0, longthreshold = 0

Combining signals - II

# Add a sigFormula signal to your code specifying that both longfilter and longthreshold must be TRUE, label it longentry
add.signal(strategy.st, name = "sigFormula",
           
           # Specify that longfilter and longthreshold must be TRUE
           arguments = list(formula = "longfilter & longthreshold", 
                            
                            # Specify that cross must be TRUE
                            cross = TRUE),
           
           # Label it longentry
           label = "longentry")
## [1] "firststrat"

Ch. 5 - Rules

Introduction to rules

[Video]

Using add.rule() to implement an exit rule

# Fill in the rule's type as exit
add.rule(strategy.st, name = "ruleSignal", 
         arguments = list(sigcol = "filterexit", sigval = TRUE, orderqty = "all", 
                        ordertype = "market", orderside = "long", 
                        replace = FALSE, prefer = "Open"), 
         type = "exit")
## [1] "firststrat"

Specifying sigcol in add.rule()

# Fill in the sigcol argument in add.rule()
add.rule(strategy.st, name = "ruleSignal", 
         arguments = list(sigcol = "filterexit", sigval = TRUE, orderqty = "all", 
                        ordertype = "market", orderside = "long", 
                        replace = FALSE, prefer = "Open"), 
         type = "exit")
## [1] "firststrat"

Specifying sigval in add.rule()

# Fill in the sigval argument in add.rule()
add.rule(strategy.st, name = "ruleSignal", 
         arguments = list(sigcol = "filterexit", sigval = TRUE, orderqty = "all", 
                        ordertype = "market", orderside = "long", 
                        replace = FALSE, prefer = "Open"), 
         type = "exit")
## [1] "firststrat"

More rule mechanics

[Video]

Specifying orderqty in add.rule()

# Fill in the orderqty argument in add.rule()
add.rule(strategy.st, name = "ruleSignal", 
         arguments = list(sigcol = "filterexit", sigval = TRUE, orderqty = "all", 
                        ordertype = "market", orderside = "long", 
                        replace = FALSE, prefer = "Open"), 
         type = "exit")
## [1] "firststrat"

Specifying ordertype in add.rule()

# Fill in the ordertype argument in add.rule()
add.rule(strategy.st, name = "ruleSignal", 
         arguments = list(sigcol = "filterexit", sigval = TRUE, orderqty = "all", 
                        ordertype = "market", orderside = "long", 
                        replace = FALSE, prefer = "Open"), 
         type = "exit")
## [1] "firststrat"

Specifying orderside in add.rule()

# Fill in the orderside argument in add.rule()
add.rule(strategy.st, name = "ruleSignal", 
         arguments = list(sigcol = "filterexit", sigval = TRUE, orderqty = "all", 
                        ordertype = "market", orderside = "long", 
                        replace = FALSE, prefer = "Open"), 
         type = "exit")
## [1] "firststrat"

More rule mechanics II

[Video]

Specifying replace in add.rule()

# Fill in the replace argument in add.rule()
add.rule(strategy.st, name = "ruleSignal", 
         arguments = list(sigcol = "thresholdexit", sigval = TRUE, orderqty = "all", 
                        ordertype = "market", orderside = "long", 
                        replace = FALSE, prefer = "Open"), 
         type = "exit")
## [1] "firststrat"

Specifying prefer in add.rule()

# Fill in the prefer argument in add.rule()
add.rule(strategy.st, name = "ruleSignal", 
         arguments = list(sigcol = "thresholdexit", sigval = TRUE, orderqty = "all", 
                        ordertype = "market", orderside = "long", 
                        replace = FALSE, prefer = "Open"), 
         type = "exit")
## [1] "firststrat"

Using add.rule() to implement an entry rule

# Create an entry rule of 1 share when all conditions line up to enter into a position
add.rule(strategy.st, name = "ruleSignal", 
         
         # Use the longentry column as the sigcol
         arguments = list(sigcol = "longentry", 
                        
                        # Set sigval to TRUE
                        sigval = TRUE, 
                        
                        # Set orderqty to 1
                        orderqty = 1,
                        
                        # Use a market type of order
                        ordertype = "market", 
                        
                        # Take the long orderside
                        orderside = "long", 
                        
                        # Do not replace other signals
                        replace = FALSE, 
                        
                        # Buy at the next day's opening price
                        prefer = "Open"), 
         
         # This is an enter type rule, not an exit
         type = "enter")
## [1] "firststrat"

Order sizing functions

[Video]

Implementing a rule with an order sizing function

# Add a rule that uses an osFUN to size an entry position
add.rule(strategy = strategy.st, name = "ruleSignal",
         arguments = list(sigcol = "longentry", sigval = TRUE, ordertype = "market",
                          orderside = "long", replace = FALSE, prefer = "Open",
                          
                          # Use the osFUN called osMaxDollar
                          osFUN = osMaxDollar,
                          
                          # The tradeSize argument should be equal to tradesize (defined earlier)
                          tradeSize = tradesize,
                          
                          # The maxSize argument should be equal to tradesize as well
                          maxSize = tradesize),
         type = "enter")
## [1] "firststrat"

Ch. 6 - Analyzing results

Analyzing your strategy

[Video]

Running your strategy

# Use applyStrategy() to apply your strategy. Save this to out
out <- applyStrategy(strategy = strategy.st, portfolios = portfolio.st)
## [1] "2003-11-04 00:00:00 SPY 1 @ 82.8469578360576"
## [1] "2003-11-04 00:00:00 SPY 1209 @ 82.8469578360576"
## [1] "2003-11-07 00:00:00 SPY -1210 @ 83.3550303566401"
## [1] "2003-11-11 00:00:00 SPY 1 @ 82.1434723265441"
## [1] "2003-11-11 00:00:00 SPY 1209 @ 82.1434723265441"
## [1] "2003-11-14 00:00:00 SPY -1210 @ 83.1674369825957"
## [1] "2003-11-17 00:00:00 SPY 1 @ 82.0027817904916"
## [1] "2003-11-17 00:00:00 SPY 1202 @ 82.0027817904916"
## [1] "2003-11-19 00:00:00 SPY 1 @ 81.3149269126141"
## [1] "2003-11-19 00:00:00 SPY 12 @ 81.3149269126141"
## [1] "2003-12-04 00:00:00 SPY 1 @ 83.7693034544295"
## [1] "2003-12-12 00:00:00 SPY -1217 @ 84.394624862679"
## [1] "2003-12-17 00:00:00 SPY 1 @ 84.4649709123541"
## [1] "2003-12-17 00:00:00 SPY 1188 @ 84.4649709123541"
## [1] "2003-12-19 00:00:00 SPY -1189 @ 85.8379047354679"
## [1] "2004-01-26 00:00:00 SPY 1 @ 89.8352933883476"
## [1] "2004-01-26 00:00:00 SPY 1107 @ 89.8352933883476"
## [1] "2004-01-29 00:00:00 SPY 1 @ 89.1834585776171"
## [1] "2004-02-05 00:00:00 SPY 1 @ 88.8771751199046"
## [1] "2004-02-05 00:00:00 SPY 15 @ 88.8771751199046"
## [1] "2004-02-12 00:00:00 SPY -1125 @ 91.0761356338675"
## [1] "2004-02-17 00:00:00 SPY 1 @ 90.9818922139293"
## [1] "2004-02-17 00:00:00 SPY 1099 @ 90.9818922139293"
## [1] "2004-02-20 00:00:00 SPY 1 @ 90.691319526913"
## [1] "2004-03-04 00:00:00 SPY 1 @ 90.8798000840517"
## [1] "2004-03-04 00:00:00 SPY 3 @ 90.8798000840517"
## [1] "2004-03-09 00:00:00 SPY 1 @ 90.3928855644821"
## [1] "2004-03-18 00:00:00 SPY -1106 @ 88.5080635009088"
## [1] "2004-03-23 00:00:00 SPY 1 @ 86.8875112703844"
## [1] "2004-03-23 00:00:00 SPY 1147 @ 86.8875112703844"
## [1] "2004-03-31 00:00:00 SPY -1148 @ 89.0468909266731"
## [1] "2004-04-14 00:00:00 SPY 1 @ 88.7474170616372"
## [1] "2004-04-14 00:00:00 SPY 1100 @ 88.7474170616372"
## [1] "2004-04-21 00:00:00 SPY 1 @ 88.4242948197242"
## [1] "2004-04-21 00:00:00 SPY 11 @ 88.4242948197242"
## [1] "2004-04-23 00:00:00 SPY -1113 @ 90.1738672633321"
## [1] "2004-04-29 00:00:00 SPY 1 @ 88.8341075490725"
## [1] "2004-04-29 00:00:00 SPY 1114 @ 88.8341075490725"
## [1] "2004-05-10 00:00:00 SPY 1 @ 86.2491556209151"
## [1] "2004-05-10 00:00:00 SPY 25 @ 86.2491556209151"
## [1] "2004-05-13 00:00:00 SPY -1141 @ 86.5013461298178"
## [1] "2004-05-20 00:00:00 SPY 1 @ 86.2570326338416"
## [1] "2004-05-20 00:00:00 SPY 1148 @ 86.2570326338416"
## [1] "2004-05-26 00:00:00 SPY -1149 @ 87.9987288526183"
## [1] "2004-06-07 00:00:00 SPY 1 @ 89.393654452605"
## [1] "2004-06-07 00:00:00 SPY 1123 @ 89.393654452605"
## [1] "2004-06-09 00:00:00 SPY -1124 @ 90.2447989963423"
## [1] "2004-06-22 00:00:00 SPY 1 @ 89.4826721872208"
## [1] "2004-06-22 00:00:00 SPY 1111 @ 89.4826721872208"
## [1] "2004-06-24 00:00:00 SPY -1112 @ 90.6137630924066"
## [1] "2004-06-28 00:00:00 SPY 1 @ 90.5821234171208"
## [1] "2004-06-28 00:00:00 SPY 1105 @ 90.5821234171208"
## [1] "2004-07-06 00:00:00 SPY 1 @ 88.8815381310937"
## [1] "2004-07-06 00:00:00 SPY 11 @ 88.8815381310937"
## [1] "2004-07-16 00:00:00 SPY 1 @ 88.248758071904"
## [1] "2004-07-16 00:00:00 SPY 13 @ 88.248758071904"
## [1] "2004-07-22 00:00:00 SPY 1 @ 86.5007105045458"
## [1] "2004-07-29 00:00:00 SPY -1133 @ 87.4340575917991"
## [1] "2004-08-06 00:00:00 SPY 1 @ 85.1323255940912"
## [1] "2004-08-06 00:00:00 SPY 1146 @ 85.1323255940912"
## [1] "2004-08-12 00:00:00 SPY -1147 @ 85.1718765723996"
## [1] "2004-11-11 00:00:00 SPY 1 @ 93.0719232673771"
## [1] "2004-11-11 00:00:00 SPY 1075 @ 93.0719232673771"
## [1] "2004-11-15 00:00:00 SPY -1076 @ 94.3992829595591"
## [1] "2004-11-30 00:00:00 SPY 1 @ 94.0009737487592"
## [1] "2004-11-30 00:00:00 SPY 1056 @ 94.0009737487592"
## [1] "2004-12-06 00:00:00 SPY 1 @ 94.9648812422764"
## [1] "2004-12-08 00:00:00 SPY 1 @ 94.1682628206767"
## [1] "2004-12-10 00:00:00 SPY -1059 @ 94.7338611033941"
## [1] "2004-12-28 00:00:00 SPY 1 @ 96.5580225549442"
## [1] "2004-12-28 00:00:00 SPY 1030 @ 96.5580225549442"
## [1] "2005-01-03 00:00:00 SPY 1 @ 97.2943727284263"
## [1] "2005-01-19 00:00:00 SPY -1032 @ 95.5895617483965"
## [1] "2005-01-21 00:00:00 SPY 1 @ 94.2769368997169"
## [1] "2005-01-21 00:00:00 SPY 1059 @ 94.2769368997169"
## [1] "2005-02-07 00:00:00 SPY -1060 @ 96.2458745729271"
## [1] "2005-02-10 00:00:00 SPY 1 @ 95.7736526933884"
## [1] "2005-02-10 00:00:00 SPY 1037 @ 95.7736526933884"
## [1] "2005-02-14 00:00:00 SPY -1038 @ 96.5980440307552"
## [1] "2005-02-23 00:00:00 SPY 1 @ 95.1893710017315"
## [1] "2005-02-23 00:00:00 SPY 1042 @ 95.1893710017315"
## [1] "2005-02-25 00:00:00 SPY -1043 @ 96.2618798016492"
## [1] "2005-03-10 00:00:00 SPY 1 @ 97.006234590446"
## [1] "2005-03-10 00:00:00 SPY 1024 @ 97.006234590446"
## [1] "2005-03-17 00:00:00 SPY 1 @ 95.4935143684339"
## [1] "2005-03-17 00:00:00 SPY 18 @ 95.4935143684339"
## [1] "2005-03-23 00:00:00 SPY 1 @ 93.9722829469485"
## [1] "2005-03-23 00:00:00 SPY 7 @ 93.9722829469485"
## [1] "2005-04-01 00:00:00 SPY -1052 @ 95.3222054728198"
## [1] "2005-04-04 00:00:00 SPY 1 @ 94.3017315393874"
## [1] "2005-04-04 00:00:00 SPY 1049 @ 94.3017315393874"
## [1] "2005-04-06 00:00:00 SPY -1050 @ 95.1775709164764"
## [1] "2005-04-12 00:00:00 SPY 1 @ 94.7275983482366"
## [1] "2005-04-12 00:00:00 SPY 1052 @ 94.7275983482366"
## [1] "2005-04-13 00:00:00 SPY -1053 @ 95.2659595044338"
## [1] "2005-04-15 00:00:00 SPY 1 @ 93.0000181217213"
## [1] "2005-04-15 00:00:00 SPY 1060 @ 93.0000181217213"
## [1] "2005-04-21 00:00:00 SPY 1 @ 92.2366714849296"
## [1] "2005-04-21 00:00:00 SPY 17 @ 92.2366714849296"
## [1] "2005-04-25 00:00:00 SPY -1079 @ 93.0964435698595"
## [1] "2005-05-16 00:00:00 SPY 1 @ 92.9678763056753"
## [1] "2005-05-16 00:00:00 SPY 1070 @ 92.9678763056753"
## [1] "2005-05-17 00:00:00 SPY -1071 @ 93.5383849025957"
## [1] "2005-06-09 00:00:00 SPY 1 @ 96.2141193737957"
## [1] "2005-06-09 00:00:00 SPY 1033 @ 96.2141193737957"
## [1] "2005-06-13 00:00:00 SPY -1034 @ 96.3748276505007"
## [1] "2005-06-24 00:00:00 SPY 1 @ 96.7153856513278"
## [1] "2005-06-24 00:00:00 SPY 1021 @ 96.7153856513278"
## [1] "2005-07-01 00:00:00 SPY 1 @ 96.3684752670201"
## [1] "2005-07-01 00:00:00 SPY 9 @ 96.3684752670201"
## [1] "2005-07-06 00:00:00 SPY -1032 @ 97.12683911602"
## [1] "2005-08-08 00:00:00 SPY 1 @ 99.3535221425788"
## [1] "2005-08-08 00:00:00 SPY 1004 @ 99.3535221425788"
## [1] "2005-08-18 00:00:00 SPY 1 @ 98.4660777801881"
## [1] "2005-08-18 00:00:00 SPY 9 @ 98.4660777801881"
## [1] "2005-08-26 00:00:00 SPY 1 @ 98.0062198288965"
## [1] "2005-08-26 00:00:00 SPY 6 @ 98.0062198288965"
## [1] "2005-08-31 00:00:00 SPY -1022 @ 97.7722562048044"
## [1] "2005-09-14 00:00:00 SPY 1 @ 99.829512233509"
## [1] "2005-09-14 00:00:00 SPY 998 @ 99.829512233509"
## [1] "2005-09-21 00:00:00 SPY 1 @ 98.6745715803002"
## [1] "2005-09-21 00:00:00 SPY 2 @ 98.6745715803002"
## [1] "2005-09-30 00:00:00 SPY -1002 @ 99.3470413322365"
## [1] "2005-10-05 00:00:00 SPY 1 @ 98.2370613833183"
## [1] "2005-10-05 00:00:00 SPY 1005 @ 98.2370613833183"
## [1] "2005-10-11 00:00:00 SPY 1 @ 96.406001958985"
## [1] "2005-10-11 00:00:00 SPY 25 @ 96.406001958985"
## [1] "2005-10-17 00:00:00 SPY -1032 @ 96.2520675220569"
## [1] "2005-10-24 00:00:00 SPY 1 @ 95.9603937873348"
## [1] "2005-10-24 00:00:00 SPY 1043 @ 95.9603937873348"
## [1] "2005-10-25 00:00:00 SPY -1044 @ 96.9974522643129"
## [1] "2005-10-28 00:00:00 SPY 1 @ 95.9522901412486"
## [1] "2005-10-28 00:00:00 SPY 1035 @ 95.9522901412486"
## [1] "2005-11-02 00:00:00 SPY 1 @ 97.3620409893546"
## [1] "2005-11-03 00:00:00 SPY -1037 @ 98.9662453150223"
## [1] "2005-11-30 00:00:00 SPY 1 @ 102.215159233548"
## [1] "2005-11-30 00:00:00 SPY 974 @ 102.215159233548"
## [1] "2005-12-08 00:00:00 SPY 1 @ 102.263768957027"
## [1] "2005-12-19 00:00:00 SPY 1 @ 103.221266810963"
## [1] "2005-12-28 00:00:00 SPY 1 @ 102.414910243219"
## [1] "2006-01-03 00:00:00 SPY 1 @ 101.966939892734"
## [1] "2006-01-03 00:00:00 SPY 5 @ 101.966939892734"
## [1] "2006-01-04 00:00:00 SPY -984 @ 103.327149853062"
## [1] "2006-01-23 00:00:00 SPY 1 @ 102.797724868596"
## [1] "2006-01-23 00:00:00 SPY 957 @ 102.797724868596"
## [1] "2006-01-30 00:00:00 SPY -958 @ 104.614056670089"
## [1] "2006-02-01 00:00:00 SPY 1 @ 104.109066609722"
## [1] "2006-02-01 00:00:00 SPY 956 @ 104.109066609722"
## [1] "2006-02-06 00:00:00 SPY 1 @ 102.985061730178"
## [1] "2006-02-06 00:00:00 SPY 12 @ 102.985061730178"
## [1] "2006-02-09 00:00:00 SPY 1 @ 103.376017257767"
## [1] "2006-02-09 00:00:00 SPY 5 @ 103.376017257767"
## [1] "2006-02-15 00:00:00 SPY -976 @ 103.995036963928"
## [1] "2006-03-01 00:00:00 SPY 1 @ 104.744379523272"
## [1] "2006-03-01 00:00:00 SPY 950 @ 104.744379523272"
## [1] "2006-03-03 00:00:00 SPY -951 @ 104.801387830189"
## [1] "2006-03-07 00:00:00 SPY 1 @ 104.141647323017"
## [1] "2006-03-07 00:00:00 SPY 950 @ 104.141647323017"
## [1] "2006-03-09 00:00:00 SPY -951 @ 104.483734631404"
## [1] "2006-03-22 00:00:00 SPY 1 @ 105.905045203611"
## [1] "2006-03-22 00:00:00 SPY 938 @ 105.905045203611"
## [1] "2006-04-06 00:00:00 SPY -939 @ 107.000821058813"
## [1] "2006-04-10 00:00:00 SPY 1 @ 106.093132767411"
## [1] "2006-04-10 00:00:00 SPY 933 @ 106.093132767411"
## [1] "2006-04-19 00:00:00 SPY -934 @ 106.919042506118"
## [1] "2006-05-15 00:00:00 SPY 1 @ 105.31627331495"
## [1] "2006-05-15 00:00:00 SPY 938 @ 105.31627331495"
## [1] "2006-05-18 00:00:00 SPY 1 @ 104.138736897255"
## [1] "2006-05-18 00:00:00 SPY 11 @ 104.138736897255"
## [1] "2006-05-24 00:00:00 SPY 1 @ 102.773118639915"
## [1] "2006-05-24 00:00:00 SPY 10 @ 102.773118639915"
## [1] "2006-05-26 00:00:00 SPY -962 @ 104.678440509468"
## [1] "2006-06-06 00:00:00 SPY 1 @ 104.024254610205"
## [1] "2006-06-06 00:00:00 SPY 949 @ 104.024254610205"
## [1] "2006-06-08 00:00:00 SPY 1 @ 102.691346629112"
## [1] "2006-06-08 00:00:00 SPY 13 @ 102.691346629112"
## [1] "2006-06-13 00:00:00 SPY 1 @ 101.186708266684"
## [1] "2006-06-13 00:00:00 SPY 7 @ 101.186708266684"
## [1] "2006-06-16 00:00:00 SPY -972 @ 102.907052003296"
## [1] "2006-06-20 00:00:00 SPY 1 @ 101.855723704104"
## [1] "2006-06-20 00:00:00 SPY 970 @ 101.855723704104"
## [1] "2006-06-30 00:00:00 SPY -971 @ 104.755091473002"
## [1] "2006-07-14 00:00:00 SPY 1 @ 101.9542817024"
## [1] "2006-07-14 00:00:00 SPY 970 @ 101.9542817024"
## [1] "2006-07-19 00:00:00 SPY -971 @ 101.995351710224"
## [1] "2006-07-24 00:00:00 SPY 1 @ 102.208904580536"
## [1] "2006-07-24 00:00:00 SPY 972 @ 102.208904580536"
## [1] "2006-07-26 00:00:00 SPY -973 @ 103.974804034594"
## [1] "2006-10-03 00:00:00 SPY 1 @ 109.629354814303"
## [1] "2006-10-03 00:00:00 SPY 907 @ 109.629354814303"
## [1] "2006-10-05 00:00:00 SPY -908 @ 111.304029224103"
## [1] "2006-11-02 00:00:00 SPY 1 @ 112.61571818925"
## [1] "2006-11-02 00:00:00 SPY 876 @ 112.61571818925"
## [1] "2006-11-09 00:00:00 SPY -877 @ 114.678126113835"
## [1] "2006-11-28 00:00:00 SPY 1 @ 114.042912722695"
## [1] "2006-11-28 00:00:00 SPY 864 @ 114.042912722695"
## [1] "2006-11-30 00:00:00 SPY -865 @ 115.85782922144"
## [1] "2006-12-08 00:00:00 SPY 1 @ 116.427056283516"
## [1] "2006-12-08 00:00:00 SPY 853 @ 116.427056283516"
## [1] "2006-12-19 00:00:00 SPY 1 @ 117.424163570766"
## [1] "2006-12-22 00:00:00 SPY 1 @ 117.498820616338"
## [1] "2007-01-03 00:00:00 SPY 1 @ 118.004852800614"
## [1] "2007-01-11 00:00:00 SPY -857 @ 117.449049529143"
## [1] "2007-01-18 00:00:00 SPY 1 @ 118.768045971558"
## [1] "2007-01-18 00:00:00 SPY 843 @ 118.768045971558"
## [1] "2007-01-25 00:00:00 SPY -844 @ 119.340444582785"
## [1] "2007-01-26 00:00:00 SPY 1 @ 118.270317678858"
## [1] "2007-01-26 00:00:00 SPY 837 @ 118.270317678858"
## [1] "2007-02-01 00:00:00 SPY -838 @ 119.581011059258"
## [1] "2007-02-13 00:00:00 SPY 1 @ 119.265786707653"
## [1] "2007-02-13 00:00:00 SPY 837 @ 119.265786707653"
## [1] "2007-02-22 00:00:00 SPY -838 @ 121.157181761295"
## [1] "2007-02-27 00:00:00 SPY 1 @ 119.357039092981"
## [1] "2007-02-27 00:00:00 SPY 826 @ 119.357039092981"
## [1] "2007-03-02 00:00:00 SPY -827 @ 116.179824173923"
## [1] "2007-03-06 00:00:00 SPY 1 @ 115.126280166357"
## [1] "2007-03-06 00:00:00 SPY 873 @ 115.126280166357"
## [1] "2007-03-09 00:00:00 SPY 1 @ 117.225065119473"
## [1] "2007-03-14 00:00:00 SPY 1 @ 114.835929329737"
## [1] "2007-03-16 00:00:00 SPY -876 @ 116.024319765602"
## [1] "2007-03-19 00:00:00 SPY 1 @ 115.982674771383"
## [1] "2007-03-19 00:00:00 SPY 861 @ 115.982674771383"
## [1] "2007-03-21 00:00:00 SPY -862 @ 117.51512777333"
## [1] "2007-05-01 00:00:00 SPY 1 @ 123.611582476384"
## [1] "2007-05-01 00:00:00 SPY 802 @ 123.611582476384"
## [1] "2007-05-11 00:00:00 SPY 1 @ 124.719274526864"
## [1] "2007-05-16 00:00:00 SPY 1 @ 125.59376943445"
## [1] "2007-05-23 00:00:00 SPY 1 @ 127.384391751092"
## [1] "2007-05-31 00:00:00 SPY -806 @ 127.984044521567"
## [1] "2007-06-07 00:00:00 SPY 1 @ 126.22673120436"
## [1] "2007-06-07 00:00:00 SPY 785 @ 126.22673120436"
## [1] "2007-06-12 00:00:00 SPY -786 @ 125.485494781463"
## [1] "2007-06-13 00:00:00 SPY 1 @ 125.34391196189"
## [1] "2007-06-13 00:00:00 SPY 796 @ 125.34391196189"
## [1] "2007-06-15 00:00:00 SPY -797 @ 128.092344289999"
## [1] "2007-06-19 00:00:00 SPY 1 @ 127.598848330385"
## [1] "2007-06-19 00:00:00 SPY 779 @ 127.598848330385"
## [1] "2007-06-21 00:00:00 SPY 1 @ 126.36928142802"
## [1] "2007-06-26 00:00:00 SPY 1 @ 125.64158324467"
## [1] "2007-06-26 00:00:00 SPY 14 @ 125.64158324467"
## [1] "2007-06-29 00:00:00 SPY -796 @ 126.218715626391"
## [1] "2007-07-11 00:00:00 SPY 1 @ 126.093254719933"
## [1] "2007-07-11 00:00:00 SPY 785 @ 126.093254719933"
## [1] "2007-07-13 00:00:00 SPY -786 @ 129.288459467415"
## [1] "2007-07-18 00:00:00 SPY 1 @ 129.004060836367"
## [1] "2007-07-18 00:00:00 SPY 771 @ 129.004060836367"
## [1] "2007-07-23 00:00:00 SPY 1 @ 128.962236352017"
## [1] "2007-07-30 00:00:00 SPY 1 @ 122.061610471821"
## [1] "2007-07-30 00:00:00 SPY 33 @ 122.061610471821"
## [1] "2007-08-03 00:00:00 SPY -807 @ 123.190808816308"
## [1] "2007-08-10 00:00:00 SPY 1 @ 120.773498659489"
## [1] "2007-08-10 00:00:00 SPY 810 @ 120.773498659489"
## [1] "2007-08-17 00:00:00 SPY -811 @ 121.701947341627"
## [1] "2007-08-29 00:00:00 SPY 1 @ 120.756766523718"
## [1] "2007-08-29 00:00:00 SPY 817 @ 120.756766523718"
## [1] "2007-08-31 00:00:00 SPY -818 @ 123.500287249344"
## [1] "2007-09-21 00:00:00 SPY 1 @ 128.338641306101"
## [1] "2007-09-21 00:00:00 SPY 779 @ 128.338641306101"
## [1] "2007-10-02 00:00:00 SPY -780 @ 129.93541058953"
## [1] "2007-10-22 00:00:00 SPY 1 @ 125.103067234912"
## [1] "2007-10-22 00:00:00 SPY 777 @ 125.103067234912"
## [1] "2007-10-24 00:00:00 SPY -778 @ 127.078029996201"
## [1] "2007-11-09 00:00:00 SPY 1 @ 122.43897617373"
## [1] "2007-11-09 00:00:00 SPY 804 @ 122.43897617373"
## [1] "2007-11-15 00:00:00 SPY -805 @ 123.178539010909"
## [1] "2007-11-16 00:00:00 SPY 1 @ 122.960025486859"
## [1] "2007-11-16 00:00:00 SPY 811 @ 122.960025486859"
## [1] "2007-11-27 00:00:00 SPY 1 @ 119.119368912215"
## [1] "2007-11-27 00:00:00 SPY 11 @ 119.119368912215"
## [1] "2007-11-29 00:00:00 SPY -824 @ 123.220549303015"
## [1] "2007-12-05 00:00:00 SPY 1 @ 124.321481499513"
## [1] "2007-12-05 00:00:00 SPY 811 @ 124.321481499513"
## [1] "2007-12-07 00:00:00 SPY -812 @ 127.254508015919"
## [1] "2007-12-12 00:00:00 SPY 1 @ 126.951961301543"
## [1] "2007-12-12 00:00:00 SPY 782 @ 126.951961301543"
## [1] "2007-12-18 00:00:00 SPY 1 @ 122.783546626733"
## [1] "2007-12-18 00:00:00 SPY 28 @ 122.783546626733"
## [1] "2007-12-21 00:00:00 SPY -812 @ 124.508169874045"
## [1] "2009-06-23 00:00:00 SPY 1 @ 78.4042142019373"
## [1] "2009-06-23 00:00:00 SPY 1252 @ 78.4042142019373"
## [1] "2009-06-29 00:00:00 SPY -1253 @ 80.7176949572702"
## [1] "2009-07-06 00:00:00 SPY 1 @ 77.9397662902533"
## [1] "2009-07-06 00:00:00 SPY 1252 @ 77.9397662902533"
## [1] "2009-07-14 00:00:00 SPY -1253 @ 79.2016605024789"
## [1] "2009-08-26 00:00:00 SPY 1 @ 90.1205877365573"
## [1] "2009-08-26 00:00:00 SPY 1103 @ 90.1205877365573"
## [1] "2009-09-02 00:00:00 SPY 1 @ 87.4390558536496"
## [1] "2009-09-02 00:00:00 SPY 15 @ 87.4390558536496"
## [1] "2009-09-08 00:00:00 SPY -1120 @ 90.2608021966999"
## [1] "2009-09-24 00:00:00 SPY 1 @ 93.6932113415245"
## [1] "2009-09-24 00:00:00 SPY 1058 @ 93.6932113415245"
## [1] "2009-10-02 00:00:00 SPY 1 @ 89.8278430661716"
## [1] "2009-10-02 00:00:00 SPY 43 @ 89.8278430661716"
## [1] "2009-10-15 00:00:00 SPY -1103 @ 95.7799741839858"
## [1] "2009-10-22 00:00:00 SPY 1 @ 95.2604862455034"
## [1] "2009-10-22 00:00:00 SPY 1041 @ 95.2604862455034"
## [1] "2009-10-27 00:00:00 SPY 1 @ 94.2391122942741"
## [1] "2009-10-27 00:00:00 SPY 7 @ 94.2391122942741"
## [1] "2009-11-02 00:00:00 SPY 1 @ 91.6856822589097"
## [1] "2009-11-02 00:00:00 SPY 18 @ 91.6856822589097"
## [1] "2009-11-09 00:00:00 SPY -1069 @ 95.0491636410232"
## [1] "2009-12-04 00:00:00 SPY 1 @ 98.4742786182327"
## [1] "2009-12-04 00:00:00 SPY 1018 @ 98.4742786182327"
## [1] "2010-01-04 00:00:00 SPY 1 @ 99.4736144672957"
## [1] "2010-01-06 00:00:00 SPY -1020 @ 100.491626897141"
## [1] "2010-01-22 00:00:00 SPY 1 @ 98.4378867582876"
## [1] "2010-01-22 00:00:00 SPY 991 @ 98.4378867582876"
## [1] "2010-02-01 00:00:00 SPY 1 @ 95.7379310881149"
## [1] "2010-02-01 00:00:00 SPY 43 @ 95.7379310881149"
## [1] "2010-02-03 00:00:00 SPY -1036 @ 97.2693794379058"
## [1] "2010-02-05 00:00:00 SPY 1 @ 94.3304073658146"
## [1] "2010-02-05 00:00:00 SPY 1036 @ 94.3304073658146"
## [1] "2010-02-10 00:00:00 SPY 1 @ 94.7641758730295"
## [1] "2010-02-10 00:00:00 SPY 17 @ 94.7641758730295"
## [1] "2010-02-12 00:00:00 SPY -1055 @ 94.7110574777571"
## [1] "2010-02-24 00:00:00 SPY 1 @ 97.4995417411739"
## [1] "2010-02-24 00:00:00 SPY 1018 @ 97.4995417411739"
## [1] "2010-02-26 00:00:00 SPY -1019 @ 98.0572366463451"
## [1] "2010-03-29 00:00:00 SPY 1 @ 104.149863026265"
## [1] "2010-03-29 00:00:00 SPY 962 @ 104.149863026265"
## [1] "2010-04-07 00:00:00 SPY -963 @ 105.598739021655"
## [1] "2010-04-19 00:00:00 SPY 1 @ 105.785402565728"
## [1] "2010-04-19 00:00:00 SPY 930 @ 105.785402565728"
## [1] "2010-04-21 00:00:00 SPY -931 @ 107.509821930501"
## [1] "2010-04-28 00:00:00 SPY 1 @ 105.820958584692"
## [1] "2010-04-28 00:00:00 SPY 932 @ 105.820958584692"
## [1] "2010-05-03 00:00:00 SPY 1 @ 106.114283074631"
## [1] "2010-05-06 00:00:00 SPY 1 @ 103.340987372324"
## [1] "2010-05-06 00:00:00 SPY 31 @ 103.340987372324"
## [1] "2010-05-07 00:00:00 SPY -966 @ 100.123245432919"
## [1] "2010-05-17 00:00:00 SPY 1 @ 101.509893728511"
## [1] "2010-05-17 00:00:00 SPY 977 @ 101.509893728511"
## [1] "2010-05-19 00:00:00 SPY 1 @ 99.3499195757947"
## [1] "2010-05-19 00:00:00 SPY 1 @ 99.3499195757947"
## [1] "2010-05-24 00:00:00 SPY -980 @ 96.4610652563182"
## [1] "2010-06-02 00:00:00 SPY 1 @ 96.0699632697649"
## [1] "2010-06-02 00:00:00 SPY 1038 @ 96.0699632697649"
## [1] "2010-06-04 00:00:00 SPY -1039 @ 96.5410678545244"
## [1] "2010-06-07 00:00:00 SPY 1 @ 95.2877459634846"
## [1] "2010-06-07 00:00:00 SPY 1035 @ 95.2877459634846"
## [1] "2010-06-14 00:00:00 SPY -1036 @ 98.2388217606114"
## [1] "2010-06-22 00:00:00 SPY 1 @ 99.5010824293916"
## [1] "2010-06-22 00:00:00 SPY 989 @ 99.5010824293916"
## [1] "2010-06-30 00:00:00 SPY 1 @ 92.8117037592083"
## [1] "2010-06-30 00:00:00 SPY 66 @ 92.8117037592083"
## [1] "2010-07-07 00:00:00 SPY 1 @ 92.1061481376476"
## [1] "2010-07-07 00:00:00 SPY 23 @ 92.1061481376476"
## [1] "2010-07-08 00:00:00 SPY -1081 @ 95.5624758791401"
## [1] "2010-11-16 00:00:00 SPY 1 @ 107.10912927803"
## [1] "2010-11-16 00:00:00 SPY 923 @ 107.10912927803"
## [1] "2010-11-23 00:00:00 SPY -924 @ 106.642223626306"
## [1] "2010-12-08 00:00:00 SPY 1 @ 110.42233992386"
## [1] "2010-12-08 00:00:00 SPY 898 @ 110.42233992386"
## [1] "2011-01-06 00:00:00 SPY -899 @ 115.254351213622"
## [1] "2011-01-20 00:00:00 SPY 1 @ 115.498053371796"
## [1] "2011-01-20 00:00:00 SPY 856 @ 115.498053371796"
## [1] "2011-01-26 00:00:00 SPY -857 @ 116.879053028159"
## [1] "2011-01-31 00:00:00 SPY 1 @ 115.597347760313"
## [1] "2011-01-31 00:00:00 SPY 851 @ 115.597347760313"
## [1] "2011-02-02 00:00:00 SPY -852 @ 117.700418758943"
## [1] "2011-02-23 00:00:00 SPY 1 @ 118.918948504635"
## [1] "2011-02-23 00:00:00 SPY 832 @ 118.918948504635"
## [1] "2011-02-28 00:00:00 SPY -833 @ 119.884748180783"
## [1] "2011-03-02 00:00:00 SPY 1 @ 118.016337889799"
## [1] "2011-03-02 00:00:00 SPY 829 @ 118.016337889799"
## [1] "2011-03-08 00:00:00 SPY 1 @ 118.819660434392"
## [1] "2011-03-08 00:00:00 SPY 3 @ 118.819660434392"
## [1] "2011-03-10 00:00:00 SPY -834 @ 118.241990543508"
## [1] "2011-03-11 00:00:00 SPY 1 @ 116.906130443993"
## [1] "2011-03-11 00:00:00 SPY 845 @ 116.906130443993"
## [1] "2011-03-15 00:00:00 SPY -846 @ 114.261474121639"
## [1] "2011-03-18 00:00:00 SPY 1 @ 116.797541917344"
## [1] "2011-03-18 00:00:00 SPY 865 @ 116.797541917344"
## [1] "2011-03-25 00:00:00 SPY -866 @ 118.973226180634"
## [1] "2011-03-29 00:00:00 SPY 1 @ 118.637800382539"
## [1] "2011-03-29 00:00:00 SPY 838 @ 118.637800382539"
## [1] "2011-03-31 00:00:00 SPY -839 @ 120.206110213051"
## [1] "2011-04-04 00:00:00 SPY 1 @ 120.958519747613"
## [1] "2011-04-04 00:00:00 SPY 826 @ 120.958519747613"
## [1] "2011-04-11 00:00:00 SPY 1 @ 120.568717457945"
## [1] "2011-04-18 00:00:00 SPY -828 @ 118.383972410212"
## [1] "2011-05-06 00:00:00 SPY 1 @ 122.327390788816"
## [1] "2011-05-06 00:00:00 SPY 822 @ 122.327390788816"
## [1] "2011-05-17 00:00:00 SPY 1 @ 120.287694440843"
## [1] "2011-05-17 00:00:00 SPY 2 @ 120.287694440843"
## [1] "2011-05-19 00:00:00 SPY -826 @ 122.200477255918"
## [1] "2011-05-24 00:00:00 SPY 1 @ 120.061061513291"
## [1] "2011-05-24 00:00:00 SPY 835 @ 120.061061513291"
## [1] "2011-05-27 00:00:00 SPY -836 @ 120.904129658064"
## [1] "2011-06-02 00:00:00 SPY 1 @ 119.625930825048"
## [1] "2011-06-02 00:00:00 SPY 820 @ 119.625930825048"
## [1] "2011-06-07 00:00:00 SPY 1 @ 117.577160094657"
## [1] "2011-06-07 00:00:00 SPY 26 @ 117.577160094657"
## [1] "2011-06-14 00:00:00 SPY 1 @ 116.824736962119"
## [1] "2011-06-14 00:00:00 SPY 14 @ 116.824736962119"
## [1] "2011-06-16 00:00:00 SPY 1 @ 115.183917286234"
## [1] "2011-06-22 00:00:00 SPY -864 @ 117.567909280326"
## [1] "2011-07-12 00:00:00 SPY 1 @ 119.973017034815"
## [1] "2011-07-12 00:00:00 SPY 826 @ 119.973017034815"
## [1] "2011-07-20 00:00:00 SPY -827 @ 121.230237483282"
## [1] "2011-07-28 00:00:00 SPY 1 @ 118.980002328384"
## [1] "2011-07-28 00:00:00 SPY 827 @ 118.980002328384"
## [1] "2011-08-03 00:00:00 SPY 1 @ 114.479532018588"
## [1] "2011-08-03 00:00:00 SPY 30 @ 114.479532018588"
## [1] "2011-08-05 00:00:00 SPY 1 @ 110.926528758843"
## [1] "2011-08-05 00:00:00 SPY 23 @ 110.926528758843"
## [1] "2011-08-11 00:00:00 SPY -883 @ 103.182807676692"
## [1] "2012-04-10 00:00:00 SPY 1 @ 127.684538407341"
## [1] "2012-04-10 00:00:00 SPY 782 @ 127.684538407341"
## [1] "2012-04-17 00:00:00 SPY 1 @ 127.582723059644"
## [1] "2012-04-20 00:00:00 SPY 1 @ 128.036265584381"
## [1] "2012-04-27 00:00:00 SPY -785 @ 130.118833309384"
## [1] "2012-05-07 00:00:00 SPY 1 @ 126.351693212168"
## [1] "2012-05-07 00:00:00 SPY 779 @ 126.351693212168"
## [1] "2012-05-09 00:00:00 SPY -780 @ 125.046627619274"
## [1] "2012-05-14 00:00:00 SPY 1 @ 124.315407546699"
## [1] "2012-05-14 00:00:00 SPY 799 @ 124.315407546699"
## [1] "2012-05-23 00:00:00 SPY -800 @ 121.483117291866"
## [1] "2012-06-01 00:00:00 SPY 1 @ 119.780043387983"
## [1] "2012-06-01 00:00:00 SPY 820 @ 119.780043387983"
## [1] "2012-06-06 00:00:00 SPY -821 @ 120.298368578338"
## [1] "2012-06-12 00:00:00 SPY 1 @ 121.982927066767"
## [1] "2012-06-12 00:00:00 SPY 805 @ 121.982927066767"
## [1] "2012-06-18 00:00:00 SPY -806 @ 124.280363746837"
## [1] "2012-06-22 00:00:00 SPY 1 @ 123.861694859222"
## [1] "2012-06-22 00:00:00 SPY 792 @ 123.861694859222"
## [1] "2012-06-28 00:00:00 SPY -793 @ 123.080163227625"
## [1] "2012-07-11 00:00:00 SPY 1 @ 124.866508749008"
## [1] "2012-07-11 00:00:00 SPY 790 @ 124.866508749008"
## [1] "2012-07-16 00:00:00 SPY -791 @ 126.010873352377"
## [1] "2012-07-24 00:00:00 SPY 1 @ 125.778277975289"
## [1] "2012-07-24 00:00:00 SPY 799 @ 125.778277975289"
## [1] "2012-07-30 00:00:00 SPY -800 @ 128.876450258874"
## [1] "2012-08-01 00:00:00 SPY 1 @ 129.043912417707"
## [1] "2012-08-01 00:00:00 SPY 776 @ 129.043912417707"
## [1] "2012-08-06 00:00:00 SPY -777 @ 129.992905277756"
## [1] "2012-09-26 00:00:00 SPY 1 @ 134.755594949074"
## [1] "2012-09-26 00:00:00 SPY 732 @ 134.755594949074"
## [1] "2012-10-10 00:00:00 SPY 1 @ 134.858470135761"
## [1] "2012-10-10 00:00:00 SPY 1 @ 134.858470135761"
## [1] "2012-10-17 00:00:00 SPY -735 @ 136.224083848539"
## [1] "2012-10-22 00:00:00 SPY 1 @ 133.895062616513"
## [1] "2012-10-22 00:00:00 SPY 734 @ 133.895062616513"
## [1] "2012-11-06 00:00:00 SPY 1 @ 133.081314520924"
## [1] "2012-11-06 00:00:00 SPY 21 @ 133.081314520924"
## [1] "2012-11-09 00:00:00 SPY 1 @ 128.722589033494"
## [1] "2012-11-09 00:00:00 SPY 8 @ 128.722589033494"
## [1] "2012-11-14 00:00:00 SPY 1 @ 129.274455586031"
## [1] "2012-11-14 00:00:00 SPY 11 @ 129.274455586031"
## [1] "2012-11-20 00:00:00 SPY -778 @ 129.929196389907"
## [1] "2012-12-04 00:00:00 SPY 1 @ 132.295624995064"
## [1] "2012-12-04 00:00:00 SPY 748 @ 132.295624995064"
## [1] "2012-12-13 00:00:00 SPY 1 @ 134.147610321731"
## [1] "2012-12-19 00:00:00 SPY -750 @ 136.12119556698"
## [1] "2013-02-01 00:00:00 SPY 1 @ 141.909563425788"
## [1] "2013-02-01 00:00:00 SPY 708 @ 141.909563425788"
## [1] "2013-02-06 00:00:00 SPY 1 @ 141.787115202194"
## [1] "2013-02-08 00:00:00 SPY -710 @ 142.446499686931"
## [1] "2013-02-22 00:00:00 SPY 1 @ 142.38055436199"
## [1] "2013-02-22 00:00:00 SPY 703 @ 142.38055436199"
## [1] "2013-02-26 00:00:00 SPY 1 @ 141.033526878325"
## [1] "2013-02-28 00:00:00 SPY -705 @ 143.087040766293"
## [1] "2013-04-04 00:00:00 SPY 1 @ 147.06343231595"
## [1] "2013-04-04 00:00:00 SPY 673 @ 147.06343231595"
## [1] "2013-04-08 00:00:00 SPY -674 @ 146.912055281063"
## [1] "2013-04-16 00:00:00 SPY 1 @ 147.877139820857"
## [1] "2013-04-16 00:00:00 SPY 668 @ 147.877139820857"
## [1] "2013-04-19 00:00:00 SPY 1 @ 146.18349942803"
## [1] "2013-04-19 00:00:00 SPY 11 @ 146.18349942803"
## [1] "2013-04-23 00:00:00 SPY -681 @ 148.501616806983"
## [1] "2013-05-22 00:00:00 SPY 1 @ 158.332337925907"
## [1] "2013-05-22 00:00:00 SPY 632 @ 158.332337925907"
## [1] "2013-05-28 00:00:00 SPY -633 @ 158.048483632192"
## [1] "2013-05-30 00:00:00 SPY 1 @ 156.449466068128"
## [1] "2013-05-30 00:00:00 SPY 638 @ 156.449466068128"
## [1] "2013-06-03 00:00:00 SPY 1 @ 155.011281577095"
## [1] "2013-06-06 00:00:00 SPY 1 @ 152.52284575565"
## [1] "2013-06-06 00:00:00 SPY 8 @ 152.52284575565"
## [1] "2013-06-10 00:00:00 SPY -649 @ 156.411611638063"
## [1] "2013-06-12 00:00:00 SPY 1 @ 155.380287522684"
## [1] "2013-06-12 00:00:00 SPY 647 @ 155.380287522684"
## [1] "2013-06-18 00:00:00 SPY 1 @ 155.673598800714"
## [1] "2013-06-20 00:00:00 SPY 1 @ 153.147322741777"
## [1] "2013-07-01 00:00:00 SPY 1 @ 153.386964644818"
## [1] "2013-07-01 00:00:00 SPY 4 @ 153.386964644818"
## [1] "2013-07-08 00:00:00 SPY -655 @ 155.860033234448"
## [1] "2013-07-25 00:00:00 SPY 1 @ 160.007169452897"
## [1] "2013-07-25 00:00:00 SPY 619 @ 160.007169452897"
## [1] "2013-07-29 00:00:00 SPY -620 @ 160.44470373808"
## [1] "2013-08-01 00:00:00 SPY 1 @ 161.690758373814"
## [1] "2013-08-01 00:00:00 SPY 622 @ 161.690758373814"
## [1] "2013-08-16 00:00:00 SPY 1 @ 157.952622050774"
## [1] "2013-08-16 00:00:00 SPY 4 @ 157.952622050774"
## [1] "2013-08-26 00:00:00 SPY -628 @ 158.646977258064"
## [1] "2013-08-28 00:00:00 SPY 1 @ 155.289320708327"
## [1] "2013-08-28 00:00:00 SPY 639 @ 155.289320708327"
## [1] "2013-09-10 00:00:00 SPY -640 @ 160.406662323878"
## [1] "2013-09-23 00:00:00 SPY 1 @ 162.956795401376"
## [1] "2013-09-23 00:00:00 SPY 607 @ 162.956795401376"
## [1] "2013-09-26 00:00:00 SPY 1 @ 161.838494509156"
## [1] "2013-09-26 00:00:00 SPY 8 @ 161.838494509156"
## [1] "2013-10-02 00:00:00 SPY -617 @ 160.911353621946"
## [1] "2013-10-09 00:00:00 SPY 1 @ 158.474024130731"
## [1] "2013-10-09 00:00:00 SPY 624 @ 158.474024130731"
## [1] "2013-10-11 00:00:00 SPY -625 @ 161.446607753185"
## [1] "2013-11-01 00:00:00 SPY 1 @ 168.242447868879"
## [1] "2013-11-01 00:00:00 SPY 593 @ 168.242447868879"
## [1] "2013-11-08 00:00:00 SPY 1 @ 167.143252749946"
## [1] "2013-11-12 00:00:00 SPY -595 @ 169.121795170532"
## [1] "2013-11-21 00:00:00 SPY 1 @ 171.062097370113"
## [1] "2013-11-21 00:00:00 SPY 583 @ 171.062097370113"
## [1] "2013-11-25 00:00:00 SPY -584 @ 173.12666021586"
## [1] "2013-12-12 00:00:00 SPY 1 @ 170.746676718937"
## [1] "2013-12-12 00:00:00 SPY 578 @ 170.746676718937"
## [1] "2013-12-19 00:00:00 SPY -579 @ 173.1744394642"
## [1] "2014-01-06 00:00:00 SPY 1 @ 176.334543928472"
## [1] "2014-01-06 00:00:00 SPY 567 @ 176.334543928472"
## [1] "2014-01-13 00:00:00 SPY -568 @ 176.507517838225"
## [1] "2014-01-14 00:00:00 SPY 1 @ 175.18132815125"
## [1] "2014-01-14 00:00:00 SPY 566 @ 175.18132815125"
## [1] "2014-01-16 00:00:00 SPY -567 @ 177.093730957195"
## [1] "2014-01-27 00:00:00 SPY 1 @ 172.077291529657"
## [1] "2014-01-27 00:00:00 SPY 573 @ 172.077291529657"
## [1] "2014-02-04 00:00:00 SPY 1 @ 168.12756602891"
## [1] "2014-02-04 00:00:00 SPY 10 @ 168.12756602891"
## [1] "2014-02-06 00:00:00 SPY -585 @ 168.733003062648"
## [1] "2014-02-20 00:00:00 SPY 1 @ 176.123122189186"
## [1] "2014-02-20 00:00:00 SPY 566 @ 176.123122189186"
## [1] "2014-02-25 00:00:00 SPY 1 @ 177.843312755559"
## [1] "2014-03-03 00:00:00 SPY -568 @ 177.449297461108"
## [1] "2014-03-14 00:00:00 SPY 1 @ 177.64150970068"
## [1] "2014-03-14 00:00:00 SPY 553 @ 177.64150970068"
## [1] "2014-03-21 00:00:00 SPY -554 @ 181.186138244352"
## [1] "2014-03-24 00:00:00 SPY 1 @ 180.346364511244"
## [1] "2014-03-24 00:00:00 SPY 551 @ 180.346364511244"
## [1] "2014-03-27 00:00:00 SPY 1 @ 178.329006405312"
## [1] "2014-03-27 00:00:00 SPY 1 @ 178.329006405312"
## [1] "2014-04-02 00:00:00 SPY -554 @ 181.939027382854"
## [1] "2014-04-07 00:00:00 SPY 1 @ 179.487297461871"
## [1] "2014-04-07 00:00:00 SPY 546 @ 179.487297461871"
## [1] "2014-04-10 00:00:00 SPY -547 @ 180.578029093173"
## [1] "2014-04-11 00:00:00 SPY 1 @ 175.809716093826"
## [1] "2014-04-11 00:00:00 SPY 553 @ 175.809716093826"
## [1] "2014-04-16 00:00:00 SPY -554 @ 179.023983741933"
## [1] "2014-05-15 00:00:00 SPY 1 @ 182.122412342361"
## [1] "2014-05-15 00:00:00 SPY 545 @ 182.122412342361"
## [1] "2014-05-20 00:00:00 SPY -546 @ 182.093455958798"
## [1] "2014-06-25 00:00:00 SPY 1 @ 188.436075649539"
## [1] "2014-06-25 00:00:00 SPY 527 @ 188.436075649539"
## [1] "2014-06-27 00:00:00 SPY -528 @ 189.105289001698"
## [1] "2014-07-18 00:00:00 SPY 1 @ 190.43402088343"
## [1] "2014-07-18 00:00:00 SPY 522 @ 190.43402088343"
## [1] "2014-07-22 00:00:00 SPY -523 @ 192.043994757799"
## [1] "2014-07-31 00:00:00 SPY 1 @ 189.716312081201"
## [1] "2014-07-31 00:00:00 SPY 521 @ 189.716312081201"
## [1] "2014-08-07 00:00:00 SPY 1 @ 187.126759599473"
## [1] "2014-08-07 00:00:00 SPY 17 @ 187.126759599473"
## [1] "2014-08-12 00:00:00 SPY -540 @ 187.776571668019"
## [1] "2014-08-13 00:00:00 SPY 1 @ 188.436075649539"
## [1] "2014-08-13 00:00:00 SPY 532 @ 188.436075649539"
## [1] "2014-08-15 00:00:00 SPY -533 @ 190.55040045887"
## [1] "2014-09-05 00:00:00 SPY 1 @ 194.138917313647"
## [1] "2014-09-05 00:00:00 SPY 513 @ 194.138917313647"
## [1] "2014-09-09 00:00:00 SPY -514 @ 194.37169198245"
## [1] "2014-09-10 00:00:00 SPY 1 @ 193.421208511418"
## [1] "2014-09-10 00:00:00 SPY 514 @ 193.421208511418"
## [1] "2014-09-12 00:00:00 SPY -515 @ 194.071034158147"
## [1] "2014-09-23 00:00:00 SPY 1 @ 193.350934585068"
## [1] "2014-09-23 00:00:00 SPY 512 @ 193.350934585068"
## [1] "2014-09-26 00:00:00 SPY 1 @ 191.665219949033"
## [1] "2014-09-26 00:00:00 SPY 2 @ 191.665219949033"
## [1] "2014-09-30 00:00:00 SPY -516 @ 192.629884559961"
## [1] "2014-10-02 00:00:00 SPY 1 @ 189.209718534193"
## [1] "2014-10-02 00:00:00 SPY 521 @ 189.209718534193"
## [1] "2014-10-06 00:00:00 SPY -522 @ 192.288837391702"
## [1] "2014-10-08 00:00:00 SPY 1 @ 188.420453423893"
## [1] "2014-10-08 00:00:00 SPY 525 @ 188.420453423893"
## [1] "2014-10-09 00:00:00 SPY -526 @ 191.304695423682"
## [1] "2014-10-13 00:00:00 SPY 1 @ 185.58495012661"
## [1] "2014-10-13 00:00:00 SPY 532 @ 185.58495012661"
## [1] "2014-10-16 00:00:00 SPY -533 @ 178.374353409571"
## [1] "2014-10-24 00:00:00 SPY 1 @ 190.252337396064"
## [1] "2014-10-24 00:00:00 SPY 527 @ 190.252337396064"
## [1] "2014-10-28 00:00:00 SPY -528 @ 191.782158146272"
## [1] "2014-12-02 00:00:00 SPY 1 @ 200.542039328959"
## [1] "2014-12-02 00:00:00 SPY 497 @ 200.542039328959"
## [1] "2014-12-09 00:00:00 SPY 1 @ 199.138894967333"
## [1] "2014-12-10 00:00:00 SPY -499 @ 200.639485553049"
## [1] "2014-12-12 00:00:00 SPY 1 @ 197.453180331298"
## [1] "2014-12-12 00:00:00 SPY 503 @ 197.453180331298"
## [1] "2014-12-22 00:00:00 SPY 1 @ 202.56987175323"
## [1] "2015-01-02 00:00:00 SPY 1 @ 202.207357413693"
## [1] "2015-01-09 00:00:00 SPY -506 @ 202.226942270605"
## [1] "2015-01-13 00:00:00 SPY 1 @ 199.993040916179"
## [1] "2015-01-13 00:00:00 SPY 499 @ 199.993040916179"
## [1] "2015-01-21 00:00:00 SPY -500 @ 197.4260176942"
## [1] "2015-01-29 00:00:00 SPY 1 @ 196.328667060516"
## [1] "2015-01-29 00:00:00 SPY 499 @ 196.328667060516"
## [1] "2015-02-04 00:00:00 SPY -500 @ 199.797087510418"
## [1] "2015-02-10 00:00:00 SPY 1 @ 201.717466550928"
## [1] "2015-02-10 00:00:00 SPY 498 @ 201.717466550928"
## [1] "2015-02-12 00:00:00 SPY -499 @ 203.686821940552"
## [1] "2015-03-09 00:00:00 SPY 1 @ 203.539860560413"
## [1] "2015-03-09 00:00:00 SPY 487 @ 203.539860560413"
## [1] "2015-03-12 00:00:00 SPY 1 @ 201.109992083283"
## [1] "2015-03-12 00:00:00 SPY 9 @ 201.109992083283"
## [1] "2015-03-18 00:00:00 SPY -498 @ 203.196931077787"
## [1] "2015-03-25 00:00:00 SPY 1 @ 205.75734015615"
## [1] "2015-03-25 00:00:00 SPY 484 @ 205.75734015615"
## [1] "2015-04-07 00:00:00 SPY -485 @ 204.566506426791"
## [1] "2015-04-28 00:00:00 SPY 1 @ 207.400877416595"
## [1] "2015-04-28 00:00:00 SPY 478 @ 207.400877416595"
## [1] "2015-04-30 00:00:00 SPY -479 @ 206.554503921547"
## [1] "2015-05-06 00:00:00 SPY 1 @ 206.239567359885"
## [1] "2015-05-06 00:00:00 SPY 481 @ 206.239567359885"
## [1] "2015-05-18 00:00:00 SPY -482 @ 208.877110256795"
## [1] "2015-05-27 00:00:00 SPY 1 @ 207.902791661487"
## [1] "2015-05-27 00:00:00 SPY 478 @ 207.902791661487"
## [1] "2015-05-29 00:00:00 SPY -479 @ 209.014891988547"
## [1] "2015-06-05 00:00:00 SPY 1 @ 206.623386914182"
## [1] "2015-06-05 00:00:00 SPY 481 @ 206.623386914182"
## [1] "2015-06-17 00:00:00 SPY -482 @ 207.253245275178"
## [1] "2015-06-25 00:00:00 SPY 1 @ 208.765742549324"
## [1] "2015-06-25 00:00:00 SPY 477 @ 208.765742549324"
## [1] "2015-07-08 00:00:00 SPY -478 @ 204.137484295003"
## [1] "2015-07-10 00:00:00 SPY 1 @ 204.997859221705"
## [1] "2015-07-10 00:00:00 SPY 488 @ 204.997859221705"
## [1] "2015-07-14 00:00:00 SPY -489 @ 207.40099711892"
## [1] "2015-07-27 00:00:00 SPY 1 @ 204.651738288859"
## [1] "2015-07-27 00:00:00 SPY 480 @ 204.651738288859"
## [1] "2015-07-29 00:00:00 SPY -481 @ 207.163646002783"
## [1] "2015-08-06 00:00:00 SPY 1 @ 207.964686364514"
## [1] "2015-08-06 00:00:00 SPY 480 @ 207.964686364514"
## [1] "2015-08-11 00:00:00 SPY -481 @ 206.659290333217"
## [1] "2015-08-21 00:00:00 SPY 1 @ 199.499342550526"
## [1] "2015-08-21 00:00:00 SPY 489 @ 199.499342550526"
## [1] "2015-08-28 00:00:00 SPY -490 @ 196.305062615871"
## [1] "2015-09-02 00:00:00 SPY 1 @ 192.467961233126"
## [1] "2015-09-02 00:00:00 SPY 523 @ 192.467961233126"
## [1] "2015-09-04 00:00:00 SPY -524 @ 190.717544097235"
## [1] "2015-12-10 00:00:00 SPY 1 @ 204.204684925897"
## [1] "2015-12-10 00:00:00 SPY 487 @ 204.204684925897"
## [1] "2015-12-16 00:00:00 SPY -488 @ 205.149061519969"
## [1] "2015-12-21 00:00:00 SPY 1 @ 201.410004"
## [1] "2015-12-21 00:00:00 SPY 493 @ 201.410004"
## [1] "2015-12-23 00:00:00 SPY -494 @ 204.690002"
# Update your portfolio (portfolio.st)
updatePortf(portfolio.st)
## [1] "firststrat"
daterange <- time(getPortfolio(portfolio.st)$summary)[-1]

# Update your account (account.st)
updateAcct(account.st, daterange)
## [1] "firststrat"
updateEndEq(account.st)
## [1] "firststrat"

Profit factor

# Get the tradeStats for your portfolio
tstats <- tradeStats(Portfolios = portfolio.st)

# Print the profit factor
tstats$Profit.Factor
## [1] 1.641442

Percent positive

While profit factor is one important statistic, it may be heavily influenced by only a few good trades. The percent positive statistic lets you know how many of your trades were winners. A trading system based on oscillation trading (such as yours!) will likely have a high percentage of winners. This is certainly a statistic you should look for in your own trade statistics.

The trading statistics object you created in the last exercise (tstats) has been preloaded into your workspace. Examine it. What is the percent positive statistic?

  • 29.1
  • 67.3
  • [*] 70.9
  • 86.7

Visualizing your strategy

[Video]

Using chart.Posn()

# Use chart.Posn to view your system's performance on SPY
chart.Posn(Portfolio = portfolio.st, Symbol = "SPY")

Adding an indicator to a chart.Posn() chart

# Compute the SMA50
sma50 <- SMA(x = Cl(SPY), n = 50)

# Compute the SMA200
sma200 <- SMA(x = Cl(SPY), n = 200)

# Compute the DVO_2_126 with an navg of 2 and a percentlookback of 126
dvo <- DVO(HLC = HLC(SPY), navg = 2, percentlookback = 126)

# Recreate the chart.Posn of the strategy from the previous exercise
chart.Posn(Portfolio = portfolio.st, Symbol = "SPY")

# Overlay the SMA50 on your plot as a blue line
add_TA(sma50, on = 1, col = "blue")

# Overlay the SMA200 on your plot as a red line
add_TA(sma200, on = 1, col = "red")

# Add the DVO_2_126 to the plot in a new window
add_TA(dvo)

Additional analytics

[Video]

Cash Sharpe ratio

When working with cash profit and loss statistics, quantstrat offers a way to compute a Sharpe ratio not just from returns, but from the actual profit and loss statistics themselves. A Sharpe ratio is a metric that compares the average reward to the average risk taken. Generally, a Sharpe ratio above 1 is a marker of a strong strategy.

In this exercise, you will see that because of trading P&L (profit and loss), one can compute a Sharpe ratio based on these metrics. The code below can be used to compute the Sharpe ratio based off of P&L. Copy the code in the console. In what range is the Sharpe ratio you obtain?

portpl <- .blotter$portfolio.firststrat$summary$Net.Trading.PL SharpeRatio.annualized(portpl, geometric=FALSE)

  • .65 - .75
  • .55 - .65
  • [*] .45 - .55
  • .35 - .45

Returns Sharpe ratio in quantstrat

# Get instrument returns
instrets <- PortfReturns(portfolio.st)

# Compute Sharpe ratio from returns
SharpeRatio.annualized(instrets, geometric = FALSE)
##                                 SPY.DailyEqPL
## Annualized Sharpe Ratio (Rf=0%)     0.5166008

About Michael Mallari

Michael is a hybrid thinker and doer—a byproduct of being a CliftonStrengths “Learner” over time. With 20+ years of engineering, design, and product experience, he helps organizations identify market needs, mobilize internal and external resources, and deliver delightful digital customer experiences that align with business goals. He has been entrusted with problem-solving for brands—ranging from Fortune 500 companies to early-stage startups to not-for-profit organizations.

Michael earned his BS in Computer Science from New York Institute of Technology and his MBA from the University of Maryland, College Park. He is also a candidate to receive his MS in Applied Analytics from Columbia University.

LinkedIn | Twitter | www.michaelmallari.com/data | www.columbia.edu/~mm5470