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
FX.HistData <- function(pair = "EURUSD", period = "day") { | |
##### Arguments verification Valid pairs to download | |
pairs.valid <- c("AUDJPY", "AUDUSD", "CHFJPY", "EURCHF", "EURGBP", "EURJPY", "EURUSD", "GBPCHF", "GBPJPY", "GBPUSD", "NZDUSD", "USDCAD", "USDCHF", "USDJPY", "XAGUSD", "XAUUSD") | |
# Valid download periods | |
period.valid <- c("day", "hour") | |
# Create set of warnings | |
error.string <- c() | |
# Check if it is a valid pair, if not store a warning | |
if (pair %in% pairs.valid){valid.pair = TRUE} else { | |
valid.pair = FALSE |
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
# DEVTOOLS | |
library(devtools) | |
build_github_devtools() | |
install.packages("devtools.zip", repos = NULL) | |
unlink("devtools.zip") | |
# RMetrics | |
source('http://www.rmetrics.org/Rmetrics.R') | |
install.Rmetrics() | |
# Additional set of repositories | |
setRepositories(addURLs = c(CRANxtras = 'http://www.stats.ox.ac.uk/pub/RWin')) |
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
doInstall <- TRUE | |
toInstall <- c("zoo") | |
if(doInstall){install.packages(toInstall, repos = "http://cran.us.r-project.org")} | |
lapply(toInstall, library, character.only = TRUE) | |
ftseIndex <- EuStockMarkets[, 4] | |
plot(ftseIndex, col = "GRAY") | |
# Calculate 10-day rolling mean, quickly: | |
smoothIndex <- rollmean(x = ftseIndex, # original series |
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
doInstall <- TRUE | |
toInstall <- c("XML") | |
if(doInstall){install.packages(toInstall, repos = "http://cran.us.r-project.org")} | |
lapply(toInstall, library, character.only = TRUE) | |
myURL <- "http://en.wikipedia.org/wiki/United_States_presidential_election,_2012" | |
allTables <- readHTMLTable(myURL) | |
str(allTables) # Look at the allTables object to find the specific table we want | |
stateTable <- allTables[[14]] # We want the 14th table in the list (maybe 13th?) |
NewerOlder