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
#look at distance from the 3 month minimum | |
#to compare the magical US Russell 2000 | |
#to the world | |
require(quantmod) | |
tkrs <- c("^W2DOW","^RUT") | |
getSymbols(tkrs,from="1896-01-01",to=Sys.Date()) |
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
#use Ken French momentum style indexes for style analysis | |
#http://mba.tuck.dartmouth.edu/pages/faculty/ken.french/ftp/6_Portfolios_ME_Prior_12_2.zip | |
require(PerformanceAnalytics) | |
require(quantmod) | |
my.url="http://mba.tuck.dartmouth.edu/pages/faculty/ken.french/ftp/6_Portfolios_ME_Prior_12_2.zip" | |
my.tempfile<-paste(tempdir(),"\\frenchmomentum.zip",sep="") | |
my.usefile<-paste(tempdir(),"\\6_Portfolios_ME_Prior_12_2.txt",sep="") | |
download.file(my.url, my.tempfile, method="auto", |
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
# Function to implement a version of the improved moving average functionality | |
# introduced and tested in: | |
# | |
# Papailias, Fotis and Thomakos, Dimitrios D., | |
# "An Improved Moving Average Technical Trading Rule, | |
# (September 11, 2011). Available at SSRN: http://ssrn.com/abstract=1926376 | |
# | |
# Original code written by Kent Russell @ timelyportfolio.com | |
# | |
# Cross-checked by Dimitrios Thomakos on 11/29/2011, @ quantf.com |
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
#get MAImp code from GIST | |
#thanks to http://systematicinvestor.wordpress.com | |
#for showing me how to do this | |
con=url("https://raw.github.com/gist/1405187/92e7c24ff2459a0830c45b828f1dba41143e9436/MAImp.r") | |
source(con) | |
require(quantmod) | |
require(PerformanceAnalytics) | |
getSymbols("^GSPC",from = "1896-01-01", to = Sys.Date()) |
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
require(ttrTests) | |
require(quantmod) | |
require(PerformanceAnalytics) | |
#simple price crossover moving average system | |
#style slightly different to conform to ttrTests | |
oneSMA <- function(x,params=10,burn=0,short=FALSE) { | |
mac2<-runMean(x,params[1]) | |
sig<-ifelse(x>=mac2,1,0) | |
sig[is.na(sig)]<-0 |
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
#I very much appreciate Joshua Ulrich's (http://blog.fosstrading.com) forked version | |
#which offers a much nicer top section of the final graph | |
#forked version resides here https://gist.github.com/1443358 | |
require(quantmod) | |
#get index tickers without the ^ which we will add in the getSymbols | |
tckrs=c("GSPC","TNX","DJUBS","W3DOW","W5DOW") | |
#name the indexes | |
names(tckrs) <- c("S&P 500","US 10y Yld","DJ Commodity","Developed","Developing") |
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
require(quantmod) | |
require(PerformanceAnalytics) | |
require(PortfolioAnalytics) | |
require(fPortfolio) | |
require(ggplot2) | |
#read a csv file of returns | |
#unfortunately I cannot share | |
portfolio <- read.csv("iv stocks bonds international.csv",stringsAsFactors=FALSE) | |
portfolio <- portfolio[2:NROW(portfolio),2:NCOL(portfolio)] |
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
#use Ken French market cap series | |
#http://mba.tuck.dartmouth.edu/pages/faculty/ken.french/ftp/Portfolios_Formed_on_ME.zip | |
require(PerformanceAnalytics) | |
require(quantmod) | |
my.url="http://mba.tuck.dartmouth.edu/pages/faculty/ken.french/ftp/Portfolios_Formed_on_ME.zip" | |
my.tempfile<-paste(tempdir(),"\\frenchsize.zip",sep="") | |
my.usefile<-paste(tempdir(),"\\Portfolios_Formed_on_ME.txt",sep="") | |
download.file(my.url, my.tempfile, method="auto", |
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
#lattice exploration of Vanguard Bond Fund (vbmfx) | |
#returns since 1990 | |
require(quantmod) | |
require(lattice) | |
require(latticeExtra) | |
require(PerformanceAnalytics) | |
getSymbols("VBMFX",from="1896-01-01",to=Sys.Date(),adjust=TRUE) |
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
require(quantmod) | |
require(PerformanceAnalytics) | |
require(latticeExtra) | |
require(grid) | |
require(reshape) | |
tckr <- "VUSTX" | |
getSymbols(tckr, | |
from="1900-01-01", to=format(Sys.Date(),"%Y-%m-%d"), | |
adjust = TRUE) |
OlderNewer