Return: Calculate return of back-test

Description Usage Arguments Details Value Author(s) Examples

View source: R/PairTrading.R

Description

Calculate the performance of pair trading by specified trading signal and hedge ratio

Usage

1
Return(price.pair, signal.lagged, hedge.ratio.lagged)

Arguments

price.pair

pair stock price (xts object)

signal.lagged

lagged signal(see details)

hedge.ratio.lagged

hedge ratio created by EstimateParametersHistorically function(see details)

Details

You have to consider "lag" to signal, because you can not trade when you calculate your trade position at that time. hedge.ratio.lagged is too. We defined "return" as following that [Return of (Buy-Sell)portfolio = (Return of Price1) * (Investmentratio of Price1) + (Return of Price2) * (Investment ratio of Price2) In this equation, as you know, "Return" is calculated as "Change ratio of price between two period". We defined "Investment ratio" as following that. [(Investment ratio of Price1) = 1 / (1 + abs(hedge ratio))], [(Investment ratio of Price2) = hedge ratio / (1 + abs(hedge ratio))]

Value

performance data(not price but return) as xts object

Author(s)

Shinichi Takayanagi, Kohta Ishikawa

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
#load library
library(PairTrading)

#load sample stock price data
data(stock.price)

#select 2 stocks & estimate parameters
price.pair <- stock.price[,1:2]["2008-12-31::"]
params <- EstimateParametersHistorically(price.pair, period = 180)

#create trading signals
signal <- Simple(params$spread, 0.05)

#Performance of pair trading
return.pairtrading <- Return(price.pair, lag(signal), lag(params$hedge.ratio))
if(!all(is.na(return.pairtrading))){
  plot(100 * cumprod(1 + return.pairtrading))
}

PairTrading documentation built on May 2, 2019, 6:11 p.m.