Skip to content

Instantly share code, notes, and snippets.

View timelyportfolio's full-sized avatar

timelyportfolio timelyportfolio

View GitHub Profile
#get very helpful Ken French data
#for this project we will look at Global Factors
#http://mba.tuck.dartmouth.edu/pages/faculty/ken.french/ftp/Global_Factors.zip
require(PerformanceAnalytics)
require(quantmod)
require(RColorBrewer)
#my.url will be the location of the zip file with the data
require(quantmod)
require(PerformanceAnalytics)
#load my barclays agg file
#if you do not have access to Barclays Agg return then you can
#use VBMFX as a proxy
portfolio <- read.csv("C:\\Users\\Kent.TLEAVELL_NT\\Documents\\old\\R\\barclaysagg.csv",stringsAsFactors=FALSE)
portfolio <- portfolio[2:(NROW(portfolio)-1),2:NCOL(portfolio)]
portfolio <- portfolio[,c(1,4)]
#since export has duplicate colnames we need to remove the .1 added
require(twitteR)
require(ggplot2)
#get CFA12 tweets for exploration
#appears to limit n to 1500
cfatweets.1 <- searchTwitter("#cfa12", n=1500, since="2012-05-04",until="2012-05-07")
cfatweets.2 <- searchTwitter("#cfa12", n=1500, since="2012-05-07",until="2012-05-08")
cfatweets.3 <- searchTwitter("#cfa12", n=1500, since="2012-05-08",until="2012-05-15")
%great guides at epslatex.pdf
%check miniplot for potential use
%\documentclass[english,nohyper,noae]{tufte-handout}
\documentclass{article}
\usepackage{graphics}
\usepackage{caption}
\usepackage{sidecap}
\usepackage{textpos}
%\usepackage[section]{placeins}
\documentclass{article}
%great guides at epslatex.pdf
%check miniplot for potential use
\usepackage{graphics}
\usepackage{caption}
%\usepackage{sidecap}
%\usepackage{textpos}
\usepackage[section]{placeins}
require(reshape2)
require(dprint)
require(quantmod)
require(PerformanceAnalytics)
#get manager data set for some date to play with
data(managers)
#get xts in df form so that we can melt with the reshape package
#Hsieh, David A. and Fung, William,
#The Risk in Hedge Fund Strategies: Theory and Evidence from Trend Followers.
#The Review of Financial Studies, Vol. 14, No. 2, Summer 2001 .
#Available at SSRN: http://ssrn.com/abstract=250542
#http://faculty.fuqua.duke.edu/~dah7/DataLibrary/TF-Fac.xls
require(gdata)
require(quantmod)
require(PerformanceAnalytics)
@timelyportfolio
timelyportfolio / cdar and cvar allocation.r
Created May 31, 2012 16:08
cdar and cvar allocation
#NONE OF THIS IS INVESTMENT ADVICE
#attempt to fuse some cdar and es (cvar) research
#3 sources for most of the ideas incorporated
#http://systematicinvestor.wordpress.com/2011/11/01/minimizing-downside-risk/
#http://www.rinfinance.com/agenda/2010/Carl+Peterson+Boudt_Tutorial.pdf
#Strub, Issam S., Trade Sizing Techniques for Drawdown and Tail Risk Control (May 21, 2012).
# Available at SSRN: http://ssrn.com/abstract=2063848
# Load Systematic Investor Toolbox (SIT)
###########NOT INVESTMENT ADVICE######################
#extend the trend following factors into a system for trading S&P 500
#Hsieh, David A. and Fung, William,
#The Risk in Hedge Fund Strategies: Theory and Evidence from Trend Followers.
#The Review of Financial Studies, Vol. 14, No. 2, Summer 2001 .
#Available at SSRN: http://ssrn.com/abstract=250542
require(lattice)
require(latticeExtra)
require(reshape2)
require(directlabels)
require(quantmod)
require(PerformanceAnalytics)
getSymbols("^GSPC",from="1900-01-01")
GSPC.monthly <- GSPC[endpoints(GSPC,"months"),4]