Created
August 22, 2013 06:51
-
-
Save izamryan/6303988 to your computer and use it in GitHub Desktop.
Putting a benchmark of monthly continuously compounded returns into a Z ordered object
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
options(digits=4, width=70) | |
# load packages | |
library(PerformanceAnalytics) | |
library(zoo) | |
library(boot) | |
library(tseries) | |
VBLTX.prices = get.hist.quote(instrument="vbltx", start="1981-12-31", | |
end="2012-11-01", quote="AdjClose", | |
provider="yahoo", | |
compression="m", retclass="zoo") | |
index(VBLTX.prices) = as.yearmon(index(VBLTX.prices)) | |
FMAGX.prices = get.hist.quote(instrument="fmagx", start="1981-12-31", | |
end="2012-11-01", quote="AdjClose", | |
provider="yahoo", | |
compression="m", retclass="zoo") | |
index(FMAGX.prices) = as.yearmon(index(FMAGX.prices)) | |
SBUX.prices = get.hist.quote(instrument="sbux", start="1981-12-31", | |
end="2012-11-01", quote="AdjClose", | |
provider="yahoo", | |
compression="m", retclass="zoo") | |
index(SBUX.prices) = as.yearmon(index(SBUX.prices)) | |
GSPC.prices = get.hist.quote(instrument="^gspc", start="1981-12-31", | |
end="2012-11-01", quote="AdjClose", | |
provider="yahoo", | |
compression="m", retclass="zoo") | |
index(GSPC.prices) = as.yearmon(index(GSPC.prices)) | |
# create merged price data | |
Prices.z = merge(VBLTX.prices, FMAGX.prices, SBUX.prices, GSPC.prices) | |
# rename columns | |
colnames(Prices.z) = c("VBLTX", "FMAGX", "SBUX","S&P500") | |
# calculate cc returns as difference in log prices | |
Returns.z = diff(log(Prices.z)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment