Skip to content

Instantly share code, notes, and snippets.

timelyportfolio timelyportfolio

Block or report user

Report or block timelyportfolio

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View Magical RUT.r
#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())
View french risk return.r
#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",
@timelyportfolio
timelyportfolio / MAImp.r
Created Nov 29, 2011
Improved Moving Average R Function
View MAImp.r
# 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
View MAImp.test.r
#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())
View drawdown and system success.r
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
View world indexes since 2008-06.r
#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")
@timelyportfolio
timelyportfolio / taleoftwo.r
Created Dec 9, 2011
Tale of Two Frontiers
View taleoftwo.r
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)]
View size risk return.r
#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",
View lattice explore vbmfx.r
#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)
View vustx forward and back.r
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)
You can’t perform that action at this time.