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
| \documentclass[nohyper,justified]{tufte-handout} | |
| %\documentclass{article} | |
| %great guides at epslatex.pdf | |
| %check miniplot for potential use | |
| %\usepackage{graphics} | |
| %\usepackage{caption} | |
| %\usepackage{sidecap} | |
| %\usepackage{textpos} | |
| %\usepackage[section]{placeins} |
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(fGarch) | |
| require(ttrTests) | |
| require(quantmod) | |
| require(PerformanceAnalytics) | |
| getSymbols("^GSPC",from="1900-01-01") | |
| #get monthly close prices from daily | |
| price.monthly<-to.monthly(GSPC)[,4] | |
| #get dates in yyyy-mm-01 format | |
| index(price.monthly) <- as.Date(index(price.monthly)) |
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
| #do a pretty correlation on heat map on all Pimco Funds (institutional share class) that have existed longer 5 years | |
| #symbol list obtained from | |
| #http://investments.pimco.com/Products/pages/PlOEF.aspx?Level1=ulProducts&Center=ulProducts&Level2=liulProductsMutualFunds | |
| #pasted into Excel and sorted by 5 yr return | |
| #then copied and pasted transpose | |
| #saved to csv | |
| #and pasted in this ticker list eliminating the money fund and adding Vanguard S&P 500 for reference | |
| tckrs <- c("PISIX","PSKIX","PSDIX","PSTKX","PCRIX","PFIIX","PHMIX","PFCIX","PCDIX","PTSHX","PFMIX","PLMIX","PSPTX","PCIMX","PSTIX","PNYIX","PLDTX","PLDIX","PTLDX","PAAIX","PXTIX","PHIYX","PSCSX","PAUIX","PTRIX","PGBIX","PFORX","PELBX","PDMIX","PMDRX","PEBIX","PDIIX","PRRSX","PMBIX","PTSAX","PTTRX","PIGLX","PRRIX","PFUIX","PIMIX","PIGIX","PRAIX","PLRIX","PGOVX","PEDIX","VFINX") | |
| for (i in 1:length(tckrs)) { |
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(lattice) | |
| require(latticeExtra) | |
| require(reshape2) | |
| require(quantmod) | |
| #set up horizon plots as a function | |
| horizonplot <- function(prices,horizon.type="offset",scale=0.05,title=NA,alpha=0.4){ | |
| #get change in prices since beginning or 1st row | |
| prices.change <- prices[,4]/as.numeric(prices[1,4])-1 | |
| #get as a data.frame so it will work well with melt and lattice |
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(lattice) | |
| require(latticeExtra) | |
| require(directlabels) | |
| require(reshape2) | |
| require(quantmod) | |
| require(PerformanceAnalytics) | |
| #I will use a csv file of weekly returns to get more history | |
| #but if you do not have access to that then use getSymbols for data to 1987 | |
| #getSymbols("^RUT",from="1900-01-01") |
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
| #do preliminary exploration of paper Why Trend is Not Your Friend | |
| #http://www.frankfurt-school.de/clicnetclm/fileDownload.do?goid=000000311260AB4 | |
| #by Peter Scholz and Ursula Walther | |
| #load table 2:Descriptive statistics of 35 leading equity indices | |
| table2 <- read.csv("https://raw.github.com/gist/2996948/31d22bf58aad9f8421f419d659da90c4b3e0bcf0/table2.csv") | |
| #load table 21: Average excess return from timing in the 35 selected leading equity indices | |
| table21 <- read.csv("https://raw.github.com/gist/2996948/8ee5c1d6680fc592c99a68027d2381701c66bb22/table21.csv") | |
| #I included the source at the end of attribution, so let's get rid of that | |
| table2 <- table2[1:(NROW(table2)-2),] |
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
| <?php | |
| /* | |
| * Converts CSV to JSON | |
| * Example uses Google Spreadsheet CSV feed | |
| * csvToArray function I think I found on php.net | |
| */ | |
| header('Content-type: application/json'); | |
| // Set your CSV feed |
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
| <!DOCTYPE html> | |
| <html> | |
| <head> | |
| <title>d3.js with Direct Yahoo Finance</title> | |
| <script type="text/javascript" src="http://mbostock.github.com/d3/d3.js?2.3.0"></script> | |
| <style type="text/css"> | |
| body { | |
| font: 10px sans-serif; |
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
| #should have known R already has horizon plot functionality | |
| #latticeExtra (already a favorite package of mine) has it sitting right there | |
| #http://rgm2.lab.nig.ac.jp/RGM2/func.php?rd_id=latticeExtra:horizonplot | |
| require(lattice) | |
| require(latticeExtra) | |
| require(reshape2) | |
| require(quantmod) |
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
| <!DOCTYPE html> | |
| <html> | |
| <head> | |
| <meta charset="utf-8" /> | |
| <title>d3.js Axys Chart</title> | |
| <!-- Always force latest IE rendering engine (even in intranet) & Chrome Frame | |
| Remove this if you use the .htaccess --> | |
| <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" /> | |
| <script src="http://d3js.org/d3.v2.min.js?2.9.1"></script> <style> |