Skip to content

Instantly share code, notes, and snippets.

View gwd999's full-sized avatar
🕶️

Walter D. gwd999

🕶️
View GitHub Profile
@gwd999
gwd999 / GoogleReader.R
Created January 13, 2012 19:50 — forked from jbryer/GoogleReader.R
Function to return an RSS feed using the (unofficial) Google Reader API
require(XML)
require(RCurl)
#' This function ruturns an XML tree of the RSS feed from the given URL.
#'
#' This function utilizes the (unofficial) Google Reader API to retrieve RSS
#' feeds. The advantage of access RSS feeds through the Google Reader API is that
#' you are not limited by the number of entries a website may included in their
#' feed. That is, Google maintains generally maintains a complete history of
#' entries from the RSS feed.
require(quantmod)
require(PerformanceAnalytics)
getSymbols("VFINX",from="1990-01-01",adjust=TRUE)
getSymbols("VBMFX",from="1990-01-01",adjust=TRUE)
perf <- na.omit(merge(monthlyReturn(VBMFX[,4]),monthlyReturn(VFINX[,4])))
colnames(perf) <- c("VBMFX","VFINX")
#get 8 month RSI; randomly picked 8; no optimization
rsi<- lag(merge(RSI(perf[,1],n=8),RSI(perf[,2],n=8)),k=1)
#allocate between vbmfx and vfinx based on highest RSI
Interactive charts and slides with R, googleVis and knitr
========================================
```{r results='asis', echo=FALSE, message=FALSE, tidy=FALSE}
library(googleVis)
G <- gvisGeoChart(Exports, "Country", "Profit",
options=list(width=250, height=120), chartid="c1")
T <- gvisBarChart(Exports[,1:2], yvar="Profit", xvar="Country",
options=list(width=250, height=260,
legend='none'), chartid="c2")
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]
@gwd999
gwd999 / spainallocation.r
Created July 24, 2012 21:16 — forked from timelyportfolio/spainallocation.r
spain stocks and bonds
#analyze asset allocation experience in Spain
require(lattice)
require(latticeExtra)
require(reshape2)
require(directlabels)
require(quantmod)
require(PerformanceAnalytics)
require(RQuantLib)
@gwd999
gwd999 / e1071.R
Created December 2, 2012 21:01 — forked from ivannp/e1071.R
Back-testing SVM with e1071
svmComputeOneForecast = function(
id,
data,
response,
startPoints,
endPoints,
len,
history=500,
trace=FALSE,
kernel="radial",
#################
# Use R to recreate part of QMV the relative non-proportional hazard estimation graph (fig 2) from Licht (2011)
# Updated to keep only the middle 95% of simulations
# Christopher Gandrud (http://christophergandrud.blogspot.com/)
# 30 December 2012
#################
#### Set Up ####
garchAutoTryFit = function(
ll,
data,
trace=FALSE,
forecast.length=1,
with.forecast=TRUE,
ic="AIC",
garch.model="garch" )
{
formula = as.formula( paste( sep="",
###############################################################################
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
## See http://gettinggeneticsdone.blogspot.com/2013/06/customize-rprofile.html
## Load packages
library(BiocInstaller)
## Don't show those silly significanct stars
options(show.signif.stars=FALSE)
## Do you want to automatically convert strings to factor variables in a data.frame?
## WARNING!!! This makes your code less portable/reproducible.