quantmod

Can getSymbols still work with oanda?

半城伤御伤魂 提交于 2019-12-10 17:31:59
问题 I want to get the data of currencies and metals. As I tried some packages, many person suggest quantmod. So I used getSymbols as the following: getSymbols("USD/EUR",src="oanda") Error in download.file(paste(oanda.URL, from.date, to.date, "exch=", currency.pair[1], : cannot open URL 'http://www.oanda.com/convert/fxhistory?lang=en&date1=09%2F28%2F13&date=02%2F09%2F15&date_fmt=us&exch=USD&expr2=EUR&margin_fixed=0&SUBMIT=Get+Table&format=CSV&redirected=1' In addition: Warning message: In download

getSymbols (quantmod) giving wrong dates

孤街醉人 提交于 2019-12-10 16:17:30
问题 I'm using the quantmod package to fetch stock data. The code Data = getSymbols('LON:ADN',src="google",auto.assign=FALSE, from = '2011-08-10') Results in an xts as expected, however on closer examination it shows a volume of trades for 2012-10-21 (October 21st) which was a sunday, and is therefore clearly erroneous. Several other sundays are also included. Unfortunately the errors surrounding the weekends seem to have moved the rest of the data out of alignment. Has anyone experienced similar

R: Using quantmod's Delt in a data.table

微笑、不失礼 提交于 2019-12-10 12:16:51
问题 Following R data.table Return calculation and set() I would like to ask how I can use Delt() from library(quantmod) to find returns for a time-series in a data.table() . So far, thanks to Frank, I have: set.seed(42) DT <- data.table( ticker=rep(letters,each=5), priceA=runif(5*26^2), priceB=runif(5*26^2)) DT[,paste('returns',LETTERS[1:2],sep=''):={ lapply(.SD,function(x){ old <- head(x,-1) new <- tail(x,-1) c(NA,(new-old)/old) }) },by=ticker,.SDcols=grep('^price',names(DT))] The result (for

How can I eliminate quote marks around parameters in R function?

人盡茶涼 提交于 2019-12-09 13:32:57
问题 Here are the first few lines of an R function that works: teetor <- function(x,y) { require("quantmod") require("tseries") alpha <- getSymbols(x, auto.assign=FALSE) bravo <- getSymbols(y, auto.assign=FALSE) t <- as.data.frame(merge(alpha, bravo)) # ... <boring unit root econometric code> } When I pass two stock symbols as function parameters, I need to enclose them with quotes: teetor("GLD", "GDX") I want to be able to simply type: teetor(GLD, GDX) 回答1: There are several ways of doing this,

How to handle hyphens in yahoo finance tickers in Quantmod [duplicate]

前提是你 提交于 2019-12-08 19:35:57
问题 This question already has answers here : Access odd-named object returned by getSymbols (4 answers) Closed 4 years ago . When executing the following commands the hyphen in the ticker HM-B.ST is interpreted as a minus sign. I have tried to rename the xts object to something else but have not succeeded. Does anybody know a solution for this? >library(quantmod) >getSymbols("HM-B.ST") >chartSeries(HM-B.ST) Error in inherits(x, "xts") : object 'HM' not found 回答1: The cleanest way to deal with

Using rvest to scrape a website - Selecting html node?

与世无争的帅哥 提交于 2019-12-08 13:57:32
问题 I have a question about my latest r vest scrape. I want to scrape this page (and some other stocks as well): http://www.finviz.com/quote.ashx?t=AA&ty=c&p=d&b=1 I need a list of the Market Capital, which is the first box in the second line. This list should contain approx 50-100 stocks. I am using rvest for that. library(rvest) html = read_html("http://www.finviz.com/quote.ashx?t=A") cast = html_nodes(html, "table-dark-row") The problem is, I can not get around the html_nodes. Any idea about

Search-and-replace on a list of strings - gsub eapply?

前提是你 提交于 2019-12-08 12:25:19
问题 Here is a simplified excerpt of my code for reproduction purposes: library("quantmod") stockData <- new.env() stocksLst <- c("AAB.TO", "BBD-B.TO", "BB.TO", "ZZZ.TO") nrstocks = length(stocksLst) startDate = as.Date("2016-09-01") for (i in 1:nrstocks) { getSymbols(stocksLst[i], env = stockData, src = "yahoo", from = startDate) } My data is then stored in this environment stockData which I use to do some analysis. I'd like to clean up the names of the xts objects, which are currently: ls

Loading stock information of Japan using quantmod package in R [closed]

随声附和 提交于 2019-12-08 12:00:27
问题 This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, visit the help center. Closed 7 years ago . I encounter one problem of using R/quantmod package. I can get the stock information for Korea, but I failed in getting the information for Japan:

Log returns of multiple securities for multiple time period in R

北城余情 提交于 2019-12-08 11:12:26
问题 I have dataset containing daily closing prices of 5413 companies from 2000 to 2014. I want to calculate daily log returns for the stocks as according to dates as log(Price today/Price yesterday). I illustrate the dataset as follows: Date A G L ABA ABB ABBEY 2000-1-3 NA NA NA NA 2000-1-4 79.5 325 NA 961 2000-1-5 79.5 322.5 NA 945 2000-1-6 79.5 327.5 NA 952 2000-1-7 NA 327.5 NA 941 2000-1-10 79.5 327.5 NA 946 2000-1-11 79.5 327.5 NA 888 How could calculate the the daily log returns and

Get Annual Financial Data for a Stock for many years in R

我是研究僧i 提交于 2019-12-08 09:21:26
问题 Suppose I want to regress in R Gross Profit on Total Revenue. I need data for this, and the more, the better. There is a library on CRAN that I find very useful: quantmod , that does what I need. library(quantmod) getFinancials(Symbol="AMD", src="google") #to get the names of the matrix: rownames(AMD.f$IS$A) Total.Revenue<-AMD.f$IS$A["Revenue",] Gross.Profit<-AMD.f$IS$A["Gross Profit",] #finally: reg1<-lm(Gross.Profit~Total.Revenue) The biggest issue that I have is that this library gets me