This file contains hidden or 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
require(quantmod) | |
require(PerformanceAnalytics) | |
require(latticeExtra) | |
require(grid) | |
require(reshape) | |
require(RQuantLib) | |
getSymbols("AAA",src="FRED") # load Moody's AAA from Fed Fred | |
#Fed monthly series of yields is the monthly average of daily yields |
This file contains hidden or 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
require(quantmod) | |
require(PerformanceAnalytics) | |
require(lattice) | |
require(latticeExtra) | |
getSymbols("GS10",src="FRED") #load 10yTreasury | |
getSymbols("BAA",src="FRED") #load Corporate for credit | |
getSymbols("CPIAUCSL",src="FRED") #load CPI for inflation | |
bondReturnSources<-na.omit(merge(ROC(CPIAUCSL,12,type="discrete")*100, | |
BAA-GS10,GS10-ROC(CPIAUCSL,12,type="discrete")*100)) |
This file contains hidden or 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
require(quantmod) | |
require(PerformanceAnalytics) | |
require(RQuantLib) | |
require(lattice) | |
getSymbols("AAA",src="FRED") # load Moody's AAA from Fed Fred | |
#Fed monthly series of yields is the monthly average of daily yields | |
#set index to yyyy-mm-dd format rather than to.monthly mmm yyy for better merging later | |
index(AAA)<-as.Date(index(AAA)) |
This file contains hidden or 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
require(quantmod) | |
#get Japanese Yen daily from Fred http://research.stlouisfed.org/fred2 | |
getSymbols("DEXJPUS",src="FRED") | |
#get US 10y Yield from Fred | |
getSymbols("DGS10", src="FRED") | |
Yen10y <- na.omit(merge(DEXJPUS,DGS10)) | |
#define colors |
This file contains hidden or 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
require(quantmod) | |
require(colorRamps) | |
#get currency data from the FED FRED data series | |
getSymbols("DEXKOUS",src="FRED") #load Korea | |
getSymbols("DEXMAUS",src="FRED") #load Malaysia | |
getSymbols("DEXSIUS",src="FRED") #load Singapore | |
getSymbols("DEXTAUS",src="FRED") #load Taiwan | |
getSymbols("DEXCHUS",src="FRED") #load China | |
getSymbols("DEXJPUS",src="FRED") #load Japan |
This file contains hidden or 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
#r code to read survey responses | |
#from a google spreadsheet published to web as .csv | |
#please see http://lamages.blogspot.com/2012/01/feedback-from-vignette-survey.html | |
#and the github https://gist.github.com/1579665 | |
#for another method using google fusion tables | |
#require(vcd) #use vcd since I have never used it before | |
#ended up not using since I could not control size and location | |
#of the assoc plot |
This file contains hidden or 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
#trying to get a better growth of a $1 chart | |
#using lattice or PerformanceAnalytics | |
require(quantmod) | |
require(reshape) | |
require(lattice) | |
require(latticeExtra) | |
#get Vanguard US Total Bond Fund vbmfx | |
getSymbols("VBMFX",from="1990-01-01",to=Sys.Date(),adjust=TRUE) | |
#get Vanguard SP500 Fund vfinx |
This file contains hidden or 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
#highlight the very fine work of http://systematicinvestor.wordpress.com/ | |
#adapted some of his code to provide an addtional example for | |
#those that might be interested | |
############################################################################### | |
# Load Systematic Investor Toolbox (SIT) | |
# http://systematicinvestor.wordpress.com/systematic-investor-toolbox/ | |
############################################################################### | |
con = gzcon(url('http://www.systematicportfolio.com/sit.gz', 'rb')) | |
source(con) |
This file contains hidden or 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
require(quantmod) | |
#get data from Japan Ministry of Finance website in csv form | |
url = "http://www.customs.go.jp/toukei/suii/html/data/d41ma.csv" | |
japantrade <- read.csv(url,skip=2,stringsAsFactors=FALSE) | |
#start cleaning data and getting in xts form | |
japantrade.xts <- japantrade[2:NROW(japantrade),] | |
#remove trailing 0 for future data | |
japantrade.xts <- japantrade.xts[which(japantrade.xts[,2]!=0),] |
This file contains hidden or 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
#further explore Japanese trade data by region | |
#website is http://www.customs.go.jp/toukei/suii/html/time_e.htm | |
#format is http://www.customs.go.jp/toukei/suii/html/data/d42ma001.csv | |
#and the filename increments from 001 to 008 for the geographic areas | |
require(quantmod) | |
require(reshape) | |
require(lattice) | |
require(latticeExtra) |