Re: [R-SIG-Finance] Remove first two weeks of data in half hourly resolution
Brian's example is good if you want to remove the first 14 calendar days. If you want to remove the first 14 dates that appear in your data, it's even simpler #create sample data x <- .xts(1:1000, .POSIXct(1:1000*60*30)) # remove 1st 14 days by using a negative with first() first(x, "-14 days") Garrett On Thu, Mar 31, 2016 at 6:24 AM, Brian G. Peterson wrote: > Peter, > > You haven't published a reproducible example, and I'm not going to take > the time to write a complete example from scratch. > > We use xts subsetting for this type of thing, so I suggest using xts for > your time series (this is always good advice for time series in R). > > Here's a partial example to get you started. > > ### > > #load some data from the PerformanceAnalytics package > data(edhec) > > #check the range > range(index(edhec)) > > #add 14 days from the start > first(index(edhec))+14 > > #now assume that you have an object 'z' with intraday data > range(z) > > #check the range of Dates by forcing the index to Date type > range(as.Date(index(z))) > > #add 114 days, as before > first(as.Date(index(z)))+14 > > # now subset by cutting off the first 14 calendar days > # from the start of the series > zs <- z[paste0(first(as.Date(index(z)))+14,'/')] > > #check the range > range(as.Date(index(zs))) > > ## > > Regards, > > Brian > > -- > Brian G. Peterson > http://braverock.com/brian/ > Ph: 773-459-4973 > IM: bgpbraverock > > > On Thu, 2016-03-31 at 11:50 +0100, Peter Neumaier wrote: >> Hi all, >> >> I am doing some analysis on monthly futures contracts from 2011-2016. >> Each monthly contract goes for eight weeks, in half hourly resolution. >> >> I'd like to remove first two weeks of eight weeks history for each monthly >> contract. >> My approach was to work out the start and end date and cut the 1st two weeks >> data off, but problem is that the half hourly resolution is sometimes >> incomplete( >> i.e. a trading day goes from 7:00am - 4:00pm but sometimes starts at >> 7:30am). >> >> Any suggestion on how to resolve this? Below a sample trading day in half >> hourly: >> >> NGFH6.Open NGFH6.High NGFH6.Low NGFH6.Close >> NGFH6.Volume NGFH6.WAP NGFH6.hasGaps NGFH6.Count >> 2016-01-06 07:30:00 0.3395 0.33950.3375 0.3380 >> 45 0.33811 0 5 >> 2016-01-06 08:00:00 0.3400 0.34000.3387 0.3395 >> 140 0.33928 0 12 >> 2016-01-06 08:30:00 0.3395 0.33950.3379 0.3379 >> 70 0.33884 0 5 >> 2016-01-06 09:00:00 0.3379 0.33790.3379 0.3379 >> 0 0.33790 0 0 >> 2016-01-06 09:30:00 0.3379 0.33790.3379 0.3379 >> 0 0.33790 0 0 >> 2016-01-06 10:00:00 0.3375 0.33800.3373 0.3373 >> 230 0.33738 0 14 >> 2016-01-06 10:30:00 0.3376 0.33790.3376 0.3379 >> 20 0.33775 0 2 >> 2016-01-06 11:00:00 0.3370 0.33700.3370 0.3370 >> 105 0.33700 0 5 >> 2016-01-06 11:30:00 0.3366 0.33660.3365 0.3365 >> 65 0.33658 0 4 >> 2016-01-06 12:00:00 0.3370 0.33700.3370 0.3370 >> 10 0.33700 0 1 >> 2016-01-06 12:30:00 0.3372 0.33720.3361 0.3361 >> 125 0.33686 0 9 >> 2016-01-06 13:00:00 0.3360 0.33600.3357 0.3360 >> 225 0.33585 0 17 >> 2016-01-06 13:30:00 0.3357 0.33570.3355 0.3355 >> 50 0.33560 0 5 >> 2016-01-06 14:00:00 0.3350 0.33590.3350 0.3359 >> 25 0.33554 0 2 >> 2016-01-06 14:30:00 0.3359 0.33590.3359 0.3359 >> 0 0.33590 0 0 >> 2016-01-06 15:00:00 0.3352 0.33520.3348 0.3352 >> 150 0.33492 0 15 >> 2016-01-06 15:30:00 0.3352 0.33520.3334 0.3341 >> 280 0.33364 0 24 >> 2016-01-06 16:00:00 0.3341 0.33750.3341 0.3370 >> 145 0.33543 0 17 >> 2016-01-06 16:30:00 0.3380 0.33850.3380 0.3385 >> 25 0.33830 0 3 >> >> Many Thanks >> Peter >> >> [[alternative HTML version deleted]] >> >> ___ >> R-SIG-Finance@r-project.org mailing list >> https://stat.ethz.ch/mailman/listinfo/r-sig-finance >> -- Subscriber-posting only. If you want to post, subscribe first. >> -- Also note that this is not the r-help list where general R questions >> should go. > > ___ > R-SIG-Finance@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-sig-finance > -- Subscriber-posting only. If you want to post, subscribe first. > -- Also note that this is not the r-help list where gener
Re: [R-SIG-Finance] Reading the GSW spot rates from fed 2006 website
It might be easier to work with the .xls file that you can download from a link on this page: http://www.federalreserve.gov/pubs/feds/2006/200628/200628abs.html hope it helps, Garrett On Sun, Oct 11, 2015 at 5:02 PM, Mahmoud Shammaa wrote: > Hello, > Does anyone have any tips or suggestions regarding reading the rates that > Gurkaynak, Sack and Wright are updating on this website: > http://www.federalreserve.gov/econresdata/researchdata/feds200628_1.html > While I know how to scrape an html page the issue is that they have the > pages going from oldest to newest so It is not easily apparent where the > latest data is: > As of right now it is on page 29... > http://www.federalreserve.gov/econresdata/researchdata/feds200628_29.html > . > > the problem is that this will change > What is even more frustrating that if you go to > http://www.federalreserve.gov/econresdata/researchdata/feds200628_30.html > data exists but it is not clear in what sequence ... it seems to be draft > data.. > > So I am not sure if anyone on this list has recommendations regarding > unruly webpages .. > > Thanks, > Mido Shammaa > > [[alternative HTML version deleted]] > > ___ > R-SIG-Finance@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-sig-finance > -- Subscriber-posting only. If you want to post, subscribe first. > -- Also note that this is not the r-help list where general R questions > should go. ___ R-SIG-Finance@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-sig-finance -- Subscriber-posting only. If you want to post, subscribe first. -- Also note that this is not the r-help list where general R questions should go.
Re: [R-SIG-Finance] Constant maturity Futures
I don't really remember how it works, to be honest. :-P I wish I had time to look into it. 2015-08-19 is 20 days ago, so I guess the 20 day CMF needs 20 days of data as it's currently implemented? Sorry I can't be of more help. Garrett On Tue, Sep 8, 2015 at 9:30 AM, Ilya Kipnis wrote: > Hi Garrett, > > I just tested this code out and...it doesn't compute up to the most current > day. As of now, the term.structure function ends at 2015-08-19. AKA in the > last month. Is there a way to make it go up to the last day for which there > is data available? Thanks. > > -Ilya > > On Thu, Aug 13, 2015 at 5:56 PM, G See wrote: >> >> Hi Samuel, >> >> Here's some code (also attached) that creates constant maturity >> futures for VIX futures. I wrote this code 4 years ago. I'm not >> particularly proud of it. I don't know for sure that it works. It >> might not be elegant. etc. Take it for what it's worth. >> >> You should be able to source this code and get a time series plot of >> several different CMFs of varying maturities. You'll need my qmao >> package which you can install with >> devtools::install_github("gsee/qmao") >> >> >> #' @export >> #' @rdname primary2expiry >> suffix2expiry <- function(suffix, root='VX', ...) { >> if (exists(paste('suffix2expiry',root,sep="."))) { >> do.call(paste('suffix2expiry',root,sep='.'),list(suffix, ...)) >> } else { >> warning(paste(root, 'is not and available suffix2expiry >> method; using "VX" instead')) >> do.call('suffix2expiry.VX',list(suffix, ...)) >> } >> } >> >> #' Get the expiration date of an instrument given it's primary_id >> #' >> #' \code{primary2expiry} is basically a wrapper for >> \code{\link{suffix2expiry}}. It uses >> #' \code{\link[FinancialInstrument]{parse_id}} to split the >> \code{primary_id} into rood_id and suffix_id. >> #' then it calls the appropriate \code{\link{suffix2expiry}} method. >> #' >> #' \code{suffix2expiry} is a generic-like function. There should be a >> method defined >> #' the "root_id". Currently, written methods include "VX", "ES" (and >> aliases "YM", "NQ"). >> #' There are links to methods help pages in the seealso section. >> #' >> #' @param primary_id character string. Primary identifier of the >> instrument >> #' @param root character string. root symbol like "ES" or "VX" (NULL) >> #' @param silent silence warnings? (TRUE) >> #' @param suffix character string that indicates expiration month and >> year (and, for options, right and strike). >> #' See \code{\link[FinancialInstrument]{parse_suffix}} for examples of >> acceptable formats. >> #' @param ... any arguments to be passed to the \code{suffix2expiry} >> method >> #' @return expiration Date >> #' @seealso \code{\link{suffix2expiry.VX}}, \code{\link{suffix2expiry.ES}} >> #' @aliases primary2expiry, suffix2expiry >> #' @author gsee >> #' @examples >> #' primary2expiry("ESU1") >> #' suffix2expiry('V11', root='VX') >> #' @export >> #' @rdname primary2expiry >> primary2expiry <- function(primary_id, root=NULL, silent=TRUE) { >> idlist <- parse_id(primary_id, silent=silent) >> if (is.null(root)) root <- idlist$root >> do.call(paste("suffix2expiry",root,sep='.'), >> list(suffix=idlist$suffix, silent=silent)) >> } >> >> >> #' VIX future contract expiration date >> #' >> #' Calculate the expiration date of a VIX future contract given a >> suffix_id >> #' >> #' Per the contract specs, expiration will occur on \dQuote{the Wednesday >> that >> #' is thirty days prior to the third Friday of the calendar month >> #' immediately following the month in which the contract expires >> ("Final Settlement Date"). >> #' If the third Friday of the month subsequent to expiration of the >> applicable >> #' VIX futures contract is a CBOE holiday, the Final Settlement Date >> for the contract >> #' shall be thirty days prior to the CBOE business day immediately >> preceding that Friday.} >> #' @param suffix suffix_id that should be something like (\sQuote
Re: [R-SIG-Finance] Constant maturity Futures
Hi Samuel, Here's some code (also attached) that creates constant maturity futures for VIX futures. I wrote this code 4 years ago. I'm not particularly proud of it. I don't know for sure that it works. It might not be elegant. etc. Take it for what it's worth. You should be able to source this code and get a time series plot of several different CMFs of varying maturities. You'll need my qmao package which you can install with devtools::install_github("gsee/qmao") #' @export #' @rdname primary2expiry suffix2expiry <- function(suffix, root='VX', ...) { if (exists(paste('suffix2expiry',root,sep="."))) { do.call(paste('suffix2expiry',root,sep='.'),list(suffix, ...)) } else { warning(paste(root, 'is not and available suffix2expiry method; using "VX" instead')) do.call('suffix2expiry.VX',list(suffix, ...)) } } #' Get the expiration date of an instrument given it's primary_id #' #' \code{primary2expiry} is basically a wrapper for \code{\link{suffix2expiry}}. It uses #' \code{\link[FinancialInstrument]{parse_id}} to split the \code{primary_id} into rood_id and suffix_id. #' then it calls the appropriate \code{\link{suffix2expiry}} method. #' #' \code{suffix2expiry} is a generic-like function. There should be a method defined #' the "root_id". Currently, written methods include "VX", "ES" (and aliases "YM", "NQ"). #' There are links to methods help pages in the seealso section. #' #' @param primary_id character string. Primary identifier of the instrument #' @param root character string. root symbol like "ES" or "VX" (NULL) #' @param silent silence warnings? (TRUE) #' @param suffix character string that indicates expiration month and year (and, for options, right and strike). #' See \code{\link[FinancialInstrument]{parse_suffix}} for examples of acceptable formats. #' @param ... any arguments to be passed to the \code{suffix2expiry} method #' @return expiration Date #' @seealso \code{\link{suffix2expiry.VX}}, \code{\link{suffix2expiry.ES}} #' @aliases primary2expiry, suffix2expiry #' @author gsee #' @examples #' primary2expiry("ESU1") #' suffix2expiry('V11', root='VX') #' @export #' @rdname primary2expiry primary2expiry <- function(primary_id, root=NULL, silent=TRUE) { idlist <- parse_id(primary_id, silent=silent) if (is.null(root)) root <- idlist$root do.call(paste("suffix2expiry",root,sep='.'), list(suffix=idlist$suffix, silent=silent)) } #' VIX future contract expiration date #' #' Calculate the expiration date of a VIX future contract given a suffix_id #' #' Per the contract specs, expiration will occur on \dQuote{the Wednesday that #' is thirty days prior to the third Friday of the calendar month #' immediately following the month in which the contract expires ("Final Settlement Date"). #' If the third Friday of the month subsequent to expiration of the applicable #' VIX futures contract is a CBOE holiday, the Final Settlement Date for the contract #' shall be thirty days prior to the CBOE business day immediately preceding that Friday.} #' @param suffix suffix_id that should be something like (\sQuote{U1}, \sQuote{U11}, or \sQuote{SEP11}) #' @param silent silence warnings? (TRUE) #' @return an expiration Date #' @author gsee #' @references \url{http://cfe.cboe.com/products/spec_vix.aspx} #' @examples #' \dontrun{ #' suffix2expiry.VX('U11') #' suffix2expiry.VX("JUN09") #' } #' @export suffix2expiry.VX <- suffix2expiry.VIX <- function(suffix, silent=TRUE) { #require('timeDate') sl <- parse_suffix(suffix,silent=silent) DT <- as.Date(paste(15, sl$month, sl$year,sep='-'),format="%d-%b-%Y") Y <- format(DT,"%Y") M <- format((DT + 30),"%m") if (as.numeric(M) == 1) Y <- paste(as.numeric(Y) + 1) DS <- as.Date(paste(Y,M,01,sep='-'))+0:22 DS <- DS[months(DS, abbreviate=TRUE) == C2M()[as.numeric(M)]] ds <- which(weekdays(DS) == "Friday")[3] if (DS[ds] %in% as.Date(holidayNYSE(as.numeric(Y))@Data)) { while (DS[ds] %in% as.Date(holidayNYSE(as.numeric(Y))@Data) || any(c('Saturday', 'Sunday') == weekdays(DS[ds]))) ds <- ds-1 } #try(detach(package:timeDate), silent=TRUE); try(detach(package:timeSeries), silent=TRUE) DS[ds] - 30 } .interp.fut.VX <- function(x1, x2, n=36, prefer='Close') { xs <- c(x1,x2) # names of 2 instruments x1 <- get(x1,pos=.GlobalEnv) x2 <- get(x2,pos=.GlobalEnv) x1$DTE <- primary2expiry(xs[1])-index(x1)#, index(x1)) #dlf(x1) x2$DTE <- primary2expiry(xs[2])-index(x2)#, index(x2)) #dlf(x2) df <- merge(x1$DTE,x2$DTE,all=FALSE) df <- na.omit(df) if (length(df[,1]) && length(df[,2])) { Pcmf <- xts() if(all(df[,1] < df[,2])) { col1 <- 1 col2 <- 2 } else if (all(df[,2] < df[,1])) { col1 <- 2 col2 <- 1 } else stop(paste("ambiguous nearby contract",xs)) for (ns in n) { idx <- index(df[(df[,col1] <= ns) & (df[,col2] > ns)])
Re: [R-SIG-Finance] getquote function
Works for me, but it's not that unusual for different yahoo servers to give different answers (which you don't have much control over). getQuote("SPY", src="yahoo") # Trade Time Last Change % Change Open HighLow Volume #SPY 2015-07-27 12:10:00 206.93 -1.07 -0.51% 206.94 207.55 206.26 54683280 #devtools::install_github("gsee/qmao") suppressPackageStartupMessages(library(qmao)) getQuote("SPY", src="google") # TradeTime Last Change PctChg Exchange GoogleID #SPY 2015-07-27 12:27:00 207.01 -0.99 -0.48 NYSEARCA 700145 getQuote("SPY", src="bats", what="bbo") # TradeTime BidSize BidPrice AskPrice AskSizeLast LastSize row.names #1 12:27:011965 207 207.013135 207.005 18 SPY Garrett On Mon, Jul 27, 2015 at 11:23 AM, Samuel Wilson wrote: > Quick question, > > Anyone else having trouble with getQuote function this morning (quantmod > library)? > > Mine will not pull a current delayed quote, but is pulling last close. > Worked on Friday, but today not. Before I spend time troubling shooting, I > want to figure out if anyone else is having this problem. > > [[alternative HTML version deleted]] > > ___ > R-SIG-Finance@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-sig-finance > -- Subscriber-posting only. If you want to post, subscribe first. > -- Also note that this is not the r-help list where general R questions > should go. ___ R-SIG-Finance@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-sig-finance -- Subscriber-posting only. If you want to post, subscribe first. -- Also note that this is not the r-help list where general R questions should go.
Re: [R-SIG-Finance] Monthly Midpoint return
Try this data(sample_matrix) # load sample data first x <- as.xts(sample_matrix) do.call(rbind, lapply(split(x, "months"), function(xx) xx[ceiling(nrow(xx)/2)])) This code splits the object by months, then uses lapply() to loop over each month and apply a function which selects the row that is in the middle of the month. (you could replace ceiling() with floor() or round()). Once you have the subsetted data, you can calculate returns however you normally would (ROC(), Delt(), dailyReturn(), etc.) HTH, Garrett On Wed, Jun 17, 2015 at 9:30 AM, Mark Knecht wrote: > On Wed, Jun 17, 2015 at 7:23 AM, Phil Steel wrote: >> >> >> >> Hi Brian and everybody else, >> its downloaded stock prices I want to transform to middle of month stock >> price. >> endpoints give end of month doesn't it?if Im using endpoints I get a really >> strange result with a lot of NA:s My Data starts with the 15:th som my idea >> it transforming the data to.monthly somehow >> My function is ("provided" by Ulrich): >> monthly = function(x){ sym <- sub("\\..*$", "", names(x)[1]) >> Ad(to.monthly(x, indexAt = 'lastof', drop.time = TRUE, name = sym))} >> > > Possibly put the month in an array, determine the size of the array > and then take the price/returns at the midpoint of the array? That way > number of days in the month, holidays, etc. wouldn't matter much? > > - Mark > > ___ > R-SIG-Finance@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-sig-finance > -- Subscriber-posting only. If you want to post, subscribe first. > -- Also note that this is not the r-help list where general R questions > should go. ___ R-SIG-Finance@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-sig-finance -- Subscriber-posting only. If you want to post, subscribe first. -- Also note that this is not the r-help list where general R questions should go.
Re: [R-SIG-Finance] Weird behavior of getSymbols for symbol PLL and PL
Not reproducible for me. I've got an older version of R and a newer version of quantmod $ R --vanilla -q > suppressMessages(library(quantmod)) > options("getSymbols.warning4.0"=FALSE) > getSymbols(c("PLL", "PL")) [1] "PLL" "PL" > head(PLL) PLL.Open PLL.High PLL.Low PLL.Close PLL.Volume PLL.Adjusted 2007-01-0335.0835.19 34.53 34.89 66810030.77 2007-01-0434.6934.74 34.32 34.69 52150030.60 2007-01-0534.0034.25 33.61 33.75117160029.77 2007-01-0833.7233.74 33.23 33.71 65670029.73 2007-01-0933.9034.27 33.67 34.21 76500030.17 2007-01-1034.0034.15 33.77 34.07 70800030.05 > tail(PLL) PLL.Open PLL.High PLL.Low PLL.Close PLL.Volume PLL.Adjusted 2015-03-06 101.18 101.85 99.90100.17 510200 100.17 2015-03-09 100.10 100.42 100.00100.22 441700 100.22 2015-03-1098.7999.67 98.25 98.25 52960098.25 2015-03-1198.2598.37 97.54 97.91 44570097.91 2015-03-1298.5299.75 98.40 99.55 43860099.55 2015-03-1399.4599.79 98.54 99.61 43730099.61 > head(PL) PL.Open PL.High PL.Low PL.Close PL.Volume PL.Adjusted 2007-01-03 47.79 48.56 47.5047.95380100 39.01 2007-01-04 47.93 48.30 47.8248.00370300 39.05 2007-01-05 48.25 50.45 48.2550.35 1108300 40.96 2007-01-08 50.17 50.45 49.6249.76656300 40.48 2007-01-09 49.74 49.74 49.2349.61473200 40.36 2007-01-10 49.48 50.06 49.4349.67467100 40.41 > tail(PL) PL.Open PL.High PL.Low PL.Close PL.Volume PL.Adjusted 2015-01-23 69.94 69.96 69.9469.95 500 69.95 2015-01-26 69.95 69.95 69.9469.95630900 69.95 2015-01-27 69.95 69.98 69.9569.96643800 69.96 2015-01-28 69.98 69.98 69.9569.95975200 69.95 2015-01-29 69.98 69.98 69.9669.96915500 69.96 2015-01-30 69.99 70.01 69.9569.95 9516700 69.95 > sessionInfo() R version 3.1.2 (2014-10-31) Platform: x86_64-apple-darwin13.4.0 (64-bit) locale: [1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8 attached base packages: [1] stats graphics grDevices utils datasets methods base other attached packages: [1] quantmod_0.4-3 TTR_0.22-0 xts_0.9-7 zoo_1.7-11 loaded via a namespace (and not attached): [1] grid_3.1.2 lattice_0.20-29 Garrett ___ R-SIG-Finance@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-sig-finance -- Subscriber-posting only. If you want to post, subscribe first. -- Also note that this is not the r-help list where general R questions should go.
Re: [R-SIG-Finance] CUSIP Numbers
Since this is an R mailing list, I'll try to bring this thread back on topic. Unless you are willing to pay, the only free source that I am aware of to get CUSIPs via R is TradeKing. https://developers.tradeking.com/documentation/market-ext-quotes-get-post You must have an account, but you can create an account for free and you don't have to fund it in order to do this. library(ROAuth) #importFrom(ROAuth, OAuthFactory) library(RJSONIO) #importFrom(RJSONIO, fromJSON) #' ## This part could go in your .Rprofile #' # Set your application keys # https://developers.tradeking.com/applications #' cKey <- '' #' cSecret <- '#' #' oKey <- '' #' oSecret <- '' # Set the API endpoint tkURL <- "https://api.tradeking.com/v1/market/ext/quotes.json"; # Create the OAuth connection - this is straight from the ROAuth documentation on CRAN credentials <- OAuthFactory$new(consumerKey=cKey, consumerSecret=cSecret, oauthKey = oKey, oauthSecret = oSecret, needsVerifier=FALSE, signMethod='HMAC') # Update the connection so the handshake is TRUE credentials$handshakeComplete <- TRUE Symbols <- tolower(c("AAPL", "MSFT")) ## Whatever symbols you want symbols <- paste(Symbols, collapse=",") #what <- "datetime,bidsz,bid,ask,asksz,last,chg,pchg,opn,hi,lo,vl" what <- "cusip" what <- gsub(" ", "", tolower(paste(unlist(strsplit(what, ",")), collapse=","))) tkURL <- "https://api.tradeking.com/v1/market/ext/quotes.json"; query <- list(symbols=symbols, fids=what) response <- credentials$OAuthRequest(tkURL, query) res <- fromJSON(response) qt <- res$response$quotes$quote qt #[[1]] # cusip exch symbol #"59491810" "NASD" "MSFT" # #[[2]] # cusip exch symbol #"03783310" "NASD" "AAPL" HTH, Garrett ___ R-SIG-Finance@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-sig-finance -- Subscriber-posting only. If you want to post, subscribe first. -- Also note that this is not the r-help list where general R questions should go.
Re: [R-SIG-Finance] RFC: quantmod::getSymbols.MySQL
Hi Josh, As you probably noticed, I updated getSymbols.FI() to use options a couple weeks ago, but instead of using a single option that is a list, I made a separate option for each function argument. This allows two things: 1) you can have different default values set for the "from" argument (for example) of different getSymbols.*() methods. 2) It doesn't change the old defaults. i.e. getOption("someOption", "2014-01-01") will return the value of the option if it is set, or "2014-01-01" if not. With your list structure, the default value has to be determined inside the function, I suppose. Here's the formal argument list for getSymbols.FI > args(getSymbols.FI) function (Symbols, from = getOption("getSymbols.FI.from", "2010-01-01"), to = getOption("getSymbols.FI.to", Sys.Date()), ..., dir = getOption("getSymbols.FI.dir", ""), return.class = getOption("getSymbols.FI.return.class", "xts"), extension = getOption("getSymbols.FI.extension", "rda"), split_method = getOption("getSymbols.FI.split_method", c("days", "common")), use_identifier = getOption("getSymbols.FI.use_identifier", NA), date_format = getOption("getSymbols.FI.date_format"), verbose = getOption("getSymbols.FI.verbose", TRUE), days_to_omit = getOption("getSymbols.FI.days_to_omit", c("Saturday", "Sunday")), indexTZ = getOption("getSymbols.FI.indexTZ", NA)) Garrett On Wed, Oct 29, 2014 at 7:25 AM, Joshua Ulrich wrote: > As many of you know, the Defaults package was removed from CRAN on > 2014-10-03 at Jeff's request. This broke a fair bit of functionality > in quantmod, most of which I have addressed in recent commits on > R-Forge. > > One issue I have not resolved is how to adapt getSymbols.MySQL to the > new no-Defaults paradigm. I will be taking over as maintainer of > quantmod, so I am soliciting input from getSymbols.MySQL users. > > My proposed solution to getSymbols.MySQL is to look for specific > option()s if certain arguments are missing. I think this is the > cleanest and most obvious solution, but am open to alternatives. I > would use the option structure below, with only the three arguments > listed. > > options(quantmod.defaults = list( > getSymbols.MySQL = list( > user="josh", > password="secret", > dbname="stocks") > ) > ) > > Should I consider another option structure? Should additional > arguments be supported? Anything else I'm missing? > > Thanks, > -- > Joshua Ulrich | about.me/joshuaulrich > FOSS Trading | www.fosstrading.com > > ___ > R-SIG-Finance@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-sig-finance > -- Subscriber-posting only. If you want to post, subscribe first. > -- Also note that this is not the r-help list where general R questions > should go. ___ R-SIG-Finance@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-sig-finance -- Subscriber-posting only. If you want to post, subscribe first. -- Also note that this is not the r-help list where general R questions should go.
Re: [R-SIG-Finance] How can I get Japanese Stock Daily Data in R?
You can get intraday data for the past few days from here: http://k-db.com/stocks Sorry, I don't use R to download that, but it should be trivial. Hope this helps, Garrett On Fri, Oct 17, 2014 at 8:18 AM, Qi Li wrote: > Hi, > I am also very interested in this data. Please also let me know if you > have a solution. Thanks. > > Qi > > On Fri, Oct 17, 2014 at 8:52 AM, Eric (YEN-LIN) CHIU > wrote: > >> As I know, RFinanceYJ cannot work properly since the format of Yahoo in >> Japan change the format of data. >> >> Every time I try to fetch data, it shows >> "Error in order(financial.data$date) : argument 1 is not a vector" >> >> The current solution I found is in here: >> >> http://rstudio-pubs-static.s3.amazonaws.com/6475_3034596b267b4a7587cefd3b8ed4ba25.html >> >> But it is not convenient to choose date or change the data into xts object. >> I notice google finance has Japanese stock data, but getSymbols cannot >> access the data either. >> I tried "getSymbols("TYO:4689")", but it cannot open the URL. >> >> Could anyone please give me some advice for this? Thanks. >> >> Eric >> >> [[alternative HTML version deleted]] >> >> ___ >> R-SIG-Finance@r-project.org mailing list >> https://stat.ethz.ch/mailman/listinfo/r-sig-finance >> -- Subscriber-posting only. If you want to post, subscribe first. >> -- Also note that this is not the r-help list where general R questions >> should go. >> > > [[alternative HTML version deleted]] > > ___ > R-SIG-Finance@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-sig-finance > -- Subscriber-posting only. If you want to post, subscribe first. > -- Also note that this is not the r-help list where general R questions > should go. ___ R-SIG-Finance@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-sig-finance -- Subscriber-posting only. If you want to post, subscribe first. -- Also note that this is not the r-help list where general R questions should go.
Re: [R-SIG-Finance] 'Defaults' removed from CRAN? (2014-10-03)
Out of curiosity, did you try _not_ changing your current code, but instead adding library(Defaults) to the top of the script? It's not ideal, but Defaults _is_ still available (http://cran.r-project.org/src/contrib/Archive/Defaults/). That could buy you some time until you come up with something better. Just a (possibly bad) thought. Garrett On Wed, Oct 8, 2014 at 9:43 AM, Mark Knecht wrote: > On Tue, Oct 7, 2014 at 7:14 PM, Joshua Ulrich wrote: >> I just pushed an updated quantmod_0.4-2 to R-Forge. Most of the >> Defaults-related issues have been addressed, except for >> getSymbols.MySQL and setTA/unsetTA. Feedback would be much >> appreciated. >> -- >> Joshua Ulrich | about.me/joshuaulrich >> FOSS Trading | www.fosstrading.com >> >> >> On Tue, Oct 7, 2014 at 3:40 PM, Brian G. Peterson >> wrote: >>> On 10/07/2014 03:26 PM, Daniel Cegiełka wrote: http://cran.r-project.org/web/packages/Defaults/index.html That's a pretty important package that is required by quantmod. >>> >>> >>> Yes. >>> >>> Defaults makes use of unlockBindings to change loaded package namespaces. >>> That's no longer allowed by CRAN. >>> >>> So, we'll need to modify getSymbols to not require it. >>> >>> The old chartSeries uses it too, but we'll be replacing that soon, so I'm >>> not worried about that dependency. >>> >>> Regards, >>> >>> Brian >>> >>> >>> -- >>> Brian G. Peterson >>> http://braverock.com/brian/ >>> Ph: 773-459-4973 >>> IM: bgpbraverock >>> >>> >>> ___ >>> R-SIG-Finance@r-project.org mailing list >>> https://stat.ethz.ch/mailman/listinfo/r-sig-finance >>> -- Subscriber-posting only. If you want to post, subscribe first. >>> -- Also note that this is not the r-help list where general R questions >>> should go. >> >> ___ >> R-SIG-Finance@r-project.org mailing list >> https://stat.ethz.ch/mailman/listinfo/r-sig-finance >> -- Subscriber-posting only. If you want to post, subscribe first. >> -- Also note that this is not the r-help list where general R questions >> should go. > > > OK, it seems to work but requires me to modify long working code to remove > setDefaults and then put the database stuff in the actual call. Is > this the way this > is intended to work in the future and I should modify my files? > > I'm pretty sure the data is coming from MySQL as AAPL is not in the ETF > database and it fails if I add it to the symbol list: > >> source('~/.active-rstudio-document') > [1] "From MySQL -- SPY" > [1] "From MySQL -- IWM" > [1] "From MySQL -- QQQ" > [1] "From MySQL -- AAPL" > Error in Symbols[[i]] : subscript out of bounds > In addition: Warning message: > In getSymbols.MySQL(Symbols = "AAPL", env = , verbose = FALSE, : > could not load symbol(s): AAPL > >> > > The code I ran is at the bottom. > > Thanks, > Mark > > >> source('~/R/Test Cases/RMySQL-Test.R') > Loading required package: xts > Loading required package: zoo > > Attaching package: ‘zoo’ > > The following objects are masked from ‘package:base’: > > as.Date, as.Date.numeric > > Loading required package: TTR > Version 0.4-0 included new data defaults. See ?getSymbols. > Loading required package: DBI > [1] "From MySQL -- SPY" > As of 0.4-0, ‘getSymbols’ uses env=parent.frame() and > auto.assign=TRUE by default. > > This behavior will be phased out in 0.5-0 when the call will > default to use auto.assign=FALSE. getOption("getSymbols.env") and > getOptions("getSymbols.auto.assign") are now checked for alternate defaults > > This message is shown once per session and may be disabled by setting > options("getSymbols.warning4.0"=FALSE). See ?getSymbol for more details > [1] "From MySQL -- IWM" > [1] "From MySQL -- QQQ" > >> > > > llibrary(quantmod) > library(RMySQL) > > Sys.setenv(TZ = "UTC") > DataStart = "1990-01-01" > DataEnd = format(Sys.time(), "%Y-%m-%d") > SymbolSrc = "yahoo" > dbName = "R_ETF" > MyAdjust = TRUE > UseMySQL = TRUE > > SymbolList = c("SPY","IWM","QQQ") > > if (UseMySQL){ > if (MyAdjust) { dbName = paste0(dbName, "Adjust")} > dbc = dbConnect(MySQL(), dbname=dbName) > # setDefaults(getSymbols.MySQL, user="mark", > password="MyTempPassword", dbname=dbName) > } > > if (!UseMySQL){ > for (i in 1:length(SymbolList)){ > print(paste("From ",SymbolSrc," -- ",SymbolList[i])) > getSymbolsCont(SymbolList[i], from = DataStart, to = DataEnd, > adjust = MyAdjust, src=SymbolSrc) > } > } else { > for (i in 1:length(SymbolList)){ > print(paste("From MySQL -- ",SymbolList[i])) > # getSymbols(SymbolList[i], src="MySQL") > getSymbols(SymbolList[i], src="MySQL", user="mark", > password="MyTempPassword", dbname=dbName) > assign(SymbolList[i], get(SymbolList[i])[paste0(DataStart,"/",DataEnd)]) > } > dbDisconnect(dbc) > } > > ___ > R-SIG-Finance@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-sig-finance > -- Subscri
Re: [R-SIG-Finance] How to download options data in R from a csv list of underlying stock symbols?
That's not really an R question, but you could get historical options prices with the IBrokers package if you have an Interactive Brokers account, or with the Rbbg package if you have a Bloomberg. Garrett On Sun, Sep 28, 2014 at 9:35 PM, Liu wrote: > That's a pity. Do you know any alternative tools/methods to get the > historical data? > Thanks > > > On Sunday, September 28, 2014, G See wrote: >> >> getOptionChain() only provides the most recent quote, not historical >> time series data. That's why I didn't answer your question on SO. ;-) >> >> Sorry, >> Garrett >> >> On Sun, Sep 28, 2014 at 9:27 PM, Liu wrote: >> > Hello G See, >> > May I ask about the usage of getOptionChain? If I want to download a >> > whole >> > month options EOD data, what do I do? I tried: >> > AA<-getOptionChain(tick[1],from="2014-09-01",to="2014-09-28") >> > but it only returns 1 day option chain data, which is same as: >> > AA<-getOptionChain(tick[1]) >> > >> > Thank you >> > Carlos >> > >> > On Sun, Sep 28, 2014 at 10:05 PM, G See wrote: >> >> >> >> Please don't cross post: >> >> >> >> >> >> http://stackoverflow.com/questions/26091219/how-to-download-options-data-in-r-from-a-csv-list-of-underlying-stock-symbols >> >> >> >> On Sun, Sep 28, 2014 at 8:11 PM, Liu wrote: >> >> > Hello everyone, >> >> > >> >> > >> >> > I've recently joined this mailing list for quantstrat. I hope not to >> >> > ask >> >> > repetitive question but I haven't googled any effective solutions >> >> > yet. >> >> > >> >> > >> >> > I have a csv file containing 100 stock symbols. I want to download >> >> > the >> >> > option chains of each underlying including price, volume, IV, HV etc. >> >> > Hopefully with greeks too. EOD data from yahoo finance would be >> >> > adequate >> >> > for now. I’m using R 3.1.1 on Windows 8, 64 bit. >> >> > >> >> > >> >> > >> >> > At first, I tried “quantmod” using “getSymbols”, as a result I have >> >> > got >> >> > a >> >> > vector of stock symbols. >> >> > >> >> > >> >> > >> >> > ticker<-read.csv("C:/User/User/Documents/equity ticker.csv") >> >> > >> >> > getSymbols(ticker, from=”2014-09-01”, to=Sys.date()) >> >> > >> >> > >> >> > >> >> > But it is not numerical options data, but just character symbols. (I >> >> > might >> >> > understand it wrongly, please correct if I misuse "getSymbols" or >> >> > other >> >> > functions) >> >> > >> >> > >> >> > >> >> > Then I tried “yahoo_opt” < >> >> > http://page.math.tu-berlin.de/~mkeller/index.php?target=rcode>, but >> >> > this >> >> > script requires “fCalander” which is no longer available in CRAN. I >> >> > downloaded the achive from here < >> >> > http://cran.r-project.org/src/contrib/Archive/fCalendar/ > But I >> >> > couldn’t >> >> > install it. The last version of “fCalander” seemed to be compatible >> >> > with >> >> > R >> >> > 2.2, therefore I was unable to run the R file. >> >> > >> >> > >> >> > >> >> > Please help with using quantmod/quantstrat more effectively, or other >> >> > available methods to download those options data. By the way how can >> >> > I >> >> > search the old posts in this mailing list? Thank you. >> >> > >> >> > >> >> > Carlos >> >> > >> >> > [[alternative HTML version deleted]] >> >> > >> >> > ___ >> >> > R-SIG-Finance@r-project.org mailing list >> >> > https://stat.ethz.ch/mailman/listinfo/r-sig-finance >> >> > -- Subscriber-posting only. If you want to post, subscribe first. >> >> > -- Also note that this is not the r-help list where general R >> >> > questions >> >> > should go. >> > >> > ___ R-SIG-Finance@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-sig-finance -- Subscriber-posting only. If you want to post, subscribe first. -- Also note that this is not the r-help list where general R questions should go.
Re: [R-SIG-Finance] How to download options data in R from a csv list of underlying stock symbols?
getOptionChain() only provides the most recent quote, not historical time series data. That's why I didn't answer your question on SO. ;-) Sorry, Garrett On Sun, Sep 28, 2014 at 9:27 PM, Liu wrote: > Hello G See, > May I ask about the usage of getOptionChain? If I want to download a whole > month options EOD data, what do I do? I tried: > AA<-getOptionChain(tick[1],from="2014-09-01",to="2014-09-28") > but it only returns 1 day option chain data, which is same as: > AA<-getOptionChain(tick[1]) > > Thank you > Carlos > > On Sun, Sep 28, 2014 at 10:05 PM, G See wrote: >> >> Please don't cross post: >> >> http://stackoverflow.com/questions/26091219/how-to-download-options-data-in-r-from-a-csv-list-of-underlying-stock-symbols >> >> On Sun, Sep 28, 2014 at 8:11 PM, Liu wrote: >> > Hello everyone, >> > >> > >> > I've recently joined this mailing list for quantstrat. I hope not to ask >> > repetitive question but I haven't googled any effective solutions yet. >> > >> > >> > I have a csv file containing 100 stock symbols. I want to download the >> > option chains of each underlying including price, volume, IV, HV etc. >> > Hopefully with greeks too. EOD data from yahoo finance would be adequate >> > for now. I’m using R 3.1.1 on Windows 8, 64 bit. >> > >> > >> > >> > At first, I tried “quantmod” using “getSymbols”, as a result I have got >> > a >> > vector of stock symbols. >> > >> > >> > >> > ticker<-read.csv("C:/User/User/Documents/equity ticker.csv") >> > >> > getSymbols(ticker, from=”2014-09-01”, to=Sys.date()) >> > >> > >> > >> > But it is not numerical options data, but just character symbols. (I >> > might >> > understand it wrongly, please correct if I misuse "getSymbols" or other >> > functions) >> > >> > >> > >> > Then I tried “yahoo_opt” < >> > http://page.math.tu-berlin.de/~mkeller/index.php?target=rcode>, but this >> > script requires “fCalander” which is no longer available in CRAN. I >> > downloaded the achive from here < >> > http://cran.r-project.org/src/contrib/Archive/fCalendar/ > But I >> > couldn’t >> > install it. The last version of “fCalander” seemed to be compatible with >> > R >> > 2.2, therefore I was unable to run the R file. >> > >> > >> > >> > Please help with using quantmod/quantstrat more effectively, or other >> > available methods to download those options data. By the way how can I >> > search the old posts in this mailing list? Thank you. >> > >> > >> > Carlos >> > >> > [[alternative HTML version deleted]] >> > >> > ___ >> > R-SIG-Finance@r-project.org mailing list >> > https://stat.ethz.ch/mailman/listinfo/r-sig-finance >> > -- Subscriber-posting only. If you want to post, subscribe first. >> > -- Also note that this is not the r-help list where general R questions >> > should go. > > ___ R-SIG-Finance@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-sig-finance -- Subscriber-posting only. If you want to post, subscribe first. -- Also note that this is not the r-help list where general R questions should go.
Re: [R-SIG-Finance] How to download options data in R from a csv list of underlying stock symbols?
Please don't cross post: http://stackoverflow.com/questions/26091219/how-to-download-options-data-in-r-from-a-csv-list-of-underlying-stock-symbols On Sun, Sep 28, 2014 at 8:11 PM, Liu wrote: > Hello everyone, > > > I've recently joined this mailing list for quantstrat. I hope not to ask > repetitive question but I haven't googled any effective solutions yet. > > > I have a csv file containing 100 stock symbols. I want to download the > option chains of each underlying including price, volume, IV, HV etc. > Hopefully with greeks too. EOD data from yahoo finance would be adequate > for now. I’m using R 3.1.1 on Windows 8, 64 bit. > > > > At first, I tried “quantmod” using “getSymbols”, as a result I have got a > vector of stock symbols. > > > > ticker<-read.csv("C:/User/User/Documents/equity ticker.csv") > > getSymbols(ticker, from=”2014-09-01”, to=Sys.date()) > > > > But it is not numerical options data, but just character symbols. (I might > understand it wrongly, please correct if I misuse "getSymbols" or other > functions) > > > > Then I tried “yahoo_opt” < > http://page.math.tu-berlin.de/~mkeller/index.php?target=rcode>, but this > script requires “fCalander” which is no longer available in CRAN. I > downloaded the achive from here < > http://cran.r-project.org/src/contrib/Archive/fCalendar/ > But I couldn’t > install it. The last version of “fCalander” seemed to be compatible with R > 2.2, therefore I was unable to run the R file. > > > > Please help with using quantmod/quantstrat more effectively, or other > available methods to download those options data. By the way how can I > search the old posts in this mailing list? Thank you. > > > Carlos > > [[alternative HTML version deleted]] > > ___ > R-SIG-Finance@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-sig-finance > -- Subscriber-posting only. If you want to post, subscribe first. > -- Also note that this is not the r-help list where general R questions > should go. ___ R-SIG-Finance@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-sig-finance -- Subscriber-posting only. If you want to post, subscribe first. -- Also note that this is not the r-help list where general R questions should go.
Re: [R-SIG-Finance] IBrokers Problem
Yup. Works fine for me with the demo account on Ubuntu. Have you tried restarting the TWS? (while you're at it, you might consider using IB Gateway instead since it doesn't log you out every day) > sessionInfo() R version 3.0.2 (2013-09-25) Platform: x86_64-pc-linux-gnu (64-bit) locale: [1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C [3] LC_TIME=en_US.UTF-8LC_COLLATE=en_US.UTF-8 [5] LC_MONETARY=en_US.UTF-8LC_MESSAGES=en_US.UTF-8 [7] LC_PAPER=en_US.UTF-8 LC_NAME=C [9] LC_ADDRESS=C LC_TELEPHONE=C [11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C attached base packages: [1] stats graphics grDevices utils datasets methods base other attached packages: [1] IBrokers_0.9-11 xts_0.9-7 zoo_1.7-11 loaded via a namespace (and not attached): [1] grid_3.0.2 lattice_0.20-18 Sorry I can't be of more assistance, Garrett On Mon, Dec 9, 2013 at 5:25 PM, Michael Smith wrote: > Does it work for you in the demo TWS version as well? > > For me, `reqCurrentTime` works fine in the demo TWS version, like all > the other examples in the vignette, except for `twsFuture`. > >> reqCurrentTime(tws) > TWS Message: 2 -1 2104 Market data farm connection is OK:ibdemo > TWS Message: 2 -1 2106 HMDS data farm connection is OK:demohmds > [1] "2013-12-10 07:14:29 HKT" > > Interestingly, when I run the following code, I get some feedback from > the Unix shell that runs TWS. > >> tws <- twsConnect() >> reqContractDetails(tws, twsEquity("QQQ")) # R hangs here. > ^C >> twsDisconnect(tws) > > So when I run `twsDisconnect` (only after running `reqContractDetails`) > in the example above, I get the following output in the Unix shell from > Java: > > 07:23:13:870 JTS-EServerSocket-157: [1:47:67:1:0:0:0:ERR] Message type > 1. Attempted read beyond end of socket stream - > 07:23:13:870 JTS-EServerSocket-157: Anticipated error > jextend.c: Attempted read beyond end of socket stream - > at jextend.tb.b(tb.java:307) > at jextend.hf.eb(hf.java:1316) > at jextend.hf.run(hf.java:1251) > at java.lang.Thread.run(Thread.java:744) > Caused by: java.io.EOFException > at jextend.tb.c(tb.java:541) > at jextend.tb.r(tb.java:183) > at jextend.wd.a(wd.java:188) > at jextend.tb.d(tb.java:613) > at jextend.uc.a(uc.java:177) > at jextend.tb.b(tb.java:304) > ... 3 more > 07:23:13:871 JTS-EServerSocket-157: [1:47:67:1:0:0:0:SYS] Client{1} > terminated conversation. > 07:23:13:871 JTS-EServerSocketNotifier-156: Terminating > > > Thanks, > Michael > > > > On 12/09/2013 11:06 PM, G See wrote: >> I don't know; it works for me. Does reqCurrentTime(tws) return the >> current time? >> >> Garrett >> >>> tws <- ibgConnect() >>> reqCurrentTime(tws) >> [1] "2013-12-09 09:04:37 CST" >>> reqContractDetails(tws, twsEquity("QQQ")) >> [[1]] >> List of 18 >> $ version : chr "6" >> $ contract :List of 16 >> ..$ conId : chr "43661924" >> ..$ symbol : chr "QQQ" >> ..$ sectype: chr "STK" >> ..$ exch : chr "SMART" >> ..$ primary: chr "NASDAQ" >> ..$ expiry : chr "" >> ..$ strike : chr "0" >> ..$ currency : chr "USD" >> ..$ right : chr "" >> ..$ local : chr "QQQ" >> ..$ multiplier : chr "" >> ..$ combo_legs_desc: chr "" >> ..$ comboleg : chr "" >> ..$ include_expired: chr "0" >> ..$ secIdType : chr "" >> ..$ secId : chr "" >> ..- attr(*, "class")= chr "twsContract" >> $ marketName: chr "NMS" >> $ tradingClass : chr "NMS" >> $ conId : chr "43661924" >> $ minTick : chr "0.01" >> $ orderTypes: chr [1:49] "ACTIVETIM" "ADJUST" "ALERT" "ALGO" ... >> $ validExchanges: chr [1:17] "SMART" "ISE" "CHX" "ARCA" ... >> $ priceMagnifier: chr "1" >> $ underConId: chr "0" >> $ longName : chr "POWERSHARES QQQ NASDAQ 100" >> $ contractMonth : chr "" >> $ industry : chr "Funds" >> $ category : chr "Equity Fund" >> $ subcategory : chr "Sector Fund-Technology" >> $ timeZoneId: chr
Re: [R-SIG-Finance] IBrokers Problem
I don't know; it works for me. Does reqCurrentTime(tws) return the current time? Garrett > tws <- ibgConnect() > reqCurrentTime(tws) [1] "2013-12-09 09:04:37 CST" > reqContractDetails(tws, twsEquity("QQQ")) [[1]] List of 18 $ version : chr "6" $ contract :List of 16 ..$ conId : chr "43661924" ..$ symbol : chr "QQQ" ..$ sectype: chr "STK" ..$ exch : chr "SMART" ..$ primary: chr "NASDAQ" ..$ expiry : chr "" ..$ strike : chr "0" ..$ currency : chr "USD" ..$ right : chr "" ..$ local : chr "QQQ" ..$ multiplier : chr "" ..$ combo_legs_desc: chr "" ..$ comboleg : chr "" ..$ include_expired: chr "0" ..$ secIdType : chr "" ..$ secId : chr "" ..- attr(*, "class")= chr "twsContract" $ marketName: chr "NMS" $ tradingClass : chr "NMS" $ conId : chr "43661924" $ minTick : chr "0.01" $ orderTypes: chr [1:49] "ACTIVETIM" "ADJUST" "ALERT" "ALGO" ... $ validExchanges: chr [1:17] "SMART" "ISE" "CHX" "ARCA" ... $ priceMagnifier: chr "1" $ underConId: chr "0" $ longName : chr "POWERSHARES QQQ NASDAQ 100" $ contractMonth : chr "" $ industry : chr "Funds" $ category : chr "Equity Fund" $ subcategory : chr "Sector Fund-Technology" $ timeZoneId: chr "EST" $ tradingHours : chr "20131209:0400-2000;20131210:0400-2000" $ liquidHours : chr "20131209:0930-1600;20131210:0930-1600" On Mon, Dec 9, 2013 at 7:47 AM, Michael Smith wrote: > Thanks for the quick reply, but R still hangs after running this command > with the new ticker. > > Best, > Michael > > > On 12/09/2013 09:29 PM, G See wrote: >> The ticker for that ETF changed to QQQ on March 23, 2011 >> >> Try reqContractDetails(tws, twsEquity("QQQ")) >> >> Best, >> Garrett >> >> On Mon, Dec 9, 2013 at 7:27 AM, Michael Smith wrote: >>> All, >>> >>> I'm trying to better understand how to use the IBrokers package by going >>> through the `IBrokers.pdf` vignette. I'm using the demo version of TWS >>> (login `edemo`). TWS seems to be running fine. However, I get stuck at >>> the following command from the vignette: >>> >>> reqContractDetails(tws, twsEquity("")) >>> >>> R just seems to hang and I don't get any further response. My >>> sessionInfo is below. I'm using the most current IBrokers from Google Code. >>> >>> Am I doing something wrong, or is this not supposed to work with the TWS >>> demo version? >>> >>> Thanks, >>> Michael >>> >>> >>>> sessionInfo() >>> R version 3.0.2 (2013-09-25) >>> Platform: x86_64-redhat-linux-gnu (64-bit) >>> >>> locale: >>> [1] LC_CTYPE=en_US.utf8 LC_NUMERIC=C >>> LC_TIME=en_US.utf8 >>> [4] LC_COLLATE=en_US.utf8 LC_MONETARY=en_US.utf8 >>> LC_MESSAGES=en_US.utf8 >>> [7] LC_PAPER=en_US.utf8 LC_NAME=C LC_ADDRESS=C >>> >>> [10] LC_TELEPHONE=CLC_MEASUREMENT=en_US.utf8 >>> LC_IDENTIFICATION=C >>> >>> attached base packages: >>> [1] stats graphics grDevices utils datasets methods base >>> >>> other attached packages: >>> [1] IBrokers_0.9-11 xts_0.9-7 zoo_1.7-10 colorout_1.0-1 >>> >>> loaded via a namespace (and not attached): >>> [1] grid_3.0.2 lattice_0.20-24 tools_3.0.2 >>> >>> ___ >>> R-SIG-Finance@r-project.org mailing list >>> https://stat.ethz.ch/mailman/listinfo/r-sig-finance >>> -- Subscriber-posting only. If you want to post, subscribe first. >>> -- Also note that this is not the r-help list where general R questions >>> should go. ___ R-SIG-Finance@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-sig-finance -- Subscriber-posting only. If you want to post, subscribe first. -- Also note that this is not the r-help list where general R questions should go.
Re: [R-SIG-Finance] IBrokers Problem
The ticker for that ETF changed to QQQ on March 23, 2011 Try reqContractDetails(tws, twsEquity("QQQ")) Best, Garrett On Mon, Dec 9, 2013 at 7:27 AM, Michael Smith wrote: > All, > > I'm trying to better understand how to use the IBrokers package by going > through the `IBrokers.pdf` vignette. I'm using the demo version of TWS > (login `edemo`). TWS seems to be running fine. However, I get stuck at > the following command from the vignette: > > reqContractDetails(tws, twsEquity("")) > > R just seems to hang and I don't get any further response. My > sessionInfo is below. I'm using the most current IBrokers from Google Code. > > Am I doing something wrong, or is this not supposed to work with the TWS > demo version? > > Thanks, > Michael > > >> sessionInfo() > R version 3.0.2 (2013-09-25) > Platform: x86_64-redhat-linux-gnu (64-bit) > > locale: > [1] LC_CTYPE=en_US.utf8 LC_NUMERIC=C > LC_TIME=en_US.utf8 > [4] LC_COLLATE=en_US.utf8 LC_MONETARY=en_US.utf8 > LC_MESSAGES=en_US.utf8 > [7] LC_PAPER=en_US.utf8 LC_NAME=C LC_ADDRESS=C > > [10] LC_TELEPHONE=CLC_MEASUREMENT=en_US.utf8 > LC_IDENTIFICATION=C > > attached base packages: > [1] stats graphics grDevices utils datasets methods base > > other attached packages: > [1] IBrokers_0.9-11 xts_0.9-7 zoo_1.7-10 colorout_1.0-1 > > loaded via a namespace (and not attached): > [1] grid_3.0.2 lattice_0.20-24 tools_3.0.2 > > ___ > R-SIG-Finance@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-sig-finance > -- Subscriber-posting only. If you want to post, subscribe first. > -- Also note that this is not the r-help list where general R questions > should go. ___ R-SIG-Finance@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-sig-finance -- Subscriber-posting only. If you want to post, subscribe first. -- Also note that this is not the r-help list where general R questions should go.
Re: [R-SIG-Finance] Introducing TFX: An R Interface to the TrueFX Web API
you entered a less than sign instead of an assignment operator. instead of id < ConnectTrueFX(... it should be id <- ConnectTrueFX(... On Wed, Nov 27, 2013 at 11:10 PM, veepsirtt wrote: >> id < ConnectTrueFX("EUR/USD",username="veepsirtt",password="veeps203") > Error in id < ConnectTrueFX("EUR/USD", username = "veepsirtt", password = > "veeps203") : > comparison (3) is possible only for atomic and list types > > > > > -- > View this message in context: > http://r.789695.n4.nabble.com/Introducing-TFX-An-R-Interface-to-the-TrueFX-Web-API-tp4651827p4681302.html > Sent from the Rmetrics mailing list archive at Nabble.com. > > ___ > R-SIG-Finance@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-sig-finance > -- Subscriber-posting only. If you want to post, subscribe first. > -- Also note that this is not the r-help list where general R questions > should go. ___ R-SIG-Finance@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-sig-finance -- Subscriber-posting only. If you want to post, subscribe first. -- Also note that this is not the r-help list where general R questions should go.
Re: [R-SIG-Finance] Introducing TFX: An R Interface to the TrueFX Web API
Because you've pasted a right single quote unicode symbol instead of typing an apostrophe. When I copy/paste from the command you entered, I get R> charToRaw("’") [1] e2 80 99 When I type an apostrophe using the keyboard, I get R> charToRaw("'") [1] 27 Try typing your command instead of copy/pasting it. Hope this helps, Garrett On Wed, Nov 27, 2013 at 10:37 PM, veepsirtt wrote: > Hello Gsee, > Why I am getting this error?. > unexpected input in "QueryTrueFX(ConnectTrueFX(username=’" > --- > >> ## Cannot run these because there may not be an internet connection >> ## Not run: >> library(TFX) >> QueryTrueFX() #unauthenticated > Symbol Bid.Price Ask.Price High Low TimeStamp > 1 EUR/USD 1.35773 1.35781 1.35804 1.35634 2013-11-28 04:29:35 > 2 USD/JPY 102.05800 102.06400 102.29100 101.93300 2013-11-28 04:29:38 > 3 GBP/USD 1.63036 1.63055 1.63074 1.62763 2013-11-28 04:29:35 > 4 EUR/GBP 0.83265 0.83282 0.83436 0.83235 2013-11-28 04:29:35 > 5 USD/CHF 0.90768 0.90784 0.90874 0.90725 2013-11-28 04:29:40 > 6 EUR/JPY 138.56800 138.58300 138.84900 138.29900 2013-11-28 04:29:35 > 7 EUR/CHF 1.23241 1.23266 1.23308 1.23195 2013-11-28 04:29:35 > 8 USD/CAD 1.05844 1.05867 1.05987 1.05746 2013-11-28 04:29:34 > 9 AUD/USD 0.91259 0.91270 0.91411 0.90742 2013-11-28 04:29:34 > 10 GBP/JPY 166.38900 166.42000 166.61000 165.95600 2013-11-28 04:29:35 >> QueryTrueFX(pretty=FALSE) > $Symbol > [1] "EUR/USD" "USD/JPY" "GBP/USD" "EUR/GBP" "USD/CHF" "EUR/JPY" "EUR/CHF" > "USD/CAD" "AUD/USD" "GBP/JPY" > > $BidBigNumber > [1] "1.35" "102." "1.63" "0.83" "0.90" "138." "1.23" "1.05" "0.91" "166." > > $BidPip > [1] "773" "058" "036" "265" "768" "568" "241" "844" "259" "389" > > $OfferBigNumber > [1] "1.35" "102." "1.63" "0.83" "0.90" "138." "1.23" "1.05" "0.91" "166." > > $OfferPip > [1] "781" "064" "055" "282" "784" "583" "266" "867" "270" "420" > > $High > [1] "1.35804" "102.291" "1.63074" "0.83436" "0.90874" "138.849" "1.23308" > "1.05987" "0.91411" "166.610" > > $Low > [1] "1.35634" "101.933" "1.62763" "0.83235" "0.90725" "138.299" "1.23195" > "1.05746" "0.90742" "165.956" > > $TimeStamp > [1] "1385612975232" "1385612978277" "1385612975780" "1385612975128" > "1385612980409" "1385612975181" > [7] "1385612975905" "1385612974630" "1385612974758" "1385612975675" > >> QueryTrueFX(parse=FALSE) > [1] > "EUR/USDUSD/JPYGBP/USDEUR/GBPUSD/CHFEUR/JPYEUR/CHFUSD/CADAUD/USDGBP/JPY1.35102.1.630.830.90138.1.231.050.91166.7690580362627735672398442593891.35102.1.630.830.90138.1.231.050.91166.7770640552787875812638672704201.35804102.2911.630740.834360.90874138.8491.233081.059870.91411166.6101.35634101.9331.627630.832350.90725138.2991.231951.057460.90742165.9561385612981970138561297827713856129820241385612981995138561298220413856129818141385612981814138561297463013856129747581385612975675" >> >> ## For authenticated session, you must have a username and password >> (it’s> free). >> ## Use your username and passward instead of JSTrader and Ou812 >> >> id <- ConnectTrueFX(’EUR/USD,GBP/USD’, >> username=’veepsirtt’,password=’veeps203’) > Error: unexpected input in "id <- ConnectTrueFX(’" >> QueryTrueFX(id) >Symbol Bid.Price Ask.PriceHigh Low TimeStamp > 1 EUR/USD 1.35769 1.35777 1.35804 1.35634 2013-11-28 04:29:52 > 2 GBP/USD 1.63031 1.63048 1.63074 1.62763 2013-11-28 04:29:52 >> id > > attr(,"class") > [1] "TFXsession" "environment" >> QueryTrueFX(ConnectTrueFX(username=’veepsirtt’, >> password=’veeps203’,format=’csv’), arse=FALSE) > Error: unexpected input in "QueryTrueFX(ConnectTrueFX(username=’" >> QueryTrueFX(ConnectTrueFX(username=’veepsirtt’, >> password=’veeps203’,format=’html’), arse=FALSE) > Error: unexpected input in "QueryTrueFX(ConnectTrueFX(username=’" >> > > > > > -- > View this message in context: > http://r.789695.n4.nabble.com/Introducing-TFX-An-R-Interface-to-the-TrueFX-Web-API-tp4651827p4681300.html > Sent from the Rmetrics mailing list archive at Nabble.com. > > ___ > R-SIG-Finance@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-sig-finance > -- Subscriber-posting only. If you want to post, subscribe first. > -- Also note that this is not the r-help list where general R questions > should go. ___ R-SIG-Finance@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-sig-finance -- Subscriber-posting only. If you want to post, subscribe first. -- Also note that this is not the r-help list where general R questions should go.
Re: [R-SIG-Finance] Introducing TFX: An R Interface to the TrueFX Web API
Try typing that command. Your single quote is a weird character. Try this: id <- ConnectTrueFX('EUR/USD,GBP/USD', username='veepsirtt', password='veeps203') On Tue, Nov 26, 2013 at 3:47 AM, veepsirtt wrote: > Hello gsee, > > I tryied the examples given in your documentation. > But I am getting errors. > what is the problem? > With regards > veepsirtt. > > > ## Cannot run these because there may not be an internet connection > ## Not run: > library(TFX) > QueryTrueFX() #unauthenticated > QueryTrueFX(pretty=FALSE) > QueryTrueFX(parse=FALSE) > > ## For authenticated session, you must have a username and password (it’s > free). > ## Use your username and passward instead of JSTrader and Ou812 > > id <- ConnectTrueFX(’EUR/USD,GBP/USD’, username=’veepsirtt’, > password=’veeps203’) > QueryTrueFX(id) > QueryTrueFX(ConnectTrueFX(username=’veepsirtt’, > password=’veeps203’,format=’csv’), parse=FALSE) > QueryTrueFX(ConnectTrueFX(username=’veepsirtt’, > password=’veeps203’,format=’html’), parse=FALSE) > ## If you have shiny installed > ## install.packages("shiny", repos="http://rstudio.org/_packages";) > library(shiny) > > runGist("4122626") > > ## view the code for this shiny app at > #browseURL("https://gist.github.com/4122626";) > ## End(Not run)-- > > > > RESULTS*** >> source('~/.active-rstudio-document', echo=TRUE) > Error in source("~/.active-rstudio-document", echo = TRUE) : > ~/.active-rstudio-document:11:21: unexpected input > 10: > 11: id <- ConnectTrueFX(� >^ >> sessionInfo() > R version 2.15.3 (2013-03-01) > Platform: x86_64-pc-linux-gnu (64-bit) > > locale: > [1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C > LC_TIME=en_US.UTF-8LC_COLLATE=en_US.UTF-8 > [5] LC_MONETARY=en_US.UTF-8LC_MESSAGES=en_US.UTF-8LC_PAPER=C > LC_NAME=C > [9] LC_ADDRESS=C LC_TELEPHONE=C > LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C > > attached base packages: > [1] stats graphics grDevices utils datasets methods base > > other attached packages: > [1] shiny_0.8.0 TFX_0.1.0 ggplot2_0.9.3.1 xtsExtra_0.0-1 > tseries_0.10-32 quantmod_0.4-0 > [7] TTR_0.21-1 xts_0.9-3 zoo_1.7-9 Defaults_1.1-1 > > loaded via a namespace (and not attached): > [1] bitops_1.0-4.1 caTools_1.13 colorspace_1.2-0 > dichromat_1.2-4digest_0.5.2 > [6] grid_2.15.3gtable_0.1.1 httpuv_1.2.0 labeling_0.1 > lattice_0.20-13 > [11] MASS_7.3-23munsell_0.4plyr_1.7.1 proto_0.3-9.2 > quadprog_1.5-5 > [16] RColorBrewer_1.0-5 Rcpp_0.10.2reshape2_1.2.1 RJSONIO_1.0-1 > scales_0.2.3 > [21] stringr_0.6.1 tools_2.15.3 XML_3.98-1.1 xtable_1.7-0 >> > > > > > > -- > View this message in context: > http://r.789695.n4.nabble.com/Introducing-TFX-An-R-Interface-to-the-TrueFX-Web-API-tp4651827p4681163.html > Sent from the Rmetrics mailing list archive at Nabble.com. > > ___ > R-SIG-Finance@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-sig-finance > -- Subscriber-posting only. If you want to post, subscribe first. > -- Also note that this is not the r-help list where general R questions > should go. ___ R-SIG-Finance@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-sig-finance -- Subscriber-posting only. If you want to post, subscribe first. -- Also note that this is not the r-help list where general R questions should go.
Re: [R-SIG-Finance] day/month/year functions?
I'd guess they come from lubridate. Although, they exist is a few packages. findFn() from the sos package is really good for finding out where a function comes from. library(sos) findFn("day") # it works better for functions with more obscure names. Garrett On Mon, Jul 22, 2013 at 7:15 PM, Mark Knecht wrote: > Hi, >I've got a piece of old code I'm trying to resurrect which contains > this function to convert R dates to TradeStation dates: > > function (MyDate) { > ThisDay = day(MyDate) > ThisMonth = month(MyDate) > ThisYear = year(MyDate) > TSDate = (ThisYear - 1900)*1 + ThisMonth*100 + ThisDay > return(TSDate) > } > > However I don't have the day/month/year functions and so far haven't > found them searching using ??day, etc. > > Does anyone recognize these as coming from a package that for some > reason might not be showing up using ??-type searching? > > Thanks, > Mark > > ___ > R-SIG-Finance@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-sig-finance > -- Subscriber-posting only. If you want to post, subscribe first. > -- Also note that this is not the r-help list where general R questions > should go. ___ R-SIG-Finance@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-sig-finance -- Subscriber-posting only. If you want to post, subscribe first. -- Also note that this is not the r-help list where general R questions should go.
Re: [R-SIG-Finance] Do the blotter demos work?
Looks like it's built on r-forge. You should be able to install it with install.packages("blotter", repos="http://r-forge.r-project.org";) Regards, Garrett ___ R-SIG-Finance@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-sig-finance -- Subscriber-posting only. If you want to post, subscribe first. -- Also note that this is not the r-help list where general R questions should go.
Re: [R-SIG-Finance] qmao and earnings.com problem
That's very disappointing. Thanks for the heads up. Garrett On Sun, Jul 7, 2013 at 6:34 PM, TheTerrible wrote: > Hi All, > > It looks Earnings.com does not exist anymore - redirected to reuters. > So qmao package doesn't work. > > Is there still a way to get earnings info from any free source? > > Thanks in advance, > Ivan > > > > -- > View this message in context: > http://r.789695.n4.nabble.com/qmao-and-earnings-com-problem-tp4671061.html > Sent from the Rmetrics mailing list archive at Nabble.com. > > ___ > R-SIG-Finance@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-sig-finance > -- Subscriber-posting only. If you want to post, subscribe first. > -- Also note that this is not the r-help list where general R questions > should go. ___ R-SIG-Finance@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-sig-finance -- Subscriber-posting only. If you want to post, subscribe first. -- Also note that this is not the r-help list where general R questions should go.
Re: [R-SIG-Finance] Delete bad dividend row
Hi Frank, There are a few ways to do it. library(quantmod) div <- getDividends("PM", from="2010-01-01") # find the row(s) you want to remove and use negative indexing div[-12] div[-which(div == 0.039)] div[-div["2012-12-20", which.i=TRUE]] # exclude specific date by passing logical vector to [.xts div[!index(div) %in% as.Date("2012-12-20")] # exclude specific weekdays div[weekdays(index(div)) != "Thursday"] div[as.POSIXlt(index(div))$wday != 4] # exclude amounts smaller than some arbitrary number div[div > 0.1] # exclude specific amount div[div != 0.039] HTH, Garrett ___ R-SIG-Finance@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-sig-finance -- Subscriber-posting only. If you want to post, subscribe first. -- Also note that this is not the r-help list where general R questions should go.
Re: [R-SIG-Finance] create new columns xts
It might be nice if `[[<-` worked on zoo/xts objects like it does on a data.frame. For example, X <- as.data.frame(temp) n <- 1 X[[paste0("sma.", n)]] <- SMA(X[[1]]) tail(X) But, with zoo/xts objects, temp[[1]] refers to the 1st row of the 1st column. I _think_ the closest you can get is to pass dimnames= through a new xts call like this: merge(temp, xts(SMA(temp), dimnames=list(NULL, paste0("sma.", n It's a shame that the availability of dimnames= is so hidden (and that it has to be specified as a list, which is a little weird.) You probably also wanted your `temp` object to have colnames; otherwise, temp$sma <- SMA(temp) wouldn't work. Instead of doing that with colnames(temp) <- "temp" you could do it when you create the object which can sometimes be more convenient. temp <- xts(1:84, timeCalendar(m=1, d=rep(1:7,each=12),h = seq(0,23,2)), dimnames=list(NULL, "temp")) Garrett On Sun, Jun 23, 2013 at 11:34 AM, Dominykas Grigonis wrote: > One more question, that will get me going. > > temp <- xts(1:84, timeCalendar(m=1, d=rep(1:7,each=12),h = seq(0,23,2))) > > I need to add named column, say SMA(temp) > > nice way to do this is temp$sma <- SMA(temp) > > however it is inside a function and it might have different SMAs, so I want > to adda column named paste0("sma.",n) > > temp$paste0("sma.",n) <- SMA(temp) > temp[,paste0("sma.",n)] <- SMA(temp) > > does not work > > it is an option to use merge > merge(temp,SMA(temp)) > and then colnames > > However my question is whether it is possible to use temp$paste0("sma.",n) <- > SMA(temp) in some way. > I tried temp$as.name(paste0("sma.",n)) and similar options... > > Thank you. > > Kind regards,-- > Dominykas Grigonis > > > [[alternative HTML version deleted]] > > ___ > R-SIG-Finance@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-sig-finance > -- Subscriber-posting only. If you want to post, subscribe first. > -- Also note that this is not the r-help list where general R questions > should go. ___ R-SIG-Finance@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-sig-finance -- Subscriber-posting only. If you want to post, subscribe first. -- Also note that this is not the r-help list where general R questions should go.
Re: [R-SIG-Finance] cut range from time objects
Hi Dominykas I would try the below as my first attempt. library(xts) library(timeSeries) Sys.setenv(TZ="GMT") temp <- xts(1:84, timeCalendar(m=1, d=rep(1:7,each=12),h = seq(0,23,2))) # Monday through Thursday mt <- temp[.indexwday(temp) %in% 1:4] # Friday 00:00:00/20:00:00 f <- temp[.indexwday(temp) == 5L]["T00:00:00/T20:00:00"] # Sunday 20:00:00/24:00:00 s <- temp[.indexwday(temp) == 0L]["T20:00:00.000/T23:59:59.999"] out <- rbind(mt, f, s) # check answer by adding a column with weekday (0-6 starting on Sunday) colnames(out) <- "temp" # have to have a column name to do the next step out$wday <- .indexwday(out) # Now you can look at the output and see that the only times where wday is 0 # are 20:00 or later, and the only times where wday is 5 are 20:00 or earlier out Hope this helps, Garrett On Sun, Jun 23, 2013 at 10:02 AM, Dominykas Grigonis wrote: > Dear all, > > I have come across the issue and I hope you will be able to help me. > > I have minute data and unfortunately it has weekends in it and unfortunately > the values on weekend are not 0s and not NAs, but rather last trading price > of friday. I want to cut the ranges out as it slows down strategy testing. > > Say we have xts object with timeDate index > temp <- xts(1:84, timeCalendar(m=1, d=rep(1:7,each=12),h = seq(0,23,2))) > > > I want to cut rows from friday 20:00 to sunday 20:00. > I started writing function, but it just does not seem right… > > filtertime <- function(x, rwd <- "5/2", rt <- "0800/1400"){ > is.within <- function(x){ > value <- hour(x)*60+minute(x) > (value > range[1] && value < range[2])} > rwd <- as.numeric(strsplit(rwd,"/")[[1]]) > rt <- as.numeric(strsplit(rt,"/")[[1]]) > rt <- (rt%/%100)*60+(rt%%100) > time<- index(x) > if(rwd[1]>rwd[2]){ wsq <- c((rwd[1]:7), (1:rwd[2])) > }else{wsq <- rwd[1]:rwd[2]} > wweek <- sapply(time, function(x){x[all(dayOfWeek(x) != wsq)]}) > wweek <- x[all(dayOfWeek(x) != wsq)] > > } > I am not looking for help on this function, I hope someone could suggest some > efficient way to solve my problem as I am working on 1 year 1minute data. > Thank you in advance. > > Kind regards,-- > Dominykas Grigonis > > > [[alternative HTML version deleted]] > > > ___ > R-SIG-Finance@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-sig-finance > -- Subscriber-posting only. If you want to post, subscribe first. > -- Also note that this is not the r-help list where general R questions > should go. ___ R-SIG-Finance@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-sig-finance -- Subscriber-posting only. If you want to post, subscribe first. -- Also note that this is not the r-help list where general R questions should go.
Re: [R-SIG-Finance] qmao installation failure
BTW, this Warning (as opposed to error) in getEPS() Warning message: In readLines(tmp) : incomplete final line found on 'C:\Users\BAM\AppData\Local\Temp\RtmpC0laFg\file111060ec69e2' actually comes from getFinancials(). It's harmless, but could be avoided if getFinancials() were patched to use warn=FALSE in the readLines() call. Josh, Jeff, Line 13 of getFinancials.R could be changed from Symbol <- readLines(tmp) to Symbols <- readLines(tmp, warn=FALSE) Garrett ___ R-SIG-Finance@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-sig-finance -- Subscriber-posting only. If you want to post, subscribe first. -- Also note that this is not the r-help list where general R questions should go.
Re: [R-SIG-Finance] qmao installation failure
Please update qmao. With the earnings.com webpage, XML:::readHTMLTable() used to return a data.frame where the first row was the headers, so getEarnings() and other functions worked around that by setting the names() to be the first row, then removing that row. In the current release of XML, readHTMLTable() gets the names() right, so my previous work-around is no longer necessary. The current version of qmao is 1.6.5.2. Let me know if you still have issues after upgrading. Garrett On Tue, May 21, 2013 at 2:10 PM, tbam wrote: >> sessionInfo() > R version 2.15.3 (2013-03-01) > Platform: x86_64-w64-mingw32/x64 (64-bit) > > locale: > [1] LC_COLLATE=English_United States.1252 LC_CTYPE=English_United > States.1252 > [3] LC_MONETARY=English_United States.1252 LC_NUMERIC=C > [5] LC_TIME=English_United States.1252 > > attached base packages: > [1] stats graphics grDevices utils datasets methods base > > other attached packages: > [1] pander_0.3.6 qmao_1.6 ggplot2_0.9.3.1 > [4] devtools_1.1 XML_3.96-1.1 gdata_2.12.0.2 > [7] FinancialInstrument_1.1.7 quantmod_0.4-0TTR_0.22-0 > [10] Defaults_1.1-1xts_0.9-3 zoo_1.7-9 > > Thanks! > > > > -- > View this message in context: > http://r.789695.n4.nabble.com/qmao-installation-failure-tp4661552p4667635.html > Sent from the Rmetrics mailing list archive at Nabble.com. > > ___ > R-SIG-Finance@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-sig-finance > -- Subscriber-posting only. If you want to post, subscribe first. > -- Also note that this is not the r-help list where general R questions > should go. ___ R-SIG-Finance@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-sig-finance -- Subscriber-posting only. If you want to post, subscribe first. -- Also note that this is not the r-help list where general R questions should go.
Re: [R-SIG-Finance] qmao installation failure
Please provide the output of sessionInfo() For me, with this sessionInfo() > sessionInfo() R version 3.0.1 (2013-05-16) Platform: x86_64-pc-linux-gnu (64-bit) locale: [1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C [3] LC_TIME=en_US.UTF-8LC_COLLATE=en_US.UTF-8 [5] LC_MONETARY=en_US.UTF-8LC_MESSAGES=en_US.UTF-8 [7] LC_PAPER=C LC_NAME=C [9] LC_ADDRESS=C LC_TELEPHONE=C [11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C attached base packages: [1] stats graphics grDevices utils datasets methods base other attached packages: [1] qmao_1.6.5.2 XML_3.96-1.1 [3] gdata_2.12.0.2FinancialInstrument_1.1.7 [5] quantmod_0.4-0TTR_0.22-0.1 [7] Defaults_1.1-1xts_0.9-3.2 [9] zoo_1.7-10 loaded via a namespace (and not attached): [1] bitops_1.0-5caTools_1.14digest_0.6.3grid_3.0.1 [5] gtools_2.7.1httpuv_1.0.5lattice_0.20-15 pander_0.3.5 [9] RCurl_1.95-4.1 RJSONIO_1.0-3 shiny_0.5.0.99 xtable_1.7-1 I get this > getEarnings("GOOG") EPS.ESTIMATE EPS.ACTUAL PREV.YEAR.ACTUAL 2004-10-21 15:15:00 NA NA NA 2005-02-01 15:15:00 NA NA NA 2005-04-21 15:15:00 NA NA NA 2005-07-21 15:15:00 NA NA NA 2005-10-20 15:15:00 NA NA NA 2006-01-31 15:15:00 NA NA NA 2006-04-20 15:15:00 1.98 2.29 NA 2006-07-20 15:15:00 2.22 2.49 NA 2006-10-19 15:15:00 2.42 2.62 NA 2007-01-31 15:15:00 2.92 3.18 NA 2007-04-19 15:15:00 3.31 3.68 2.29 2007-07-19 15:15:00 3.59 3.56 2.49 2007-10-18 15:15:00 3.78 3.91 2.62 2008-01-31 15:15:00 4.44 4.43 3.18 2008-04-17 15:15:00 4.52 4.84 3.68 2008-07-17 15:15:00 4.74 4.63 3.56 2008-10-16 15:15:00 4.75 4.92 3.91 2009-01-22 15:15:00 4.95 5.10 4.43 2009-04-16 15:15:00 4.93 5.16 4.84 2009-07-16 15:15:00 5.09 5.36 4.63 2009-10-15 15:15:00 5.42 5.89 4.92 2010-01-21 15:15:00 6.48 6.79 5.10 2010-04-15 15:15:00 6.60 6.76 5.16 2010-07-15 15:15:00 6.52 6.45 5.36 2010-10-14 15:15:00 6.69 7.64 5.89 2011-01-20 15:15:00 8.10 8.75 6.79 2011-04-14 15:15:00 8.10 8.08 6.76 2011-07-14 15:15:00 7.85 8.74 6.45 2011-10-13 15:15:00 8.74 9.72 7.64 2012-01-19 15:15:0010.50 9.50 8.75 2012-04-12 15:15:00 9.65 10.08 8.08 2012-07-19 15:15:0010.04 10.12 8.74 2012-10-18 15:15:0010.65 9.03 9.72 2013-01-22 15:15:0010.42 10.59 9.50 2013-04-18 15:15:0010.66 11.5810.08 2013-07-15 15:15:0010.80 NA10.12 Warning message: In FUN(c("15-Jul-13 - 19-Jul-13", "18-Apr-13 AMC", "22-Jan-13 AMC", : Using 1st date of earnings date range Garrett On Tue, May 21, 2013 at 11:09 AM, dornan wrote: > great package, thanks for putting it together. Getting some errors and > wondering if someone could help. Sorry in advance if posting format > > #only a few lines with this command >> getEPS("Goog") >Goog.Q.EPS > 2012-03-31 8.75 > 2012-06-30 8.56 > 2012-09-30 6.47 > 2012-12-31 9.40 > 2013-03-31 10.00 > Warning message: > In readLines(tmp) : > incomplete final line found on > 'C:\Users\BAM\AppData\Local\Temp\RtmpC0laFg\file111060ec69e2' > > #xts, gdata, pander, all installed, but getting this error >> getEarnings("GOOG") > Error in `[.data.frame`(df, , "TIME") : undefined columns selected > In addition: Warning messages: > 1: NAs introduced by coercion > 2: NAs introduced by coercion > 3: NAs introduced by coercion > > Thanks for any help! > > > > -- > View this message in context: > http://r.789695.n4.nabble.com/qmao-installation-failure-tp4661552p4667618.html > Sent from the Rmetrics mailing list archive at Nabble.com. > > ___ > R-SIG-Finance@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-sig-finance > -- Subscriber-posting only. If you want to post, subscribe first. > -- Also note that this is not the r-help list where general R questions > should go. ___ R-SIG-Finance@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-sig-finance -- Subscriber-posting only. If you want to post, subscribe first. -
Re: [R-SIG-Finance] Help with iBrokers data
For the first part, see ?reqHistory. You can't get 2 years of data though, IB only provides 1 year. For the second part, maybe reqTBBOhistory from my twsInstrument package is useful (https://r-forge.r-project.org/R/?group_id=1113). See also the unexported wrapper twsInstrument:::update.data() Garrett On Mon, Apr 8, 2013 at 8:12 PM, wlblount wrote: > about 30 days ago i posted here looking for historical, intraday data. since > then i have figured out how to use the ibrokers package to download approx 4 > days of 3 minute data (650 bars x 8 variables = 5200 which is the ibrokers > limit for 1 request). > > library(IBrokers) > > tws <- twsConnect() > > symbol <- "uvxy" > > contract<- twsEquity(symbol) > > pricedata<-reqHistoricalData(tws,contract,barSize="3 mins", duration = "1 > W") > > save(pricedata,file=symbol) > > twsDisconnect(tws) > > > my next step is to figure out how to 1- loop this request to get older data > (i would like to get 2 years) and append the saved file. and 2 -eventually > move up to periodically updating 50 or so symbols and saving and appending > all the symbol data to individual files. > > > does anyone have any code or could anyone point me in the right direction? > my coding skills are only slightly above control c and control v . any help > would be greatly appreciated and i will be happy to share data, code, or > whatever i end up with. thanks. Bill > > > > > -- > View this message in context: > http://r.789695.n4.nabble.com/Help-with-iBrokers-data-tp4663719.html > Sent from the Rmetrics mailing list archive at Nabble.com. > > ___ > R-SIG-Finance@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-sig-finance > -- Subscriber-posting only. If you want to post, subscribe first. > -- Also note that this is not the r-help list where general R questions > should go. ___ R-SIG-Finance@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-sig-finance -- Subscriber-posting only. If you want to post, subscribe first. -- Also note that this is not the r-help list where general R questions should go.
Re: [R-SIG-Finance] qmao installation failure
They're on CRAN http://cran.r-project.org/package=gdata http://cran.r-project.org/package=pander Garrett On Fri, Mar 15, 2013 at 7:43 PM, rex wrote: > Tried: >> >> install.packages("qmao", repos="http://R-Forge.R-project.org";) > > package ‘qmao’ is not available (for R version 2.15.3) > > SVN: > svn checkout svn://scm.r-forge.r-project.org/svnroot/twsinstrument/ > Atwsinstrument/pkg > Atwsinstrument/pkg/twsInstrument > [...] > Atwsinstrument/www > Atwsinstrument/www/index.php > Atwsinstrument/README > U twsinstrument > Checked out revision 407. > > cd twsinstrument && R CMD INSTALL ./pkg/qmao && cd .. > * installing to library ‘/home/rex/R/x86_64-pc-linux-gnu-library/2.15’ > ERROR: dependencies ‘gdata’, ‘pander’ are not available for package ‘qmao’ > * removing ‘/home/rex/R/x86_64-pc-linux-gnu-library/2.15/qmao’ > > I was unable to find gdata or pander. > > Any suggestions appreciated. > > Thanks, > > -rex > -- > > ___ > R-SIG-Finance@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-sig-finance > -- Subscriber-posting only. If you want to post, subscribe first. > -- Also note that this is not the r-help list where general R questions > should go. ___ R-SIG-Finance@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-sig-finance -- Subscriber-posting only. If you want to post, subscribe first. -- Also note that this is not the r-help list where general R questions should go.
Re: [R-SIG-Finance] intraday historical data
This is extremely broad. You just want intraday data? Whose day? The SGX provides free intraday data: http://www.sgx.com/wps/portal/sgxweb/home/marketinfo/historical_data/derivatives/time_sales What asset class? TrueFX provides historical tick data for FX (http://truefx.com/?page=downloads). There's a script called download.TrueFX.R in the inst/parser directory of FinancialInstrument that will download and parse that data. (http://r-forge.r-project.org/scm/viewvc.php/pkg/FinancialInstrument/inst/parser/?root=blotter) Maybe you want stocks? Did you search the internet? I found this via google: http://www.quantshare.com/sa-426-6-ways-to-download-free-intraday-and-tick-data-for-the-us-stock-market That link gives 6 sources. One of them is "stooq". They provide 5 days of 5 minute OHLC data for thousands of stocks around the world. I once wrote a script to download and parse that data. I ran it on a crontab for a couple weeks, then they put up a captcha. So, I guess they don't want you downloading the data systematically -- I don't know, I can't read Polish. If you're willing to manually download the data at least once every 5 days, I'd be happy share my code that parses it. Also, the methods that page gives for getting historical intraday data from Google and Yahoo look promising if you're up to parsing it. I think I have some scraps of code laying around somewhere where I started working on that. Let me know if you'd like me to look. I use Interactive Brokers for my personal intraday data needs. They're really hard to beat since they provide a year's worth of data for stocks, bonds, FX, options, futures, etc. for products all over the world. I use (a small adaptation of) twsInstrument:::update.data() to download minutely OHLC data for BID, ASK, and TRADES, data for over 2000 stocks. Since you can only make 6 requests every minute, it takes almost a full day to download 5 days of data. So, it runs 24 hours a day. (it's also helpful to get more than one log-in). There is a cost for Interactive Brokers. It's about 10 or 20 bucks a month, but if you spend that much money on commissions, they waive the fee. I just get minutely data, because I want a lot of history for a lot of symbols, but they also provide 1 second frequency historical data if you are patient. Here's the reference for how much data you can get per request (remember: 6 requests a minute) http://www.interactivebrokers.com/php/apiUsersGuide/apiguide/api/historical_data_limitations.htm If you're interested in realtime/near-realtime intraday data, you have a few options. This will give you a 15 minute delayed quote: getQuote("SPY", src="yahoo") These will give you a real-time quote: library(qmao) getQuote("SPY", src="google") getQuote("SPY", src="IB") # if you have an Interactive Brokers account getQuote("SPY", src="bats") getQuote("SPY", src="bats", what="bbo") getQuote("SPY", src="bats", what="ladder") getQuote("SPY", src="bats", what="depth") getQuote("SPY", src="bats", what="trades") # These come with plot methods too plot(getQuote("SPY", src="bats")) plot(getQuote("SPY", src="ladder")) plot(getQuote("SPY", src="depth")) I created a shiny app using the getQuote.bats stuff. If you run qmao::shinyBATS() it will launch this shiny app: http://glimmer.rstudio.com/gsee/BATS/ You can wrap one of these getQuote calls in a while loop to retrieve a "stream" of data dat <- NULL while(TRUE){ dat <- rbind(dat, getQuote("SPY", src="yahoo")) Sys.sleep(1) } (If you like shiny, here's a crude way to plot intraday data as it comes in -- just replace the rnorm call with a getQuote call: https://gist.github.com/gsee/4384158) If you want real-time intraday fx quotes, see the TFX package (http://rpubs.com/gsee/TFX) Recently, I've been excited about this new free API (requires a free account): https://developers.tradeking.com/documentation/r According to their forums, they're planning on rolling out historical intraday data soon. Currently, you can get snapshots, or streaming data. twsInstrument and qmao can be obtained via svn checkout from https://r-forge.r-project.org/R/?group_id=1113 I hope this helps, and I hope that if you write code to parse some intraday historical data, that you share it with the list. Best, Garrett On Mon, Mar 11, 2013 at 6:15 PM, Bill Blount wrote: > i just mean intraday historical quotes. any ideas where? > > On Mon, Mar 11, 2013 at 6:36 PM, Michael Weylandt < > michael.weyla...@gmail.com> wrote: > >> What exactly do you mean by end of day intraday? >> >> Regardless, I assume the answer is 'yes, many by subscription: some cheap: >> few free.' >> >> MW >> >> On Mar 11, 2013, at 22:26, Bill Blount wrote: >> >> > is there a source for end of day intraday data (i am assuming that yahoo >> is >> > daily only)? >> > >> > Thanks. Bill >> > >> >[[alternative HTML version deleted]] >> > >> > ___ >> > R-SIG-Finance@r-project.org mailing list >> >
Re: [R-SIG-Finance] IBrokers Risk Management Backend Solution Help with twsPortfolioValue
I don't think the socket connection is shut down. R> invisible(reqAccountUpdates(con)) 2 -1 2100 API client has been unsubscribed from account data. R> isConnected(con) [1] TRUE Why does your loop break? Do you get an error in R? The 2100 message is a warning http://www.interactivebrokers.com/php/apiUsersGuide/apiguide/tables/api_message_codes.htm Garrett On Sun, Feb 10, 2013 at 12:33 PM, JohnnyPaper wrote: > Hi Everyone, > > I have a couple of questions to ask, and I absolutely don't mind if this > gets resubmitted anywhere else. It seems as though this may be helpful for > many people trying to manage portfolio risk with IBrokers, which as I may > add is an excellent addition to R. Very nice work on Jeff's part, and many > many thanks. > > I am just trying to keep a loop monitoring my position and shutting them > down if they hit a stop or profit target based on my position value. Mind > you I am submitting these orders after my offline analysis is done at the > EOD. So they are market orders executed at the open, hence the reason for > management of the portfolio in this sense through the twsPortfolioValue > updates in the data.frame . > > Here is the code I am using and the results: > > con <- twsConnect() > > while (TRUE){ > Offset<-50 > Val<-twsPortfolioValue(reqAccountUpdates(con),zero.pos=FALSE) > for (i in 1:nrow(Val)){ > if ( 0.01 * -abs(Val[i,4]) > Val[i,8] ){ > if (Val[i,6] < 0){ > IBrokers:::.placeOrder( con, twsSTK(toString(Val[i,1])), > twsOrder((i+Offset),"BUY",abs(Val[i,6]),"MKT") ) > Offset<- Offset +1 > } else if (Val[i,6] > 0){ > IBrokers:::.placeOrder( con, twsSTK(toString(Val[i,1])), > twsOrder((i+Offset),"SELL",abs(Val[i,6]),"MKT") ) > Offset<- Offset +1 > } > } else if (0.03 * abs(Val[i,4]) < Val[i,8] ){ > if (Val[i,6] < 0){ > IBrokers:::.placeOrder( con, twsSTK(toString(Val[i,1])), > twsOrder((i+Offset),"BUY",abs(Val[i,6]),"MKT") ) > Offset<- Offset +1 > } else if (Val[i,6] > 0){ > IBrokers:::.placeOrder( con, twsSTK(toString(Val[i,1])), > twsOrder((i+Offset),"SELL",abs(Val[i,6]),"MKT") ) > Offset<- Offset +1 > } > } > } > print(Val) > Sys.sleep(5) > } > > 2 -1 2104 Market data farm connection is OK:usfarm > 2 -1 2106 HMDS data farm connection is OK:ushmds >local sectype marketValue averageCostreturn position realizedPNL > unrealizedPNL > 2 AKAM STK-8022.18 -8011.965 -0.0012749681 -227 0 > -10.22 > 6 ETFC STK-7964.32 -7987.240 0.0028695755 -728 0 > 22.92 > 8 FISV STK-8048.00 -7994.000 -0.0067550663 -100 0 > -54.00 > 9 GS STK-8006.97 -7985.040 -0.0027463856 -53 0 > -21.93 > 10 HAR STK-8066.78 -8015.330 -0.0064189493 -177 0 > -51.45 > 11 HNZ STK-7987.07 -7990.070 0.0003754658 -131 0 > 3.00 > 12 ICE STK 8047.898042.140 0.0007149839 54 0 > 5.75 > 14 MOLX STK-8024.33 -8004.405 -0.0024892541 -291 0 > -19.92 > 15 MRK STK-8017.43 -8007.650 -0.0012213320 -195 0 > -9.78 > 16 MWV STK 8053.078009.890 0.0053908356 254 0 > 43.18 > 19 OXY STK-8041.22 -8027.020 -0.0017690250 -91 0 > -14.20 > 21 SIAL STK 8081.328013.160 0.0085060074 104 0 > 68.16 > 23 VFC STK-7962.50 -8028.320 0.0081984775 -52 0 > 65.82 > 25 ZMH STK-8115.41 -8060.680 -0.0067897497 -107 0 > -54.73 > > 2 -1 2100 API client has been unsubscribed from account data. >local sectype marketValue averageCostreturn position realizedPNL > unrealizedPNL > 2 AKAM STK-8022.18 -8011.965 -0.0012749681 -227 0 > -10.22 > 6 ETFC STK-7964.32 -7987.240 0.0028695755 -728 0 > 22.92 > 8 FISV STK-8048.00 -7994.000 -0.0067550663 -100 0 > -54.00 > 9 GS STK-8006.97 -7985.040 -0.0027463856 -53 0 > -21.93 > 10 HAR STK-8066.78 -8015.330 -0.0064189493 -177 0 > -51.45 > 11 HNZ STK-7987.07 -7990.070 0.0003754658 -131 0 > 3.00 > 12 ICE STK 8047.898042.140 0.0007149839 54 0 > 5.75 > 14 MOLX STK-8024.33 -8004.405 -0.0024892541 -291 0 > -19.92 > 15 MRK STK-8017.43 -8007.650 -0.0012213320 -195 0 > -9.78 > 16 MWV STK 8053.078009.890 0.0053908356 254 0 > 43.18 > 19 OXY STK-8041.22 -8027.020 -0.0017690250 -91 0 > -14.20 > 21 SIAL STK 8081
Re: [R-SIG-Finance] 4-digit SIC codes
There are actually non-break spaces in the source code of the page. If you look at it, you will see things like this: A/D Whether or not XML::trim gets rid of them for you may be OS specific. See and answer to an old question of mine on R-help for example https://stat.ethz.ch/pipermail/r-help/2012-February/302417.html Best, Garrett On Tue, Feb 5, 2013 at 8:20 AM, David Reiner wrote: > Very nice, Garrett! > More curious than anything, but does anyone know why I get the extraneous > characters when I do it? > They are present in x as well. I believe they are non-breaking spaces. > >> head(SIC) > SICCode A/D  Office  Industry Title > 4 1005 ÂAGRICULTURAL PRODUCTION-CROPS > 5 2005  AGRICULTURAL PROD-LIVESTOCK & ANIMAL SPECIALTIES > 6 7005 ÂAGRICULTURAL SERVICES > 7 8005  FORESTRY > 8 9005 ÂFISHING, HUNTING AND TRAPPING > 910009  METAL MINING >> sessionInfo() > R version 2.15.2 (2012-10-26) > Platform: x86_64-w64-mingw32/x64 (64-bit) > > locale: > [1] LC_COLLATE=English_United States.1252 LC_CTYPE=English_United > States.1252LC_MONETARY=English_United States.1252 > [4] LC_NUMERIC=C LC_TIME=English_United States.1252 > > attached base packages: > [1] stats graphics grDevices utils datasets methods base > > other attached packages: > [1] XML_3.95-0.1 > > loaded via a namespace (and not attached): > [1] tools_2.15.2 > > Thanks, > -- David Reiner > > > -Original Message- > From: r-sig-finance-boun...@r-project.org > [mailto:r-sig-finance-boun...@r-project.org] On Behalf Of G See > Sent: Monday, February 04, 2013 9:30 PM > To: Bastian Offermann > Cc: r-sig-finance@r-project.org > Subject: Re: [R-SIG-Finance] 4-digit SIC codes > > I'm not sure, but here's a really quick and dirty way to get it > >> library(XML) >> x <- readHTMLTable("http://www.sec.gov/info/edgar/siccodes.htm";, > stringsAsFactors=FALSE)[[4]] >> colnames(x) <- x[2, ] >> SIC <- x[-c(1:3), ] >> head(SIC) > SICCode A/D OfficeIndustry Title > 4 100 5 AGRICULTURAL PRODUCTION-CROPS > 5 200 5 AGRICULTURAL PROD-LIVESTOCK & ANIMAL SPECIALTIES > 6 700 5 AGRICULTURAL SERVICES > 7 800 5 FORESTRY > 8 900 5 FISHING, HUNTING AND TRAPPING > 91000 9 METAL MINING > >> SIC[SIC$SICCode == "2834", ] >SICCode A/D Office Industry Title > 912834 1 PHARMACEUTICAL PREPARATIONS > > HTH, > Garrett > > On Mon, Feb 4, 2013 at 9:19 PM, Bastian Offermann > wrote: >> Hi, >> does anybody know whether 4-digit SIC codes are available in R? Something >> along the lines >> >> "2834" "Pharmaceutical Preparations" >> >> Thank you. >> >> ___ >> R-SIG-Finance@r-project.org mailing list >> https://stat.ethz.ch/mailman/listinfo/r-sig-finance >> -- Subscriber-posting only. If you want to post, subscribe first. >> -- Also note that this is not the r-help list where general R questions >> should go. > > ___ > R-SIG-Finance@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-sig-finance > -- Subscriber-posting only. If you want to post, subscribe first. > -- Also note that this is not the r-help list where general R questions > should go. > > > This e-mail and any materials attached hereto, including, without limitation, > all content hereof and thereof (collectively, "XR Content") are confidential > and proprietary to XR Trading, LLC ("XR") and/or its affiliates, and are > protected by intellectual property laws. Without the prior written consent > of XR, the XR Content may not (i) be disclosed to any third party or (ii) be > reproduced or otherwise used by anyone other than current employees of XR or > its affiliates, on behalf of XR or its affiliates. > > THE XR CONTENT IS PROVIDED AS IS, WITHOUT REPRESENTATIONS OR WARRANTIES OF > ANY KIND. TO THE MAXIMUM EXTENT PERMISSIBLE UNDER APPLICABLE LAW, XR HEREBY > DISCLAIMS ANY AND ALL WARRANTIES, EXPRESS AND IMPLI
Re: [R-SIG-Finance] 4-digit SIC codes
I'm not sure, but here's a really quick and dirty way to get it > library(XML) > x <- readHTMLTable("http://www.sec.gov/info/edgar/siccodes.htm";, stringsAsFactors=FALSE)[[4]] > colnames(x) <- x[2, ] > SIC <- x[-c(1:3), ] > head(SIC) SICCode A/D OfficeIndustry Title 4 100 5 AGRICULTURAL PRODUCTION-CROPS 5 200 5 AGRICULTURAL PROD-LIVESTOCK & ANIMAL SPECIALTIES 6 700 5 AGRICULTURAL SERVICES 7 800 5 FORESTRY 8 900 5 FISHING, HUNTING AND TRAPPING 91000 9 METAL MINING > SIC[SIC$SICCode == "2834", ] SICCode A/D Office Industry Title 912834 1 PHARMACEUTICAL PREPARATIONS HTH, Garrett On Mon, Feb 4, 2013 at 9:19 PM, Bastian Offermann wrote: > Hi, > does anybody know whether 4-digit SIC codes are available in R? Something > along the lines > > "2834" "Pharmaceutical Preparations" > > Thank you. > > ___ > R-SIG-Finance@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-sig-finance > -- Subscriber-posting only. If you want to post, subscribe first. > -- Also note that this is not the r-help list where general R questions > should go. ___ R-SIG-Finance@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-sig-finance -- Subscriber-posting only. If you want to post, subscribe first. -- Also note that this is not the r-help list where general R questions should go.
Re: [R-SIG-Finance] Fitting RSLN models
Sorry for the html, I'm having a hell of a time getting gmail to consistently send plain text. Looks like the code has been removed in Rev. 8. You can still get Rev. 7, but since the author removed the code, maybe you don't want it afterall? svn checkout svn://svn.r-forge.r-project.org/svnroot/rsln/@7 If the above line doesn't make sense, see http://stackoverflow.com/questions/11105131/cannot-install-r-forge-package-using-install-packages/11105132#11105132 Garrett On Fri, Jan 11, 2013 at 1:56 PM, G See wrote: > Looks like the code has been removed in Rev. 8. You can still get Rev. 7, > but since the author removed the code, maybe you don't want it afterall? > > svn checkout svn://svn.r-forge.r-project.org/svnroot/rsln/@7 > > If the above line doesn't make sense, see > > http://stackoverflow.com/questions/11105131/cannot-install-r-forge-package-using-install-packages/11105132#11105132 > > Garrett > > On Fri, Jan 11, 2013 at 1:50 PM, jaimie villanueva > wrote: >> >> Fitting RSLN > > > ___ R-SIG-Finance@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-sig-finance -- Subscriber-posting only. If you want to post, subscribe first. -- Also note that this is not the r-help list where general R questions should go.
Re: [R-SIG-Finance] Fitting RSLN models
Looks like the code has been removed in Rev. 8. You can still get Rev. 7, but since the author removed the code, maybe you don't want it afterall? svn checkout svn://svn.r-forge.r-project.org/svnroot/rsln/@7 If the above line doesn't make sense, see http://stackoverflow.com/questions/11105131/cannot-install-r-forge-package-using-install-packages/11105132#11105132 Garrett On Fri, Jan 11, 2013 at 1:50 PM, jaimie villanueva < jaimie.villanu...@gmail.com> wrote: > Fitting RSLN [[alternative HTML version deleted]] ___ R-SIG-Finance@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-sig-finance -- Subscriber-posting only. If you want to post, subscribe first. -- Also note that this is not the r-help list where general R questions should go.
Re: [R-SIG-Finance] Installed quantstrat along with blotter and FinancialInstrument but seems I'm missing .instrument
I sent the e-mail to you directly and did not copy the list. This is a mailing list. nabble makes it look like an online forum, but it is not. Most people receive and reply to messages as e-mails not with nabble. Since you mention it on-list, and people are curious beings, here's what I sent: On Wed, Jan 2, 2013 at 7:50 PM, rquantnoob wrote: > I'm following quantstrat-I.pdf by Guy Yollin to learn the language. With all due respect to Mr. Yollin and the authors of the packages outlined in that (now outdated) pdf, a better place to start learning R is "An Introduction to R" (http://cran.r-project.org/doc/manuals/R-intro.pdf). Garrett On Wed, Jan 2, 2013 at 8:58 PM, rquantnoob wrote: > I don't see your last post but I have the email. Thank you for your > suggestion and I appreciate it, I started yesterday I'm really new, I'll > take anything at this point. :) > > > > -- > View this message in context: > http://r.789695.n4.nabble.com/Installed-quantstrat-along-with-blotter-and-FinancialInstrument-but-seems-I-m-missing-instrument-tp4654469p4654484.html > Sent from the Rmetrics mailing list archive at Nabble.com. > > ___ > R-SIG-Finance@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-sig-finance > -- Subscriber-posting only. If you want to post, subscribe first. > -- Also note that this is not the r-help list where general R questions > should go. ___ R-SIG-Finance@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-sig-finance -- Subscriber-posting only. If you want to post, subscribe first. -- Also note that this is not the r-help list where general R questions should go.
Re: [R-SIG-Finance] Installed quantstrat along with blotter and FinancialInstrument but seems I'm missing .instrument
If you specifically want to use "get" > get("USD", envir=FinancialInstrument:::.instrument) primary_id :"USD" currency :"USD" multiplier :1 tick_size :0.01 identifiers: list() type :"currency" or, I think this works too > .instrument <- FinancialInstrument:::.instrument > get("USD", envir=.instrument) primary_id :"USD" currency :"USD" multiplier :1 tick_size :0.01 identifiers: list() type :"currency" Garrett On Wed, Jan 2, 2013 at 8:11 PM, G See wrote: >> getInstrument("USD") > primary_id :"USD" > currency :"USD" > multiplier :1 > tick_size :0.01 > identifiers: list() > type :"currency" > > Please have a look at the demo directory of the package. > > Best, > Garrett > > On Wed, Jan 2, 2013 at 8:08 PM, rquantnoob wrote: >> First, thank you for taking your time to reply to my message. >> >> Here is the next step that perhaps will shed light on what's happening. >> >>> currency("USD") >> [1] "USD" >> >> > get("USD",envir=.instrument) >> Error in get("USD", envir = .instrument) : object '.instrument' not found >> >> >> >> >> >> -- >> View this message in context: >> http://r.789695.n4.nabble.com/Installed-quantstrat-along-with-blotter-and-FinancialInstrument-but-seems-I-m-missing-instrument-tp4654469p4654475.html >> Sent from the Rmetrics mailing list archive at Nabble.com. >> >> ___ >> R-SIG-Finance@r-project.org mailing list >> https://stat.ethz.ch/mailman/listinfo/r-sig-finance >> -- Subscriber-posting only. If you want to post, subscribe first. >> -- Also note that this is not the r-help list where general R questions >> should go. ___ R-SIG-Finance@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-sig-finance -- Subscriber-posting only. If you want to post, subscribe first. -- Also note that this is not the r-help list where general R questions should go.
Re: [R-SIG-Finance] Installed quantstrat along with blotter and FinancialInstrument but seems I'm missing .instrument
> getInstrument("USD") primary_id :"USD" currency :"USD" multiplier :1 tick_size :0.01 identifiers: list() type :"currency" Please have a look at the demo directory of the package. Best, Garrett On Wed, Jan 2, 2013 at 8:08 PM, rquantnoob wrote: > First, thank you for taking your time to reply to my message. > > Here is the next step that perhaps will shed light on what's happening. > >> currency("USD") > [1] "USD" > > > get("USD",envir=.instrument) > Error in get("USD", envir = .instrument) : object '.instrument' not found > > > > > > -- > View this message in context: > http://r.789695.n4.nabble.com/Installed-quantstrat-along-with-blotter-and-FinancialInstrument-but-seems-I-m-missing-instrument-tp4654469p4654475.html > Sent from the Rmetrics mailing list archive at Nabble.com. > > ___ > R-SIG-Finance@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-sig-finance > -- Subscriber-posting only. If you want to post, subscribe first. > -- Also note that this is not the r-help list where general R questions > should go. ___ R-SIG-Finance@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-sig-finance -- Subscriber-posting only. If you want to post, subscribe first. -- Also note that this is not the r-help list where general R questions should go.
Re: [R-SIG-Finance] Installed quantstrat along with blotter and FinancialInstrument but seems I'm missing .instrument
I mean it's probably NOT necessary to assign it to your workspace. On Wed, Jan 2, 2013 at 8:04 PM, G See wrote: > The .instrument environment is now stored in the FinancialInstrument > NAMESPACE. > > .instrument is now FinancialInstrument:::.instrument > > I don't know what the rest of the pdf does, so I'm not sure what's > keeping you from following through. I suppose you could do this > assignment > > .instrument <- FinancialInstrument:::.instrument > > I'd guess that will make things work for you since environments are by > reference, but it's probably necessary. What specifically is holding > you back? > > Garrett > > > > > > On Wed, Jan 2, 2013 at 7:50 PM, rquantnoob wrote: >> I'm following quantstrat-I.pdf by Guy Yollin to learn the language. But it >> seems the .instrument does not load for me as it does in the .pdf. >> Installing quanstrat, installed 3 packages, "blotter","financialinstrument" >> and "quantstrat". >> >> .PDF example >> >> R Code: >>> ls(all=T) >> [1] ".blotter" ".instrument" >> >> ___ >> >> Mine. >> >>> ls(all=T) >> [1] ".blotter" >> >> Since I'm missing ".instrument" it isn't allowing me to follow through with >> the next step. >> >> The installation seemed to have gone through fine, please help. >> >> Thank you. >> >> >> >> -- >> View this message in context: >> http://r.789695.n4.nabble.com/Installed-quantstrat-along-with-blotter-and-FinancialInstrument-but-seems-I-m-missing-instrument-tp4654469.html >> Sent from the Rmetrics mailing list archive at Nabble.com. >> >> ___ >> R-SIG-Finance@r-project.org mailing list >> https://stat.ethz.ch/mailman/listinfo/r-sig-finance >> -- Subscriber-posting only. If you want to post, subscribe first. >> -- Also note that this is not the r-help list where general R questions >> should go. ___ R-SIG-Finance@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-sig-finance -- Subscriber-posting only. If you want to post, subscribe first. -- Also note that this is not the r-help list where general R questions should go.
Re: [R-SIG-Finance] Installed quantstrat along with blotter and FinancialInstrument but seems I'm missing .instrument
The .instrument environment is now stored in the FinancialInstrument NAMESPACE. .instrument is now FinancialInstrument:::.instrument I don't know what the rest of the pdf does, so I'm not sure what's keeping you from following through. I suppose you could do this assignment .instrument <- FinancialInstrument:::.instrument I'd guess that will make things work for you since environments are by reference, but it's probably necessary. What specifically is holding you back? Garrett On Wed, Jan 2, 2013 at 7:50 PM, rquantnoob wrote: > I'm following quantstrat-I.pdf by Guy Yollin to learn the language. But it > seems the .instrument does not load for me as it does in the .pdf. > Installing quanstrat, installed 3 packages, "blotter","financialinstrument" > and "quantstrat". > > .PDF example > > R Code: >> ls(all=T) > [1] ".blotter" ".instrument" > > ___ > > Mine. > >> ls(all=T) > [1] ".blotter" > > Since I'm missing ".instrument" it isn't allowing me to follow through with > the next step. > > The installation seemed to have gone through fine, please help. > > Thank you. > > > > -- > View this message in context: > http://r.789695.n4.nabble.com/Installed-quantstrat-along-with-blotter-and-FinancialInstrument-but-seems-I-m-missing-instrument-tp4654469.html > Sent from the Rmetrics mailing list archive at Nabble.com. > > ___ > R-SIG-Finance@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-sig-finance > -- Subscriber-posting only. If you want to post, subscribe first. > -- Also note that this is not the r-help list where general R questions > should go. ___ R-SIG-Finance@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-sig-finance -- Subscriber-posting only. If you want to post, subscribe first. -- Also note that this is not the r-help list where general R questions should go.
Re: [R-SIG-Finance] Futures data (G See)
Eduoard, I like that site (and I like the subject of this e-mail :) ). Have you written anything or do you know of some open source code to pull that data into R without having to manually download it? Thanks, Garrett On Sun, Dec 16, 2012 at 7:20 AM, Edouard Tallent wrote: > Hi all. > > Please, have a look at wikiposit.org/p?futures > > Best, > Édouard > -- > http://quantcorner.wordpress.com > > > ___ > R-SIG-Finance@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-sig-finance > -- Subscriber-posting only. If you want to post, subscribe first. > -- Also note that this is not the r-help list where general R questions > should go. ___ R-SIG-Finance@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-sig-finance -- Subscriber-posting only. If you want to post, subscribe first. -- Also note that this is not the r-help list where general R questions should go.
Re: [R-SIG-Finance] Combining instrument data into one xts
A common way to do this is to store your data in its own environment. Then, use eapply to get a list of close prices. Finally, construct a merge call with do.call s <- c("SPY", "AAPL") myEnv <- new.env() getSymbols(s, src='yahoo', env=myEnv) p <- do.call(merge, eapply(myEnv, Cl)) this is like calling merge(Cl(SPY), Cl(AAPL)), but it will work for any number of symbols. Similarly, if your data are stored in your globalenv(), you can create a list of Close prices and merge them together using do.call. s <- c("SPY", "AAPL") getSymbols(s, src="yahoo") p <- do.call(merge, lapply(s, function(x) Cl(get(x, pos=globalenv() I also happen to have a function that does this for you in one line in my qmao package on R-Forge. https://r-forge.r-project.org/R/?group_id=1113 library(qmao) p <- PF(getSymbols(c("SPY", "AAPL")), silent=TRUE) HTH, Garrett On Sat, Dec 15, 2012 at 11:06 PM, Robert A'gata wrote: > Hi, > > 1) When I call getSymbols with multiple symbols, is there any way I can > obtain everything into one xts. Says, I want only close data from google > for c("SPY","AAPL"). Is there anyway I can get an xts with 2 columns > corresponding to SPY and AAPL close prices? > 2) Similar to #1, if I have all symbols loaded from files (.RData), is > there any better way to combiing them than merging them one-by-one using > xts? > > Thank you. > > Robert > > [[alternative HTML version deleted]] > > ___ > R-SIG-Finance@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-sig-finance > -- Subscriber-posting only. If you want to post, subscribe first. > -- Also note that this is not the r-help list where general R questions > should go. ___ R-SIG-Finance@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-sig-finance -- Subscriber-posting only. If you want to post, subscribe first. -- Also note that this is not the r-help list where general R questions should go.
Re: [R-SIG-Finance] Futures data
Robert, If you have an Interactive Brokers account -- which isn't free, but pretty close to it -- you can get a year's worth of intraday data for most futures with the IBrokers package (on CRAN). See ?reqHistoricalData. I also have some wrappers for IBrokers functions for getting lots of data from Interactive Brokers in my twsInstrument package on R-Forge. https://r-forge.r-project.org/R/?group_id=1113 (see ?reqTBBOhistory) IB offers 1 second bars, but if you want to get a meaningful amount of history, you're best off getting 1 minute bars because of their historical data request pacing rules. HTH, Garrett On Sat, Dec 15, 2012 at 9:39 PM, Robert A'gata wrote: > Hi, > > I am wondering if there is any source that one can download futures data > such as Eurodollar, treasury, S&P500 e-mini, crude oil, natural gas, > agricultural, etc? Especially downloading from R. Of course, not bloomberg. > Thank you. > > Robert > > [[alternative HTML version deleted]] > > ___ > R-SIG-Finance@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-sig-finance > -- Subscriber-posting only. If you want to post, subscribe first. > -- Also note that this is not the r-help list where general R questions > should go. ___ R-SIG-Finance@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-sig-finance -- Subscriber-posting only. If you want to post, subscribe first. -- Also note that this is not the r-help list where general R questions should go.
Re: [R-SIG-Finance] Futures data
Chinmay, The trading blox data has a column called Unadjusted close. The user is free to use that column. Also, it is trivial to un-adjust the Open, High, and Low as well. And, there is a column showing which contract is being used for each row which makes it trivial to re-adjust prices however you see fit, or not at all. Garrett On Sat, Dec 15, 2012 at 10:13 PM, Chinmay Patil wrote: > Hi Garret, > > Although a good solution, I would insist user to be careful with downloading > data from TradingBlox. > Any futures strategy backtesting especially on higher timeframes like daily > and above will be very sensitive to method of construction of continous > contract and if user is not aware of how such a continuos contract is > created, they may lead themselves to reaching overly optimistic conclusions > from that backtesting. > > TradingBlox data while good (they source the data CSIdata as well) is a > continuous contract based on their rolling methodology and may not suite > every user. > > Best Regards, > Chinmay Patil > > > On Sun, Dec 16, 2012 at 12:03 PM, G See wrote: >> >> If you just want daily data, there is a script in the parser directory >> of FinancialInstrument >> >> (http://r-forge.r-project.org/scm/viewvc.php/*checkout*/pkg/FinancialInstrument/inst/parser/download.tblox.R?root=blotter) >> that will download free data since 1995 from tradingblox. >> >> Try this, >> >> library(FinancialInstrument) >> >> source(paste0("http://r-forge.r-project.org/scm/viewvc.php/*checkout*/pkg/";, >> >> "FinancialInstrument/inst/parser/download.tblox.R?root=blotter")) >> define_futures.tblox() # define meta data for available futures -- not >> required to get data >> >> buildHierarchy(ls_futures(), "description") # show the descriptions of >> available futures >> >> find.instrument("Eurodollar") >> getInstrument("ED") >> >> # this getSymbols.tblox method will download all data from tblox, but will >> only >> # assign the symbols you give it. >> getSymbols("ED", src='tblox') >> tail(ED) >> >> # this will download all tblox futures data and assign in your globalenv() >> get_tblox() >> >> tail(TY) >> head(CL) >> >> HTH, >> Garrett >> >> On Sat, Dec 15, 2012 at 9:39 PM, Robert A'gata wrote: >> > Eurodollar, treasury, S&P500 e-mini, crude oil, natural gas, >> > agricultural >> >> ___ >> R-SIG-Finance@r-project.org mailing list >> https://stat.ethz.ch/mailman/listinfo/r-sig-finance >> -- Subscriber-posting only. If you want to post, subscribe first. >> -- Also note that this is not the r-help list where general R questions >> should go. > > ___ R-SIG-Finance@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-sig-finance -- Subscriber-posting only. If you want to post, subscribe first. -- Also note that this is not the r-help list where general R questions should go.
Re: [R-SIG-Finance] Futures data
Also, for daily VIX futures data, there's a getSymbols.cfe method in my qmao package on R-Forge # install.packages("qmao", repos="http://r-forge.r-project.org";) library(qmao) getSymbols("VX", src='cfe', Months=1:12, Years=2011:2012) Garrett On Sat, Dec 15, 2012 at 10:03 PM, G See wrote: > If you just want daily data, there is a script in the parser directory > of FinancialInstrument > (http://r-forge.r-project.org/scm/viewvc.php/*checkout*/pkg/FinancialInstrument/inst/parser/download.tblox.R?root=blotter) > that will download free data since 1995 from tradingblox. > > Try this, > > library(FinancialInstrument) > source(paste0("http://r-forge.r-project.org/scm/viewvc.php/*checkout*/pkg/";, > "FinancialInstrument/inst/parser/download.tblox.R?root=blotter")) > define_futures.tblox() # define meta data for available futures -- not > required to get data > > buildHierarchy(ls_futures(), "description") # show the descriptions of > available futures > > find.instrument("Eurodollar") > getInstrument("ED") > > # this getSymbols.tblox method will download all data from tblox, but will > only > # assign the symbols you give it. > getSymbols("ED", src='tblox') > tail(ED) > > # this will download all tblox futures data and assign in your globalenv() > get_tblox() > > tail(TY) > head(CL) > > HTH, > Garrett > > On Sat, Dec 15, 2012 at 9:39 PM, Robert A'gata wrote: >> Eurodollar, treasury, S&P500 e-mini, crude oil, natural gas, >> agricultural ___ R-SIG-Finance@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-sig-finance -- Subscriber-posting only. If you want to post, subscribe first. -- Also note that this is not the r-help list where general R questions should go.
Re: [R-SIG-Finance] Futures data
If you just want daily data, there is a script in the parser directory of FinancialInstrument (http://r-forge.r-project.org/scm/viewvc.php/*checkout*/pkg/FinancialInstrument/inst/parser/download.tblox.R?root=blotter) that will download free data since 1995 from tradingblox. Try this, library(FinancialInstrument) source(paste0("http://r-forge.r-project.org/scm/viewvc.php/*checkout*/pkg/";, "FinancialInstrument/inst/parser/download.tblox.R?root=blotter")) define_futures.tblox() # define meta data for available futures -- not required to get data buildHierarchy(ls_futures(), "description") # show the descriptions of available futures find.instrument("Eurodollar") getInstrument("ED") # this getSymbols.tblox method will download all data from tblox, but will only # assign the symbols you give it. getSymbols("ED", src='tblox') tail(ED) # this will download all tblox futures data and assign in your globalenv() get_tblox() tail(TY) head(CL) HTH, Garrett On Sat, Dec 15, 2012 at 9:39 PM, Robert A'gata wrote: > Eurodollar, treasury, S&P500 e-mini, crude oil, natural gas, > agricultural ___ R-SIG-Finance@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-sig-finance -- Subscriber-posting only. If you want to post, subscribe first. -- Also note that this is not the r-help list where general R questions should go.
Re: [R-SIG-Finance] Introducing TFX: An R Interface to the TrueFX Web API
On Mon, Dec 3, 2012 at 11:28 AM, Dennis Lee wrote: > I did get this warning when I ran the code: > >> runGist("4122626") Loading required package: TFX Warning: package ‘TFX’ was >> built under R version 2.15.2 > > I have checked websockets: > > > loaded via a namespace (and not attached): [1] bitops_1.0-5 caTools_1.13 >devtools_0.8 [4] digest_0.6.0 evaluate_0.4.2 httr_0.2 > [7] memoise_0.1 parallel_2.15.1 plyr_1.7.1 > [10] RCurl_1.95-3 RJSONIO_1.0-1stringr_0.6.1 > [13] tools_2.15.1 websockets_1.1.6 whisker_0.1 > [16] xtable_1.7-0 > > I have checked pause updates: > > Pause updates This should be UNchecked! > > So, Windows is not the issue, I have to update R to version 2.15.2 then > seems logical to me. > But, I ran it on R 2.15.1 and it worked fine. See my sessionInfo in the previous message. So, I'm not sure what's not working for you. Maybe some local security settings? Garrett ___ R-SIG-Finance@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-sig-finance -- Subscriber-posting only. If you want to post, subscribe first. -- Also note that this is not the r-help list where general R questions should go.
Re: [R-SIG-Finance] Introducing TFX: An R Interface to the TrueFX Web API
Another possibililty, of course, is that you checked the "Pause updates" check box at the bottom of the page. When that is checked, the quotes don't update. Garrett On Mon, Dec 3, 2012 at 11:12 AM, G See wrote: > I just tried it on Windows and it works for me with the sessionInfo below. > > Are you sure you have at least version 1.1.6 of websockets? > >> sessionInfo() > R version 2.15.1 (2012-06-22) > Platform: x86_64-pc-mingw32/x64 (64-bit) > > locale: > [1] LC_COLLATE=English_United States.1252 LC_CTYPE=English_United > States.1252LC_MONETARY=English_United States.1252 LC_NUMERIC=C > LC_TIME=English_United States.1252 > > attached base packages: > [1] stats graphics grDevices utils datasets methods base > > other attached packages: > [1] bitops_1.0-5 TFX_0.1.0shiny_0.2.3 > > loaded via a namespace (and not attached): > [1] caTools_1.13 digest_0.5.2 RJSONIO_1.0-1tools_2.15.1 > websockets_1.1.6 XML_3.9-4.1 xtable_1.7-0 > > Garrett > > > On Mon, Dec 3, 2012 at 11:09 AM, Jeff Ryan wrote: >> If the backend is using websockets, that is very new ground in the land of >> HTML. M$ prides itself typically on being off by a decade w.r.t. adoption >> of such 'shiny' things. >> >> So... that may indeed be your issue. >> >> Jeff >> >> >> On Mon, Dec 3, 2012 at 11:05 AM, Dennis Lee wrote: >> >>> I am running it on Windows, maybe you didn't understand what I said. >>> >>> I did get the first quote displayed correctly, so it is not because of the >>> library. >>> >>> My problem is that it doesn't update periodically. I will try to figure it >>> out >>> when I have time, just too late now (its past midnight here) to solve this. >>> >>> > sessionInfo() R version 2.15.1 (2012-06-22) >>> Platform: i386-pc-mingw32/i386 (32-bit) >>> >>> It could be because of my R version (maybe not), but then again I have >>> >>> installed the CRAN version of shiny (and not the dev version on Github). >>> >>> >>> >>> >>> From: Dirk Eddelbuettel >>> >>> Cc: r-sig-finance >>> Sent: Tuesday, 4 December 2012 12:56 AM >>> Subject: Re: [R-SIG-Finance] Introducing TFX: An R Interface to the TrueFX >>> Web API >>> >>> >>> On 3 December 2012 at 08:33, Dennis Lee wrote: >>> | I copied and pasted the code for Shiny app, but it doesn't update the FX >>> quotes >>> | every 750 ms. I tried it on Firefox and Chrome. >>> >>> "I copied and paste" ? Maybe you did that the wrong way? >>> >>> What happens when you install the shiny and TFX packages, and execute >>> >>> library(shiny) >>> runGist("4122626") >>> >>> which has been very reliable for me on different machine >>> (home/work/netbook/...) ? >>> >>> Dirk >>> >>> -- >>> Dirk Eddelbuettel | e...@debian.org | http://dirk.eddelbuettel.com >>> [[alternative HTML version deleted]] >>> >>> >>> ___ >>> R-SIG-Finance@r-project.org mailing list >>> https://stat.ethz.ch/mailman/listinfo/r-sig-finance >>> -- Subscriber-posting only. If you want to post, subscribe first. >>> -- Also note that this is not the r-help list where general R questions >>> should go. >>> >> >> >> >> -- >> Jeffrey Ryan >> jeffrey.r...@lemnica.com >> >> www.lemnica.com >> >> [[alternative HTML version deleted]] >> >> ___ >> R-SIG-Finance@r-project.org mailing list >> https://stat.ethz.ch/mailman/listinfo/r-sig-finance >> -- Subscriber-posting only. If you want to post, subscribe first. >> -- Also note that this is not the r-help list where general R questions >> should go. ___ R-SIG-Finance@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-sig-finance -- Subscriber-posting only. If you want to post, subscribe first. -- Also note that this is not the r-help list where general R questions should go.
Re: [R-SIG-Finance] Introducing TFX: An R Interface to the TrueFX Web API
I just tried it on Windows and it works for me with the sessionInfo below. Are you sure you have at least version 1.1.6 of websockets? > sessionInfo() R version 2.15.1 (2012-06-22) Platform: x86_64-pc-mingw32/x64 (64-bit) locale: [1] LC_COLLATE=English_United States.1252 LC_CTYPE=English_United States.1252LC_MONETARY=English_United States.1252 LC_NUMERIC=C LC_TIME=English_United States.1252 attached base packages: [1] stats graphics grDevices utils datasets methods base other attached packages: [1] bitops_1.0-5 TFX_0.1.0shiny_0.2.3 loaded via a namespace (and not attached): [1] caTools_1.13 digest_0.5.2 RJSONIO_1.0-1tools_2.15.1 websockets_1.1.6 XML_3.9-4.1 xtable_1.7-0 Garrett On Mon, Dec 3, 2012 at 11:09 AM, Jeff Ryan wrote: > If the backend is using websockets, that is very new ground in the land of > HTML. M$ prides itself typically on being off by a decade w.r.t. adoption > of such 'shiny' things. > > So... that may indeed be your issue. > > Jeff > > > On Mon, Dec 3, 2012 at 11:05 AM, Dennis Lee wrote: > >> I am running it on Windows, maybe you didn't understand what I said. >> >> I did get the first quote displayed correctly, so it is not because of the >> library. >> >> My problem is that it doesn't update periodically. I will try to figure it >> out >> when I have time, just too late now (its past midnight here) to solve this. >> >> > sessionInfo() R version 2.15.1 (2012-06-22) >> Platform: i386-pc-mingw32/i386 (32-bit) >> >> It could be because of my R version (maybe not), but then again I have >> >> installed the CRAN version of shiny (and not the dev version on Github). >> >> >> >> >> From: Dirk Eddelbuettel >> >> Cc: r-sig-finance >> Sent: Tuesday, 4 December 2012 12:56 AM >> Subject: Re: [R-SIG-Finance] Introducing TFX: An R Interface to the TrueFX >> Web API >> >> >> On 3 December 2012 at 08:33, Dennis Lee wrote: >> | I copied and pasted the code for Shiny app, but it doesn't update the FX >> quotes >> | every 750 ms. I tried it on Firefox and Chrome. >> >> "I copied and paste" ? Maybe you did that the wrong way? >> >> What happens when you install the shiny and TFX packages, and execute >> >> library(shiny) >> runGist("4122626") >> >> which has been very reliable for me on different machine >> (home/work/netbook/...) ? >> >> Dirk >> >> -- >> Dirk Eddelbuettel | e...@debian.org | http://dirk.eddelbuettel.com >> [[alternative HTML version deleted]] >> >> >> ___ >> R-SIG-Finance@r-project.org mailing list >> https://stat.ethz.ch/mailman/listinfo/r-sig-finance >> -- Subscriber-posting only. If you want to post, subscribe first. >> -- Also note that this is not the r-help list where general R questions >> should go. >> > > > > -- > Jeffrey Ryan > jeffrey.r...@lemnica.com > > www.lemnica.com > > [[alternative HTML version deleted]] > > ___ > R-SIG-Finance@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-sig-finance > -- Subscriber-posting only. If you want to post, subscribe first. > -- Also note that this is not the r-help list where general R questions > should go. ___ R-SIG-Finance@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-sig-finance -- Subscriber-posting only. If you want to post, subscribe first. -- Also note that this is not the r-help list where general R questions should go.
Re: [R-SIG-Finance] Introducing TFX: An R Interface to the TrueFX Web API
Aw. That's a shame. What version of shiny and websockets are you using? Maybe try: devtools::install_github('shiny', 'rstudio') It works for me on linux with the following sessionInfo > sessionInfo() R version 2.15.2 (2012-10-26) Platform: x86_64-pc-linux-gnu (64-bit) locale: [1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C [3] LC_TIME=en_US.UTF-8LC_COLLATE=en_US.UTF-8 [5] LC_MONETARY=en_US.UTF-8LC_MESSAGES=en_US.UTF-8 [7] LC_PAPER=C LC_NAME=C [9] LC_ADDRESS=C LC_TELEPHONE=C [11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C attached base packages: [1] stats graphics grDevices utils datasets methods base other attached packages: [1] bitops_1.0-4.1 TFX_0.1.1 shiny_0.1.12 loaded via a namespace (and not attached): [1] caTools_1.13 digest_0.6.0 RJSONIO_1.0-1tools_2.15.2 [5] websockets_1.1.6 XML_3.95-0.1 xtable_1.7-0 Garrett On Mon, Dec 3, 2012 at 10:33 AM, Dennis Lee wrote: > > > I copied and pasted the code for Shiny app, but it doesn't update the FX > quotes > every 750 ms. I tried it on Firefox and Chrome. > > > > > From: G See > To: r-sig-finance > Sent: Monday, 3 December 2012 8:57 PM > Subject: [R-SIG-Finance] Introducing TFX: An R Interface to the TrueFX Web API > > [sorry for the previous HTML e-mail. Gmail seems to think that's what > I meant to do] > > Hello all, > > I'd like to introduce the TFX package which I recently published to CRAN. > > It is a simple R interface to the free TrueFX Web API. You can use it > to get real-time quotes with millisecond resolution and fractional-pip > bid/ask spreads for 26 currency pairs. > > There is an RPub overview of the TFX package available here: > http://rpubs.com/gsee/TFX > > The shiny package (http://www.rstudio.com/shiny/) has made the TFX > package more relevant (at least to me). You can see a demo of using > TFX with shiny by running the following code which will open a browser > window and display FX quotes that update every 750 milliseconds: > > # install.packages('shiny', repos=c('http://rstudio.org/_packages', > # getOption('repos')) > library(shiny) > runGist("4122626") > #-- > The code for the above shiny app can be viewed or downloaded from > https://gist.github.com/4122626 > > I've also had a little bit of success creating real-time streaming > charts using svSockets, following the video > (http://www.youtube.com/watch?v=rvT8XThGA8o) on the data.table > homepage (http://datatable.r-forge.r-project.org/) as a template and > using TFX as the data source. > > Finally, TrueFX provides historical tick data for 15 currency pairs > going back to May 2009 (http://truefx.com/?page=downloads). There is a > script in the inst/parser directory of the FinancialInstrument package > (www.tinyurl.com/DownloadTrueFX) that can be used to download all of > that data to disk in a format that FinancialInstrument::getSymbols.FI > can easily read. This script is not intended to be used on Windows. > > I have no affiliation with TrueFX. > > Hope it's useful, > Garrett > > P.S. The RPub (http://rpubs.com/gsee/TFX) is also included as a > vignette in the R-Forge version (installable with > install.packages("TFX", repos="http://r-forge.r-project.org";). As > outlined in the NEWS file, the only updates in the R-Forge version are > aesthetic: there are better error messages, a print.TFXsession method, > and Reconnect and Disconnect no longer print the returned TFXsession > object. > > ___ > R-SIG-Finance@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-sig-finance > -- Subscriber-posting only. If you want to post, subscribe first. > -- Also note that this is not the r-help list where general R questions > should go. > [[alternative HTML version deleted]] > > ___ > R-SIG-Finance@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-sig-finance > -- Subscriber-posting only. If you want to post, subscribe first. > -- Also note that this is not the r-help list where general R questions > should go. ___ R-SIG-Finance@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-sig-finance -- Subscriber-posting only. If you want to post, subscribe first. -- Also note that this is not the r-help list where general R questions should go.
[R-SIG-Finance] Introducing TFX: An R Interface to the TrueFX Web API
[sorry for the previous HTML e-mail. Gmail seems to think that's what I meant to do] Hello all, I'd like to introduce the TFX package which I recently published to CRAN. It is a simple R interface to the free TrueFX Web API. You can use it to get real-time quotes with millisecond resolution and fractional-pip bid/ask spreads for 26 currency pairs. There is an RPub overview of the TFX package available here: http://rpubs.com/gsee/TFX The shiny package (http://www.rstudio.com/shiny/) has made the TFX package more relevant (at least to me). You can see a demo of using TFX with shiny by running the following code which will open a browser window and display FX quotes that update every 750 milliseconds: # install.packages('shiny', repos=c('http://rstudio.org/_packages', # getOption('repos')) library(shiny) runGist("4122626") #-- The code for the above shiny app can be viewed or downloaded from https://gist.github.com/4122626 I've also had a little bit of success creating real-time streaming charts using svSockets, following the video (http://www.youtube.com/watch?v=rvT8XThGA8o) on the data.table homepage (http://datatable.r-forge.r-project.org/) as a template and using TFX as the data source. Finally, TrueFX provides historical tick data for 15 currency pairs going back to May 2009 (http://truefx.com/?page=downloads). There is a script in the inst/parser directory of the FinancialInstrument package (www.tinyurl.com/DownloadTrueFX) that can be used to download all of that data to disk in a format that FinancialInstrument::getSymbols.FI can easily read. This script is not intended to be used on Windows. I have no affiliation with TrueFX. Hope it's useful, Garrett P.S. The RPub (http://rpubs.com/gsee/TFX) is also included as a vignette in the R-Forge version (installable with install.packages("TFX", repos="http://r-forge.r-project.org";). As outlined in the NEWS file, the only updates in the R-Forge version are aesthetic: there are better error messages, a print.TFXsession method, and Reconnect and Disconnect no longer print the returned TFXsession object. ___ R-SIG-Finance@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-sig-finance -- Subscriber-posting only. If you want to post, subscribe first. -- Also note that this is not the r-help list where general R questions should go.
[R-SIG-Finance] Introducing TFX: An R Interface to the TrueFX Web API
Hello all, I'd like to introduce the TFX package which I recently published to CRAN. It is a simple R interface to the free TrueFX Web API. You can use it to get real-time quotes with millisecond resolution and fractional-pip bid/ask spreads for 26 currency pairs. There is an RPub overview of the TFX package available here: http://rpubs.com/gsee/TFX The shiny package (http://www.rstudio.com/shiny/) has made the TFX package more relevant (at least to me). You can see a demo of using TFX with shiny by running the following code which will open a browser window and display FX quotes that update every 750 milliseconds: # install.packages('shiny', repos=c('http://rstudio.org/_packages', # getOption('repos')) library(shiny) runGist("4122626") #-- The code for the above shiny app can be viewed or downloaded from https://gist.github.com/4122626 I've also had a little bit of success creating real-time streaming charts using svSockets, following the video ( http://www.youtube.com/watch?v=rvT8XThGA8o) on the data.table homepage ( http://datatable.r-forge.r-project.org/) as a template and using TFX as the data source. Finally, TrueFX provides historical tick data for 15 currency pairs going back to May 2009 (http://truefx.com/?page=downloads). There is a script in the inst/parser directory of the FinancialInstrument package ( www.tinyurl.com/DownloadTrueFX) that can be used to download all of that data to disk in a format that FinancialInstrument::getSymbols.FI can easily read. This script is not intended to be used on Windows. I have no affiliation with TrueFX. Hope it's useful, Garrett P.S. The RPub (http://rpubs.com/gsee/TFX) is also included as a vignette in the R-Forge version (installable with install.packages("TFX", repos=" http://r-forge.r-project.org";). As outlined in the NEWS file, the only updates in the R-Forge version are aesthetic: there are better error messages, a print.TFXsession method, and Reconnect and Disconnect no longer print the returned TFXsession object. [[alternative HTML version deleted]] ___ R-SIG-Finance@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-sig-finance -- Subscriber-posting only. If you want to post, subscribe first. -- Also note that this is not the r-help list where general R questions should go.
Re: [R-SIG-Finance] chart_Series with knitr markdown
Hi Nick, Thanks for the suggestion. Unfortunately it doesn't help. The problem seems to occur when new.replot() is called after chartSeries() (NO underscore) Here is a new RPub to demostrate the same issue. http://rpubs.com/gsee/chart_Series_knit2 And the markdown for that is: Zeroing in on chart_Series issue ```{r message=FALSE} library(quantmod) getSymbols("SPY", src='yahoo') ``` This looks fine ```{r figwidth=7, fig.height=6} chartSeries(SPY) ``` This looks wrong ```{r} cs <- new.replot() ``` Garrett On Sun, Nov 25, 2012 at 2:53 PM, Nick White wrote: > I've not seen this issue before. > > Try passing the ` fig.align="left" ` argument...ie: > > {r fig.width=7, fig.height=6, fig.align='left'} > > > On Mon, Nov 26, 2012 at 2:03 AM, G See wrote: >> >> I'm having trouble getting chart_Series to render properly with markdown >> to >> html. Are others using chart_Series with markdown? What am I doing >> wrong? >> >> The Pub at this link should be self explanatory: >> http://rpubs.com/gsee/chart_Series_knit >> >> The .Rmd file used to produce it is below. >> >> Thanks, >> Garrett >> >> Why doesn't chart_Series look right? >> >> >> ```{r message=FALSE} >> library(quantmod) >> getSymbols("SPY", src='yahoo') >> ``` >> This looks fine >> >> ```{r fig.width=7, fig.height=6} >> chartSeries(SPY) >> ``` >> But, why does this look wrong? i.e. instead of being aligned at the left >> margin, >> there is a box with a question mark. >> ```{r fig.width=7, fig.height=6} >> chart_Series(SPY) >> ``` >> >> [[alternative HTML version deleted]] >> >> ___ >> R-SIG-Finance@r-project.org mailing list >> https://stat.ethz.ch/mailman/listinfo/r-sig-finance >> -- Subscriber-posting only. If you want to post, subscribe first. >> -- Also note that this is not the r-help list where general R questions >> should go. > > ___ R-SIG-Finance@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-sig-finance -- Subscriber-posting only. If you want to post, subscribe first. -- Also note that this is not the r-help list where general R questions should go.
[R-SIG-Finance] chart_Series with knitr markdown
I'm having trouble getting chart_Series to render properly with markdown to html. Are others using chart_Series with markdown? What am I doing wrong? The Pub at this link should be self explanatory: http://rpubs.com/gsee/chart_Series_knit The .Rmd file used to produce it is below. Thanks, Garrett Why doesn't chart_Series look right? ```{r message=FALSE} library(quantmod) getSymbols("SPY", src='yahoo') ``` This looks fine ```{r fig.width=7, fig.height=6} chartSeries(SPY) ``` But, why does this look wrong? i.e. instead of being aligned at the left margin, there is a box with a question mark. ```{r fig.width=7, fig.height=6} chart_Series(SPY) ``` [[alternative HTML version deleted]] ___ R-SIG-Finance@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-sig-finance -- Subscriber-posting only. If you want to post, subscribe first. -- Also note that this is not the r-help list where general R questions should go.
Re: [R-SIG-Finance] xtsExtra
You've typed "source" instead of "repos" Try this: install.packages("xtsExtra", repos="http://r-forge.r-project.org";) HTH, Garrett On Sat, Nov 17, 2012 at 5:53 PM, Eric Thungstom wrote: > Getting this message when I try to install xtsExtra. > > > install.packages('xtsExtra', source = "http://r-forge.r-project.org";) > Installing package(s) into C:/PROGRA~1/R/R-212~1.0/library > (as lib is unspecified) > Warning in install.packages : > package xtsExtra is not available > > > > Is there a problem with this package to where it's no longer available ? > > [[alternative HTML version deleted]] > > > ___ > R-SIG-Finance@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-sig-finance > -- Subscriber-posting only. If you want to post, subscribe first. > -- Also note that this is not the r-help list where general R questions > should go. > [[alternative HTML version deleted]] ___ R-SIG-Finance@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-sig-finance -- Subscriber-posting only. If you want to post, subscribe first. -- Also note that this is not the r-help list where general R questions should go.
Re: [R-SIG-Finance] [R] (no subject)
Manasvi, Did you add 127.0.0.1 to "Trusted IP Addresses"? -Garrett On Fri, Nov 9, 2012 at 8:39 AM, R. Michael Weylandt < michael.weyla...@gmail.com> wrote: > Forwarding to the relevant list. > > MW > > On Fri, Nov 9, 2012 at 9:01 AM, Manasvi Dobhal > wrote: > > Hi all, > > The TWS on my system is unable to connect to my R session. Here is the > > error that I'm getting: > > > > *> tws<-twsConnect() > > Error in socketConnection(host = host, port = port, open = "ab", > blocking = > > blocking) : > > cannot open the connection > > In addition: Warning message: > > In socketConnection(host = host, port = port, open = "ab", blocking = > > blocking) : > > localhost:7496 cannot be opened* > > > > Here is the session info for the R session: > > > > *R version 2.15.1 (2012-06-22)* > > ** > > > > *Platform: x86_64-pc-linux-gnu (64-bit)* > > > > ** > > > > *locale:* > > > > * [1] LC_CTYPE=en_IN.UTF-8LC_NUMERIC=C* > > > > * [3] LC_TIME=en_IN.UTF-8LC_COLLATE=en_IN.UTF-8* > > > > * [5] LC_MONETARY=en_IN.UTF-8LC_MESSAGES=en_IN.UTF-8* > > > > * [7] LC_PAPER=CLC_NAME=C* > > > > * [9] LC_ADDRESS=CLC_TELEPHONE=C* > > > > *[11] LC_MEASUREMENT=en_IN.UTF-8 LC_IDENTIFICATION=C* > > > > * * > > > > *attached base packages:* > > > > *[1] statsgraphicsgrDevices utilsdatasets * > > > > *[6] methodsbase* > > > > * * > > > > *other attached packages:* > > > > *[1] IBrokers_0.9-10 xts_0.8-6zoo_1.7-8* > > > > * * > > > > *loaded via a namespace (and not attached):* > > > > *[1] grid_2.15.1lattice_0.20-0 tools_2.15.1* > > > > ** > > > > > > > > I have checked the "Enable Activex and Socket clients" but it hasn't > > helped. Since I'm running on an Ubuntu machine, I even tried changing the > > parameter *blocking *in the command *twsConnect() *to > > > > 1. *blocking = FALSE* > > > > 2. According to the one mentioned here > > > http://code.google.com/p/ibrokers/source/detail?r=84&path=/trunk/R/twsConnect.R > > > > but nothing has helped. > > > > > > > > Please let me know what I should do. > > > > > > > > Thanks. > > > > [[alternative HTML version deleted]] > > > > __ > > r-h...@r-project.org mailing list > > https://stat.ethz.ch/mailman/listinfo/r-help > > PLEASE do read the posting guide > http://www.R-project.org/posting-guide.html > > and provide commented, minimal, self-contained, reproducible code. > > ___ > R-SIG-Finance@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-sig-finance > -- Subscriber-posting only. If you want to post, subscribe first. > -- Also note that this is not the r-help list where general R questions > should go. > [[alternative HTML version deleted]] ___ R-SIG-Finance@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-sig-finance -- Subscriber-posting only. If you want to post, subscribe first. -- Also note that this is not the r-help list where general R questions should go.
Re: [R-SIG-Finance] [R-SIG-FINANCE] Low Priority - market component list and general coding help
Hi Martin, comments in-line. On Fri, Oct 26, 2012 at 2:01 PM, Martin Jenkins wrote: > Hi, > > I've searched around and not found anything to help on this, even though it's > not the first time it's been asked, so was wondering if anyone had any new > ideas. > > I really like the device output of the chartSeries function and so have used > it to output a bitmap of the stock chart. What I'm using it for is to get an > entire market index component list, however to get that I've had to create my > own flat file called masterlist.csv in the below code. Ideally I'd like to > have a function do the same job so I don't have to create the file manually. > This way I can quickly and easily get graphs for an entire stock market. > > Rather frustratingly Yahoo! have stopped allowing the component list for an > index to be downloaded. If you just want a list of most stocks, use TTR::stockSymbols() R> head(stockSymbols()$Symbol) Fetching AMEX symbols... Fetching NASDAQ symbols... Fetching NYSE symbols... [1] "AA-P" "AAU" "ACU" "ACY" "ADGE" "ADK" If the holdings of ETFs will suffice, you can use getHoldings from my qmao package on R-Forge (https://r-forge.r-project.org/R/?group_id=1113) R> #install.packages("qmao", repos='http://r-forge.r-project.org') R> library(qmao) R> rownames(getHoldings("SPY", auto.assign=FALSE)) If you want components of specific indexes, you might look through the code from systematic investor https://github.com/systematicinvestor/SIT/blob/master/R/data.r I haven't used any of that code, but the file I linked to above appears to get the Symbols of stocks for different indexes. > Also as you can see my coding skills are restricted by my procedural > background, so whilst the below works fine, I'm sure it can be written more > efficiently. > > One last thing, I'm using the auto.assign = FALSE so that I can use a > variable in chartseries, this leaves me with the name of my variable, in this > case 'x', on the bitmap, which isn't ideal, meaning I have to refer to the > filename for the epic. > You can simply provide a "name" argument to chartSeries() R> s <- "AAPL" R> chartSeries(getSymbols(s, src='google', auto.assign=FALSE), name=s) Just curious, why use src='google' ? I've found yahoo's data to be slightly more reliable. HTH, Garrett > Many thanks, > Martin > > library(quantmod) > > masterfile <- > "C:/Users/Admin/Documents/Programming/R/current/FTSE100/masterlist.csv" > path <- "C:/Users/Admin/Documents/Programming/R/ftse100bmps/" > epicstable <- read.table(masterfile, header=FALSE, sep=",") > > i <- 1 > while(is.na(epicstable$V1[i]) == "FALSE") > { > epic_char <- as.character(epicstable$V1[i]) > x <- try(getSymbols(epic_char, auto.assign=FALSE)) > > if (length(x)==1) > { > x <- try(getSymbols(epic_char, src = "google", auto.assign=FALSE)) > } > > if (length(x) > 1) > { > outputfile <- paste(path, epicstable$V1[i], '.bmp') > chartSeries(x,subset='2011-01::2012',TA="addVo();addMACD()") > bmp(file=outputfile, bg = "transparent", width = 1024, height = 768) > dev.off() > } > i = i + 1 > } > [[alternative HTML version deleted]] > > > ___ > R-SIG-Finance@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-sig-finance > -- Subscriber-posting only. If you want to post, subscribe first. > -- Also note that this is not the r-help list where general R questions > should go. ___ R-SIG-Finance@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-sig-finance -- Subscriber-posting only. If you want to post, subscribe first. -- Also note that this is not the r-help list where general R questions should go.
Re: [R-SIG-Finance] Daily dividend yield
Hi Frank, > 1) I have downloaded both the dividends and the OHLCVAdjC data successfully. > When I merge the data with fill=0.0 and export the merged data with > write.csv, the date is replaced with the index from 1 to 52, first few lines: I suggest using write.zoo(). But, you can also consult ?write.table and the R Data Import/Export manual (http://cran.r-project.org/doc/manuals/R-data.html) > 2) Divs contains the dividend date and the 1 dividend 0.20. Stock contains > theOHLVAdjC data for Microsoft. I can print the dates using Divs[1,0] and > Stock[1,0] but a comparison of those dates always results in an error: What looks like Dates to you is actually a zero-width xts object. This is the line that's giving you trouble if ((Stock[i,0]) == (Divs[j,0])) Current_Div <- Divs[j,1] If you are trying to compare indexes, maybe something along these lines would work better. index(Stock[i]) == index(Divs[j]) # > if (Stock[i, 0] == Divs[1, 0]) print("equal") Error in if (Stock[i, 0] == Divs[1, 0]) print("equal") : argument is of length zero > Divs[1, 0] 2012-08-14 > length(Divs[1, 0]) [1] 0 > index(Divs[1]) [1] "2012-08-14" > if (index(Stock[i]) == index(Divs[1])) print("equal") # no error # That said, I'm fairly confident that you should not use a (double) for loop for this. I can't quite tell from your code what you're trying to do, but if you provide your desired output, I'm sure we can come up with a vectorized solution. For example, if you want to multiply the last quarterly dividend amount by 4 and use that value every day until the next dividend, you can do the following: # Setup based on original question Divs_Per_Year<-4 startDate=as.Date("2012-05-01") endDate=as.Date("2012-10-13") Divs<-getDividends(ticker, from = startDate, to = endDate) Stock <- getSymbols(ticker, from=startDate, to=endDate, src='yahoo', auto.assign=FALSE) # End setup na.locf(merge(Stock, Divs * Divs_Per_Year, retside=c(FALSE, TRUE))) Or, if you want to do basically the same thing, but divide the current estimate for the annual dividend amount by the most recent price in order to calculate the current yield, you can do this: with(na.locf(merge(Stock, AnnDiv=Divs * Divs_Per_Year)), AnnDiv / MSFT.Adjusted) HTH, Garrett On Sat, Oct 13, 2012 at 10:29 PM, FJ M wrote: > > I'm trying to calculate the current yield for MSFT using the most recent > dividend and daily closing price of MSFT. I've tried a couple of approaches > that don't work, any suggestions would be appreciated. ___ R-SIG-Finance@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-sig-finance -- Subscriber-posting only. If you want to post, subscribe first. -- Also note that this is not the r-help list where general R questions should go.
Re: [R-SIG-Finance] Slow data EOD
And Jeff's already provided a quoteFormat (which I had forgotten about) so that you don't have to rearrange columns. > getQuote("SPY", what=yahooQuote.EOD) Trade Time Open HighLow CloseVolume SPY 2012-10-12 04:00:00 143.46 143.95 142.58 142.89 124181904 On Tue, Oct 9, 2012 at 12:04 PM, Ralph Vince wrote: > Ah, okthen I can create a function to perhaps append it onto the > file I am downloading entirely end of day or something like that. > > On Tue, Oct 9, 2012 at 1:02 PM, G See wrote: >> On Tue, Oct 9, 2012 at 11:58 AM, Ralph Vince wrote: >>> Thanks Garrett, Im really just looking for timely end-of-day data on >>> this though. Ralph >> >> For example, getQuote("SPY"), will return end of day data if you call >> it late in the afternoon ;-) ___ R-SIG-Finance@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-sig-finance -- Subscriber-posting only. If you want to post, subscribe first. -- Also note that this is not the r-help list where general R questions should go.
Re: [R-SIG-Finance] "Optimx" help
Please don't crosspost. Ask "other guy" for clarification, not us. On Wed, Oct 10, 2012 at 10:37 AM, nserdar wrote: > I do not understand what other guy mentioned about my problem. So I asked in > this part. > > Please explain other guy opinion about my problem. > > Regards, > Serdar > > > > -- > View this message in context: > http://r.789695.n4.nabble.com/Optimx-help-tp4645666p4645723.html > Sent from the Rmetrics mailing list archive at Nabble.com. > > ___ > R-SIG-Finance@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-sig-finance > -- Subscriber-posting only. If you want to post, subscribe first. > -- Also note that this is not the r-help list where general R questions > should go. ___ R-SIG-Finance@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-sig-finance -- Subscriber-posting only. If you want to post, subscribe first. -- Also note that this is not the r-help list where general R questions should go.
Re: [R-SIG-Finance] Slow data EOD
On Tue, Oct 9, 2012 at 11:58 AM, Ralph Vince wrote: > Thanks Garrett, Im really just looking for timely end-of-day data on > this though. Ralph For example, getQuote("SPY"), will return end of day data if you call it late in the afternoon ;-) ___ R-SIG-Finance@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-sig-finance -- Subscriber-posting only. If you want to post, subscribe first. -- Also note that this is not the r-help list where general R questions should go.
Re: [R-SIG-Finance] Slow data EOD
Hi Ralph, You can get real time intraday data from yahoo or google: http://www.quantshare.com/sa-426-6-ways-to-download-free-intraday-and-tick-data-for-the-us-stock-market Or you can get delayed data with quantmod::getQuote. Maybe that will work better for you. I'm not sure about your particular issue, but one of the issues with yahoo's daily data is that sometimes it has duplicate timestamps (and different volume) for the most recent observation. HTH, Garrett On Tue, Oct 9, 2012 at 11:26 AM, Ralph Vince wrote: > I'm downloading certain equity data from yahoo on an eod basis, using > the code, below. It works wonderfully, formatting the data and dates > precisely as I am looking for EXCEPT often the data is late. Often, > the latest market day's data is not up until 10, 11 pm that night. > > Is there something I am doing wrong here? Surely, yahoo must have the > data by the close. is the way I am invoking calling the file, below, > causing this? Or is there a way to obtain it from google earlier? I;d > be very grateful for any help along these lines. Ralph Vince > > require(quantmod) > library(plan) > brsym <- c( > "AAPL", > "ABT", > ... > "WMT", > "XOM" > ); > for (i in 1:length(brsym)) { > tryCatch({ > j <- paste("http://table.finance.yahoo.com/table.csv?s=",brsym[[i]],sep="";); > j <- paste(j,"&g=d&ignore=.csv",sep=""); > print(j); > X <- read.csv(j, header=TRUE); > # Convert the "Date" column from a factor class to a Date class > X$Date <- as.Date(X$Date) > # Sort the X object by the Date column -- order(-X$Date) will sort it > in the other direction > X <- X[order(X$Date),] > # Format the date column as you want > X$Date <- format(as.Date(X$Date),"%Y%m%d"); > X <- X[,1:6] > kk <- trim.whitespace(brsym[[i]]); > k <- paste("/home/oracle/broadbaseddata/", kk, sep=""); > k <- trim.whitespace(k); > k <- paste(k,".csv", sep=""); > write.table(X, k, append = FALSE, quote = FALSE, sep = ",", > eol = "\n", na = "NA", dec = ".", row.names = FALSE, > col.names = FALSE, qmethod = c("escape", "double")); > print(k); > ko <- paste(X$Date[1], "-",X$Date[length(X$Date)]); > print(ko); > }, interrupt = function(ex) { > cat("An interrupt was detected.\n"); > print(ex); > }, error = function(ex) { > cat("An error was detected.\n"); > print(ex); > }, finally = { > cat("done\n"); > }) > } > > ___ > R-SIG-Finance@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-sig-finance > -- Subscriber-posting only. If you want to post, subscribe first. > -- Also note that this is not the r-help list where general R questions > should go. ___ R-SIG-Finance@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-sig-finance -- Subscriber-posting only. If you want to post, subscribe first. -- Also note that this is not the r-help list where general R questions should go.
Re: [R-SIG-Finance] PerformanceAnalytics seems to break rollapply
There should be a GIANT WARNING when loading PerformanceAnalytics to let users know that their code will no longer be reproducible. The problem comes from the zzz.R that does these nasty things: mean.xts <- function(x,...) { if(is.vector(x) ||is.null(ncol(x)) || ncol(x)==1){ x<-as.numeric(x) mean(x,...) } else apply(x,2,mean.xts,...) } mean.matrix <- function(x,...) {apply(x,2,mean,...)} sd.xts <- function(x,na.rm=FALSE) { if(is.vector(x) || is.null(ncol(x)) || ncol(x)==1){ x<-as.numeric(x) sd(x,na.rm=na.rm) } else apply(x,2,sd,na.rm=na.rm) } sd.matrix <- function(x,na.rm=FALSE) {apply(x,2,sd,na.rm=na.rm)} rollapply.xts <- xts:::rollapply.xts HTH, Garrett On Fri, Oct 5, 2012 at 2:04 PM, Bos, Roger wrote: > Unless I am making a user error, it seems that rollapply stops working with > some functions after the PerformanceAnalytics packages has been loaded. I > provide reproducible code below: > > test <- xts(1:10, order.by=Sys.time()+(1:10)) > "w" <- function(x) { > z <- scale(x) >attributes(z) <- NULL >z > } > rollapply(data=test, width=3, FUN=mean) > rollapply(data=test, width=3, FUN=scale) > rollapply(data=test, width=3, FUN=w) > require("PerformanceAnalytics") > rollapply(data=test, width=3, FUN=mean) > rollapply(data=test, width=3, FUN=scale) > rollapply(data=test, width=3, FUN=w) > > The first three calls to rollapply work fine. Then once the > PerformanceAnalytics packages had been loaded "mean" still works but "scale" > does not. I suspect it is because of the attributes which scale creates, but > I tried creating a function (called "w") which removes the attributes, but > rollapply still does not work. > > Here is the error I get: > >> rollapply(data=test, width=3, FUN=w) > Error in xts(xx, tt, if (by == 1) attr(data, "frequency")) : > NROW(x) must match length(order.by) >> > > > Thanks for any help or advice you can provide! > > Roger J. Bos, CFA > Rothschild Asset Management, Inc. > Tel +1 (212) 403-5471 > Email roger@rothschild.com > 1251 Avenue of the Americas, NY, NY 10020 > > *** > This message is for the named person's use only. It may\...{{dropped:11}} > > ___ > R-SIG-Finance@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-sig-finance > -- Subscriber-posting only. If you want to post, subscribe first. > -- Also note that this is not the r-help list where general R questions > should go. ___ R-SIG-Finance@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-sig-finance -- Subscriber-posting only. If you want to post, subscribe first. -- Also note that this is not the r-help list where general R questions should go.
Re: [R-SIG-Finance] Problem with updatePortf
getPrice looks for a price column and it only works if the xts object has colnames. > getPrice(USDCHF) Error in getPrice(USDCHF) : subscript out of bounds, no price was discernible from the data You need to add colnames. > colnames(USDCHF) <- c("Bid", "Ask", "Last.Price") > getPrice(USDCHF) Last.Price 2005-09-01 1.2343 2005-09-02 1.2280 2005-09-05 1.2335 2005-09-06 1.2365 2005-09-07 1.2426 2005-09-08 1.2449 2005-09-09 1.2442 2005-09-12 1.2592 2005-09-13 1.2619 2005-09-14 1.2585 2005-09-15 1.2671 2005-09-16 1.2687 2005-09-19 1.2772 2005-09-20 1.2809 2005-09-21 1.2718 2005-09-22 1.2795 2005-09-23 1.2916 2005-09-26 1.2896 2005-09-27 1.2959 2005-09-28 1.2940 Although getPrice is not documented, you can look at its code to see what it does. If you do not provide a value for the "prefer" argument, it looks for a column name that contains the word "price". If it cannot find that, it looks for "trade". Finally, it looks for "close". If your colnames don't contain any of those words, or if you want to use a different column, you can specify that with the "prefer" argument > getPrice(USDCHF, prefer="Bid") Bid 2005-09-01 1.2558 2005-09-02 1.2368 2005-09-05 1.2344 2005-09-06 1.2404 2005-09-07 1.2444 2005-09-08 1.2470 2005-09-09 1.2470 2005-09-12 1.2597 2005-09-13 1.2640 2005-09-14 1.2613 2005-09-15 1.2696 2005-09-16 1.2729 2005-09-19 1.2815 2005-09-20 1.2818 2005-09-21 1.2825 2005-09-22 1.2809 2005-09-23 1.2918 2005-09-26 1.2965 2005-09-27 1.2998 2005-09-28 1.2984 Garrett On Thu, Sep 20, 2012 at 9:30 PM, Worik Stanton wrote: > On 21/09/12 14:10, Worik Stanton wrote: >> [snip] >> I am working on a small example that exhibits the problem but in the >> mean time is there a way I can debug .updatePosPL? > > So here is an example without transactions. > > I am a novice with blotter so tis example could probably be smaller. I > have tried to distill what are the most important points (hence no > transactions). > > When I run this I get... > >> go() > 2005-09-01 > FOO > Error in getPrice(get(Symbol, pos = env), symbol = symbol, prefer = > prefer) : > subscript out of bounds, no price was discernible from the data >> ___ R-SIG-Finance@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-sig-finance -- Subscriber-posting only. If you want to post, subscribe first. -- Also note that this is not the r-help list where general R questions should go.
Re: [R-SIG-Finance] Problem with updatePortf
If by "cannot debug that function" you mean you can't find the source code, you can view the code with blotter:::.updatePosPL or getAnywhere(".updatePosPL") Or, your can checkout the code with svn to see a commented copy. svn checkout svn://svn.r-forge.r-project.org/svnroot/blotter/ and browse to the file pkg/blotter/R/updatePosPL.R Or, you can view it online at https://r-forge.r-project.org/scm/viewvc.php/*checkout*/pkg/blotter/R/updatePosPL.R?root=blotter HTH, Garrett On Thu, Sep 20, 2012 at 9:10 PM, Worik Stanton wrote: > Friends > > I am running into trouble with updatePortf. > > Stepping through it the problem is with the call to .updatePosPL, but I > cannot debug that function. > > I am working on a small example that exhibits the problem but in the > mean time is there a way I can debug .updatePosPL? > > cheers > Worik > > -- > it does not matter I think that I shall never see > how much I dig and digA billboard lovely as a tree > this hole just Indeed, unless the billboards fall > keeps getting deeper I'll never see a tree at all > > ___ > R-SIG-Finance@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-sig-finance > -- Subscriber-posting only. If you want to post, subscribe first. > -- Also note that this is not the r-help list where general R questions > should go. ___ R-SIG-Finance@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-sig-finance -- Subscriber-posting only. If you want to post, subscribe first. -- Also note that this is not the r-help list where general R questions should go.
Re: [R-SIG-Finance] Removing instruments...
Hi Worik, Either of these will do it rm_exchange_rates("AUDCAD") rm_instruments("AUDCAD", keep.currencies=FALSE) The reason rm_instruments has a keep.currencies argument is because I was frustrated that currencies have to be defined before anything else. So, I made it a little more work to delete them. exchange_rate instruments get treated like currencies because they inherit the 'currency' class (although, personally, I don't think they should). You could also backup your .instrument environment before experimenting, then reload it. You could either back it up by saving it via saveInstruments(), or, simply convert it to a list and assign it to something. tmppdir <- tempdir() saveInstruments("test", dir=tmpdir) bak <- as.list(FinancialInstrument:::.instrument, all.names=TRUE) Now, you can revert to a backed up version like this reloadInstruments('test', dir=tmpdir) or reloadInstruments(bak) reloadInstruments(bak) is equivalent to rm_instruments(keep=FALSE) loadInstruments(bak) HTH, Garrett On Mon, Sep 17, 2012 at 11:09 PM, Worik Stanton wrote: > I have been playing with exchange_rate(..) > > Having called, for example, > > currency("CAD") > currency("AUD") > exchange_rate("AUDCAD", currency="CAD", counter_currency="AUD") > > All good so far. > > How do I delete the exchange_rate AUDCAD when I am done with it? > > cheers > Worik > > -- > it does not matter I think that I shall never see > how much I dig and digA billboard lovely as a tree > this hole just Indeed, unless the billboards fall > keeps getting deeper I'll never see a tree at all > > ___ > R-SIG-Finance@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-sig-finance > -- Subscriber-posting only. If you want to post, subscribe first. > -- Also note that this is not the r-help list where general R questions > should go. ___ R-SIG-Finance@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-sig-finance -- Subscriber-posting only. If you want to post, subscribe first. -- Also note that this is not the r-help list where general R questions should go.
Re: [R-SIG-Finance] Trouble with getSymbols.csv
This function should really have more formal arguments -- especially the format argument. As it is, the `format` will be set to "". You should be able to pass `format` through the dots, but there's a syntax bug preventing that from working (`list(...)[["format"]] <- NULL`). As it is, the only way to load your data using getSymbols.csv is to set the `format` argument in the Symbol Lookup table. (I saved the text from your e-mail in a file at "~/tmp/worik.txt") setSymbolLookup(worik=list(src='csv', format='%Y-%m-%d')) getSymbols('worik', dir='~/tmp', auto.assign=FALSE, extension='txt') WORIK.Open WORIK.High WORIK.Low WORIK.Close WORIK.Volume 2011-12-28 1.5968 1.59871.5762 1.58270 2011-12-29 1.5831 1.58461.5695 1.57240 2011-12-30 1.5726 1.58771.5704 1.58610 2011-12-31 1.5850 1.58611.5850 1.58610 2012-01-01 1.5850 1.58611.5820 1.58610 2012-01-02 1.5871 1.58751.5768 1.58020 2012-01-03 1.5800 1.58371.5726 1.58180 2012-01-04 1.5819 1.58651.5796 1.58130 2012-01-05 1.5812 1.58541.5730 1.57950 2012-01-06 1.5796 1.58711.5745 1.58590 2012-01-07 1.5854 1.58541.5782 1.57820 2012-01-08 1.5808 1.58661.5808 1.58660 2012-01-09 1.5867 1.59101.5807 1.58150 WORIK.Adjusted 2011-12-281.58745 2011-12-291.57705 2011-12-301.57905 2011-12-311.58555 2012-01-011.58405 2012-01-021.58215 2012-01-031.57815 2012-01-041.58305 2012-01-051.57920 2012-01-061.58080 2012-01-071.58180 2012-01-081.58370 2012-01-091.58585 HTH, Garrett On Mon, Sep 17, 2012 at 4:12 PM, Worik Stanton wrote: > Friends > > I have a file of data: > > "Date","Open","High","Low","Close","Volume","Adjusted" > "2011-12-28",1.5968,1.5987,1.5762,1.5827,0,1.58745 > "2011-12-29",1.5831,1.5846,1.5695,1.5724,0,1.57705 > "2011-12-30",1.5726,1.5877,1.5704,1.5861,0,1.57905 > "2011-12-31",1.585,1.5861,1.585,1.5861,0,1.58555 > "2012-01-01",1.585,1.5861,1.582,1.5861,0,1.58405 > "2012-01-02",1.5871,1.5875,1.5768,1.5802,0,1.58215 > "2012-01-03",1.58,1.5837,1.5726,1.5818,0,1.57815 > "2012-01-04",1.5819,1.5865,1.5796,1.5813,0,1.58305 > "2012-01-05",1.5812,1.5854,1.573,1.5795,0,1.5792 > "2012-01-06",1.5796,1.5871,1.5745,1.5859,0,1.5808 > "2012-01-07",1.5854,1.5854,1.5782,1.5782,0,1.5818 > "2012-01-08",1.5808,1.5866,1.5808,1.5866,0,1.5837 > "2012-01-09",1.5867,1.591,1.5807,1.5815,0,1.58585 > > When I use getSymbols(.., src="csv") > > The dates are incorrect. The first date is "2012-09-18" > > It seems that in getSymbols.csv uses: > > as.Date(fr[, 1], format = format, ..., origin = "1970-01-01") > > Looking more closely... > >> as.Date("2011-12-28", origin="1970-01-01", format="") > [1] "2012-09-18" > > That is what I see. > > But either of... >> as.Date("2011-12-28", origin="1970-01-01") > [1] "2011-12-28" >> as.Date("2011-12-28") > [1] "2011-12-28" >> > > give me what I expect. > > What am I doing wrong? > > cheers > Worik > > -- > it does not matter I think that I shall never see > how much I dig and digA billboard lovely as a tree > this hole just Indeed, unless the billboards fall > keeps getting deeper I'll never see a tree at all > > ___ > R-SIG-Finance@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-sig-finance > -- Subscriber-posting only. If you want to post, subscribe first. > -- Also note that this is not the r-help list where general R questions > should go. ___ R-SIG-Finance@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-sig-finance -- Subscriber-posting only. If you want to post, subscribe first. -- Also note that this is not the r-help list where general R questions should go.
Re: [R-SIG-Finance] Aggregating tick-by-tick data to seconds
You can use `period.apply` (along with `endpoints()`) to apply any function you like over non-overlapping time periods. In this case, you want to sum columns 2 and 3 separately, so use `period.apply()` with `FUN=colSums` on just the 2nd and 3rd columns. period.apply(test[, 2:3], endpoints(test, 'secs'), FUN=colSums) Then you can merge that with the results of `to.period` > cbind(to.period(test[, 1], name="test"), period.apply(test[, -1], endpoints(test, 'secs'), FUN=colSums)) test.Open test.High test.Low test.Close up down 2012-09-12 16:30:00144.39144.39 144.38 144.38 5903 100 You could also use `period.sum()` on each column separately. HTH, Garrett On Sat, Sep 15, 2012 at 10:57 AM, Costas Vorlow wrote: > Hello, > > I have the following data (xts) (last two columns refer to up and down > volumes). > >> head(test,20) > [,1] [,2] [,3] > 2012-09-12 16:30:00 144.39 3000 > 2012-09-12 16:30:00 144.39 5000 > 2012-09-12 16:30:00 144.39 3000 > 2012-09-12 16:30:00 144.39 4000 > 2012-09-12 16:30:00 144.39 3000 > 2012-09-12 16:30:00 144.39 3000 > 2012-09-12 16:30:00 144.39 1000 > 2012-09-12 16:30:00 144.39 9000 > 2012-09-12 16:30:00 144.39 2000 > 2012-09-12 16:30:00 144.39 1030 > 2012-09-12 16:30:00 144.39 1970 > 2012-09-12 16:30:00 144.39 2000 > 2012-09-12 16:30:00 144.39 5000 > 2012-09-12 16:30:00 144.39 4000 > 2012-09-12 16:30:00 144.39 1000 > 2012-09-12 16:30:00 144.39 5000 > 2012-09-12 16:30:00 144.39 3000 > 2012-09-12 16:30:00 144.39 2000 > 2012-09-12 16:30:00 144.39 1030 > 2012-09-12 16:30:00 144.380 100 > > > I can use the to.period to aggregate the above data to seconds > > test.Open test.High test.Low test.Close > 2012-09-12 16:30:00144.39144.47 144.37 144.38 > 2012-09-12 16:31:00144.39144.40 144.33 144.37 > 2012-09-12 16:32:00144.37144.45 144.37 144.45 > 2012-09-12 16:33:00144.45144.47 144.42 144.47 > > > but I am not sure how to do this for the volume columns. I would need to > retrieve the volume sums per second. > > Is this functionality built into the xts package? Is there any other > function that could be used to do something like that? > > Thanks & best regards, > Costas > ___ > > [[alternative HTML version deleted]] > > ___ > R-SIG-Finance@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-sig-finance > -- Subscriber-posting only. If you want to post, subscribe first. > -- Also note that this is not the r-help list where general R questions > should go. ___ R-SIG-Finance@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-sig-finance -- Subscriber-posting only. If you want to post, subscribe first. -- Also note that this is not the r-help list where general R questions should go.
Re: [R-SIG-Finance] I am using the quantmod package (http://www.quantmod.com) and, using getSymbols,
I assume you did this: library(quantmod) getSymbols("BBD-B.TO") If so, then you should have data stored in the .GlobalEnv in an object named "BBD-B.TO" You could access it like this get("BBD-B.TO") And you could rename the data with a syntactically valid name like this: assign("BBD", get("BBD-B.TO"), pos=.GlobalEnv) #assign(make.names("BBD-B.TO"), get("BBD-B.TO"), pos=.GlobalEnv) rm("BBD-B.TO") You have at least 2 other options. You can use auto.assign=FALSE in the getSymbols call and assign the results yourself like this: BBD <- getSymbols("BBD-B.TO", src='yahoo', auto.assign=FALSE) Or, you can use setSymbolLookup to associate the name yahoo uses with a valid name in R setSymbolLookup("BBD", list(src='yahoo', name='BBD-B.TO')) getSymbols("BBD") HTH, Garrett On Sun, Sep 9, 2012 at 8:29 PM, Jean-Victor Côté wrote: > > ...I could not download from Yahoo Finance the quotes for "BBD-B.TO", a > common stock traded on the Toronto Stock Exchange. I guess that it is > because of the "-" and the ".". > > Jean-Victor Côté > > [[alternative HTML version deleted]] > > > ___ > R-SIG-Finance@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-sig-finance > -- Subscriber-posting only. If you want to post, subscribe first. > -- Also note that this is not the r-help list where general R questions > should go. ___ R-SIG-Finance@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-sig-finance -- Subscriber-posting only. If you want to post, subscribe first. -- Also note that this is not the r-help list where general R questions should go.
Re: [R-SIG-Finance] Equities Data
You should be able to install it with this command install.packages("qmao", repos="http://R-Forge.R-project.org";) If for some reason that does not work, see this link: http://stackoverflow.com/questions/11105131/cannot-install-r-forge-package-using-install-packages Garrett On Thu, Sep 6, 2012 at 6:31 PM, Ralph Vince wrote: > Garrett, this is really great. So I only need to get the latest qmao > to do this? It's in CRAN? Ralph VInce > > On Thu, Sep 6, 2012 at 2:49 PM, G See wrote: >> I guess since you really only care about the future, this would be >> more appropriate >> >> sc <- getSplitsCalendar(from='2012-09-05', to='2012-12-31') >> sc[sc$Symbol =="LKQ", ] >> PayableEx.Date Company Symbol Optionable. Ratio Announced >> 4 2012-09-18 2012-09-19 LKQLKQ Y 2-1 2012-08-17 >> >> >> On Thu, Sep 6, 2012 at 1:44 PM, G See wrote: >>> That's not really how the website is setup. So, I don't think that's >>> how the function should be setup by default. But, you can easily >>> filter the results by Symbol. >>> >>> Here is the wrapper I mentioned. >>> >>> getSplitsCalendar <- function(from, to) { >>> qmao:::getCalendarByMonth(".getSplitsCalendar", from=from, to=to) >>> } >>> >>> This allows you to get and merge several months of splits calendars. >>> >>> sc <- getSplitsCalendar(from='2012-01-01', to='2012-08-31') >>> >>> Now you have the splits calendar from January to August. You can >>> filter that by the symbol you care about. >>> >>> sc[sc$Symbol == "ALK", ] >>> PayableEx.DateCompany Symbol Optionable. Ratio Announced >>> 52 2012-03-16 2012-03-19 Alaska AirALK Y 2-1 2012-02-16 >>> >>> Good enough? >>> >>> Garrett >>> >>> On Thu, Sep 6, 2012 at 1:34 PM, Ralph Vince wrote: >>>> Garrett, >>>> >>>> This is great. Do you think it would be possible to pass in a given >>>> ticker to get that informatoin, rather than getting the whole gulp? >>>> Ralph Vince >>>> ___ R-SIG-Finance@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-sig-finance -- Subscriber-posting only. If you want to post, subscribe first. -- Also note that this is not the r-help list where general R questions should go.
Re: [R-SIG-Finance] Equities Data
That's not really how the website is setup. So, I don't think that's how the function should be setup by default. But, you can easily filter the results by Symbol. Here is the wrapper I mentioned. getSplitsCalendar <- function(from, to) { qmao:::getCalendarByMonth(".getSplitsCalendar", from=from, to=to) } This allows you to get and merge several months of splits calendars. sc <- getSplitsCalendar(from='2012-01-01', to='2012-08-31') Now you have the splits calendar from January to August. You can filter that by the symbol you care about. sc[sc$Symbol == "ALK", ] PayableEx.DateCompany Symbol Optionable. Ratio Announced 52 2012-03-16 2012-03-19 Alaska AirALK Y 2-1 2012-02-16 Good enough? Garrett On Thu, Sep 6, 2012 at 1:34 PM, Ralph Vince wrote: > Garrett, > > This is great. Do you think it would be possible to pass in a given > ticker to get that informatoin, rather than getting the whole gulp? > Ralph Vince > ___ R-SIG-Finance@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-sig-finance -- Subscriber-posting only. If you want to post, subscribe first. -- Also note that this is not the r-help list where general R questions should go.
Re: [R-SIG-Finance] Equities Data
I guess since you really only care about the future, this would be more appropriate sc <- getSplitsCalendar(from='2012-09-05', to='2012-12-31') sc[sc$Symbol =="LKQ", ] PayableEx.Date Company Symbol Optionable. Ratio Announced 4 2012-09-18 2012-09-19 LKQLKQ Y 2-1 2012-08-17 On Thu, Sep 6, 2012 at 1:44 PM, G See wrote: > That's not really how the website is setup. So, I don't think that's > how the function should be setup by default. But, you can easily > filter the results by Symbol. > > Here is the wrapper I mentioned. > > getSplitsCalendar <- function(from, to) { > qmao:::getCalendarByMonth(".getSplitsCalendar", from=from, to=to) > } > > This allows you to get and merge several months of splits calendars. > > sc <- getSplitsCalendar(from='2012-01-01', to='2012-08-31') > > Now you have the splits calendar from January to August. You can > filter that by the symbol you care about. > > sc[sc$Symbol == "ALK", ] > PayableEx.DateCompany Symbol Optionable. Ratio Announced > 52 2012-03-16 2012-03-19 Alaska AirALK Y 2-1 2012-02-16 > > Good enough? > > Garrett > > On Thu, Sep 6, 2012 at 1:34 PM, Ralph Vince wrote: >> Garrett, >> >> This is great. Do you think it would be possible to pass in a given >> ticker to get that informatoin, rather than getting the whole gulp? >> Ralph Vince >> ___ R-SIG-Finance@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-sig-finance -- Subscriber-posting only. If you want to post, subscribe first. -- Also note that this is not the r-help list where general R questions should go.
Re: [R-SIG-Finance] Equities Data
Ralph, This will parse that yahoo link you provided. I'll add it (along with a wrapper) to the qmao package tonight. .getSplitsCalendar <- function(YM=format(Sys.Date(), "%Y%m")) { stopifnot(length(YM) == 1) if (is.timeBased(YM) || nchar(YM) == 10) { YM <- format(as.Date(YM), "%Y%m") } else if (nchar(YM) == 5) { YM <- paste0(substr(YM, 1, 4), 0, substr(YM, 5, 5)) } else if (nchar(YM) == 7 && length(grep("-", YM) == 1)) { YM <- sub("-", "", YM) } if (nchar(YM) != 6) stop("'YM' should be 6 digits or a Date") Y <- substr(YM, 3, 4) M <- as.numeric(substr(YM, 5, 6)) # there is a different URL for the current month than for other months URL <- if (identical(format(Sys.Date(), "%Y%m"), YM)) { "http://biz.yahoo.com/c/s.html"; } else paste0("http://biz.yahoo.com/c/";, Y, "/s", M, ".html") rt <- try(readHTMLTable(URL, stringsAsFactors=FALSE), silent=TRUE) if (inherits(rt, 'try-error')) return(NULL) dat <- rt[[which.max(sapply(rt, nrow))]] colnames(dat) <- make.names(dat[1, ]) dat <- dat[-c(1,2), -NCOL(dat)] #read.zoo(dat, index.column=1:2 dat[[1]] <- as.Date(paste(substr(YM, 1, 4), dat[[1]]), "%Y %b %d") dat[[2]] <- as.Date(paste(substr(YM, 1, 4), dat[[2]]), "%Y %b %d") dat[, NCOL(dat)] <- as.Date(paste(substr(YM, 1, 4), dat[, NCOL(dat)]), "%Y %b %d") dat } R> .getSplitsCalendar() PayableEx.Date Company Symbol Optionable. Ratio Announced 3 2012-09-07 2012-09-10 Old Dominion ODFL Y 3-2 2012-08-13 4 2012-09-18 2012-09-19 LKQLKQ Y 2-1 2012-08-17 5 2012-09-21 2012-09-24 Medivation MDVN Y 2-1 2012-08-28 R> .getSplitsCalendar('201208') PayableEx.DateCompany Symbol Optionable. Ratio Announced 3 2012-08-10 2012-08-13 Brown-Forman BF.B Y 3-2 2012-06-14 42012-08-13 Coca-Cola KO Y 2-1 2012-04-25 5 2012-08-14 2012-08-15 Oi SA OIBR Y 3-1 2012-08-10 6 2012-08-21 2012-08-22 Schweitzer-MauduitSWM Y 2-1 2012-08-01 getDividendsCalendar gets it's data from earnings.com which is Reuters data. So, it should be good (except that it's way too much data if you only want to know the dividend date of a particular ticker) Regards, Garrett On Thu, Sep 6, 2012 at 12:56 PM, Ralph Vince wrote: > THis looks pretty good, and could be parsed -- I just wish they had it > for cash dividends as well; > http://biz.yahoo.com/c/s.html > Ralph Vince > > On Thu, Sep 6, 2012 at 1:44 PM, Ralph Vince wrote: >> Hi Jeff, >> >> Yes, but they only offer dividends not splits. I;ve been working off >> of sites like this and looking to automate it somehow, hopefully >> through R. >> >> >> On Thu, Sep 6, 2012 at 12:15 PM, Jeff Ryan wrote: >>> You might be able to use this: >>> >>> http://www.dividend.com/ex-dividend-dates.php >>> >>> Jeff >>> >>> On Thu, Sep 6, 2012 at 11:13 AM, Ralph Vince wrote: >>>> Yes, I'm willing to pay for it, but I would like to get it >>>> automatically into a format I can parse and use, not even sure where >>>> that exists at the moment. (Doesn't Yahoo Finance get their data from >>>> CSI?) Ralph Vince >>>> >>>> On Thu, Sep 6, 2012 at 12:04 PM, G See wrote: >>>>> On Thu, Sep 6, 2012 at 10:54 AM, Brian G. Peterson >>>>> wrote: >>>>>> The only way I know of to get out of maintaining it by hand is to pay for >>>>>> data. >>>>>> >>>>>> On the GUI side, Bloomberg, Factset, and Reuters have all been mentioned >>>>>> already I think. Rbbg of course talks to Bloomberg. >>>>>> >>>>>> On the other vendor side, I think Interactive Brokers has this data, and >>>>>> it >>>>>> may be available via the IBrokers package if it is available via the IB >>>>>> API. >>>>>> Additional vendors, such as CSIdata, tickdata.com, Reuters, CRSP, >>>>>> Telekurs, >>>>>> etc all sell this data, at varying prices and quality. >>>>> >>>>> Interactive Brokers does provide an "Upcoming Dividend Schedule" for >>>>> stocks, but it is a rough estimate that is often wrong. Also, I don't >>>>> think you can get it from their API (although if someone knows how, >>>>> please speak up). I
Re: [R-SIG-Finance] Equities Data
Oh. Sorry. getDividendsCalendar gets it's data from earnings.com. I was confused because getMergersCalendar, getEarningsCalendar and .getEconomicCalendarYahoo use analogous yahoo sites. Oops, Garrett On Thu, Sep 6, 2012 at 12:57 PM, G See wrote: > On Thu, Sep 6, 2012 at 12:56 PM, Ralph Vince wrote: >> THis looks pretty good, and could be parsed -- I just wish they had it >> for cash dividends as well; >> http://biz.yahoo.com/c/s.html >> Ralph Vince > > They do. Please look at > library(qmao) > ?getDividendsCalendar > > I think I've mentioned this before... > Garrett ___ R-SIG-Finance@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-sig-finance -- Subscriber-posting only. If you want to post, subscribe first. -- Also note that this is not the r-help list where general R questions should go.
Re: [R-SIG-Finance] Equities Data
On Thu, Sep 6, 2012 at 12:56 PM, Ralph Vince wrote: > THis looks pretty good, and could be parsed -- I just wish they had it > for cash dividends as well; > http://biz.yahoo.com/c/s.html > Ralph Vince They do. Please look at library(qmao) ?getDividendsCalendar I think I've mentioned this before... Garrett ___ R-SIG-Finance@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-sig-finance -- Subscriber-posting only. If you want to post, subscribe first. -- Also note that this is not the r-help list where general R questions should go.
Re: [R-SIG-Finance] Equities Data
On Thu, Sep 6, 2012 at 10:54 AM, Brian G. Peterson wrote: > The only way I know of to get out of maintaining it by hand is to pay for > data. > > On the GUI side, Bloomberg, Factset, and Reuters have all been mentioned > already I think. Rbbg of course talks to Bloomberg. > > On the other vendor side, I think Interactive Brokers has this data, and it > may be available via the IBrokers package if it is available via the IB API. > Additional vendors, such as CSIdata, tickdata.com, Reuters, CRSP, Telekurs, > etc all sell this data, at varying prices and quality. Interactive Brokers does provide an "Upcoming Dividend Schedule" for stocks, but it is a rough estimate that is often wrong. Also, I don't think you can get it from their API (although if someone knows how, please speak up). I think you have to go into the GUI, right-click a stock and select Dividend Schedule. -Garrett ___ R-SIG-Finance@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-sig-finance -- Subscriber-posting only. If you want to post, subscribe first. -- Also note that this is not the r-help list where general R questions should go.
Re: [R-SIG-Finance] Equities Data
That data is expensive, but your prime broker will probably provide it for free. Otherwise, qmao::getDividendsCalendar can do it, but it's inefficient. You'd have to get the dividends calendar for future dates, and look for your symbols. Keep in mind that the local symbol will be used even if the stock also trades in the U.S. (i.e. BMW.DE instead of BMW) Good luck, Garrett On Thu, Sep 6, 2012 at 10:45 AM, Ralph Vince wrote: > I don't think this is going to do what I'm trying to accomplish here, > which is determine the next, future, pending ex-date for dividends or > splits, if there is one announced, so that I can prepare the systems > for this in advance. It seems to be an nasty problem and I'm trying > to get out of maintaining this by hand! > > On Thu, Sep 6, 2012 at 9:05 AM, G See wrote: >> On Thu, Sep 6, 2012 at 8:02 AM, Ralph Vince wrote: >>> Thanks for the replies. I'm not looking for data adjusted for splits >>> and dividends, but rather the ex-dates when the dividend or split will >>> be affecting prices, and the amount of the dividends/ splits. It >>> appears Yahoo finance might have this information, Im just not sure >>> how, in R, to extract anything other than prices in R. Ralph Vince >> >> library(quantmod) >> ?getDividends >> ?getSplits >> ?adjRatios >> ?getQuote >> ?yahooQF >> >> That is much more on topic that "can someone tell me where to get some >> data?" ;-) >> >> Best, >> Garrett ___ R-SIG-Finance@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-sig-finance -- Subscriber-posting only. If you want to post, subscribe first. -- Also note that this is not the r-help list where general R questions should go.
Re: [R-SIG-Finance] Equities Data
Also in quantmod, there is `getFinancials` if you want financial statements In qmao (https://r-forge.r-project.org/R/?group_id=1113), there's `getEarnings` which will give you historic analyst estimates and actual earnings numbers `getEarningsCalendar` will show you all stocks (U.S. and non-U.S.) that report earnings. It supports "from" and "to" arguments. `getDividendsCalendar` will show you all stocks that go Ex-Div today (although it also supports from and to if you want to see historic calendars) `getEconomicCalendar` shows the calendar of economic number releases `getMergersCalendar` shows mergers/acquisitions -Garrett On Thu, Sep 6, 2012 at 8:18 AM, Ralph Vince wrote: > Ah, thank you! It must be in the Quantmod API / Thank you. Ralph Vince > > On Thu, Sep 6, 2012 at 9:05 AM, G See wrote: >> On Thu, Sep 6, 2012 at 8:02 AM, Ralph Vince wrote: >>> Thanks for the replies. I'm not looking for data adjusted for splits >>> and dividends, but rather the ex-dates when the dividend or split will >>> be affecting prices, and the amount of the dividends/ splits. It >>> appears Yahoo finance might have this information, Im just not sure >>> how, in R, to extract anything other than prices in R. Ralph Vince >> >> library(quantmod) >> ?getDividends >> ?getSplits >> ?adjRatios >> ?getQuote >> ?yahooQF >> >> That is much more on topic that "can someone tell me where to get some >> data?" ;-) >> >> Best, >> Garrett ___ R-SIG-Finance@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-sig-finance -- Subscriber-posting only. If you want to post, subscribe first. -- Also note that this is not the r-help list where general R questions should go.
Re: [R-SIG-Finance] Equities Data
On Thu, Sep 6, 2012 at 8:02 AM, Ralph Vince wrote: > Thanks for the replies. I'm not looking for data adjusted for splits > and dividends, but rather the ex-dates when the dividend or split will > be affecting prices, and the amount of the dividends/ splits. It > appears Yahoo finance might have this information, Im just not sure > how, in R, to extract anything other than prices in R. Ralph Vince library(quantmod) ?getDividends ?getSplits ?adjRatios ?getQuote ?yahooQF That is much more on topic that "can someone tell me where to get some data?" ;-) Best, Garrett ___ R-SIG-Finance@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-sig-finance -- Subscriber-posting only. If you want to post, subscribe first. -- Also note that this is not the r-help list where general R questions should go.
Re: [R-SIG-Finance] Performance Analytics Calendar Returns
On Wed, Sep 5, 2012 at 12:21 AM, Nikos Rachmanis wrote: > However, I am trying to transform the daily returns of my P&L (which also > include gaps) to monthly and unfortunately the to.monthly does not work > very well. > > i am currently trying table.TrailingPeriods and rollapply. > > Any other ideas or functions? ?apply.monthly apply.monthly(PnL, sum) -Garrett ___ R-SIG-Finance@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-sig-finance -- Subscriber-posting only. If you want to post, subscribe first. -- Also note that this is not the r-help list where general R questions should go.
Re: [R-SIG-Finance] blotter updatePortf issue..
Hi Pie, Thanks for providing reproducible code. I committed a patch in Rev. 1151 that I believe will fix your problem. If you need help checking out and building the latest revision, see this post on SO: http://stackoverflow.com/a/11105132/967840 Internally, the code was checking to see if "Dates" was timeBased. If it wasn't, it was being converted to a timeBased vector. But, later, the code was treating "Dates" as if it were not timeBased. Hopefully my patch fixes your problem and doesn't create others. There are a couple other things to mention. First, these lines are not going to work: updateAcct(account, Dates=paste('::',as.Date(Sys.time()),sep='')) updateEndEq(account, Dates=paste('::',as.Date(Sys.time()),sep='')) These functions do not support that type of "Dates" strings. You'll have to either use Dates=NULL, or supply both starting and ending dates like this: updateAcct(account, Dates=paste(initDate, as.Date(Sys.time()),sep='::') ) updateEndEq(account, Dates=paste(initDate, as.Date(Sys.time()),sep='::') ) Second, I didn't get these warnings that you got >> > getSymbols(symbols, src='yahoo', >> index.class=c("POSIXt","POSIXct"),from='2001-01-01') >> [1] "QQQ" "IWM" >> Warning messages: >> 1: In download.file(paste(yahoo.URL, "s=", Symbols.name, "&a=", from.m, : >> downloaded length 147933 != reported length 200 >> 2: In download.file(paste(yahoo.URL, "s=", Symbols.name, "&a=", from.m, : >> downloaded length 147996 != reported length 200 I'm not sure why you get those warnings, but your version of quantmod is a little older than mine (the R-forge version). HTH, Garrett On Sun, Sep 2, 2012 at 11:27 PM, pie trader wrote: > Hi, > Currently I am stuck on an error with updatePortf function in blotter. The > error message is same as the issue mentioned on R-sig-finance previously > i.e., > http://r.789695.n4.nabble.com/blotter-updatePortf-issues-tp4635933.html > >> >> updatePortf(Portfolio=portfolio,Dates=paste('::',as.Date(Sys.time()),sep='')) >> Error in if (length(c(year, month, day, hour, min, sec)) == 6 && c(year, >> : >> missing value where TRUE/FALSE needed >> In addition: Warning message: >> In as_numeric() : NAs introduced by coercion > > ___ R-SIG-Finance@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-sig-finance -- Subscriber-posting only. If you want to post, subscribe first. -- Also note that this is not the r-help list where general R questions should go.
Re: [R-SIG-Finance] FinancialInstrument functions output / side effect variables
Doug, I re-read your question. Let me clarify. Instruments are stored in an environment called .instrument at the top level of the package. You can see everything in that environment like this ls(FinancialInstrument:::.instrument) However, there are lots of functions show the primary_ids of instruments that do some checking to make sure that what is being shown are indeed primary_ids of instruments. e.g ls_stocks() ls_currencies() ls_instruments() Let me know if I can offer more clarity. Best, Garrett On Fri, Aug 24, 2012 at 11:44 AM, G See wrote: > Hi Doug, > > You can use getInstrument to see the instruments > > e.g. > > stock("SPY", currency("USD")) > getInstrument("USD") > getInstrument("SPY") > > Please take a look at the files in the demo directory > (https://r-forge.r-project.org/scm/viewvc.php/pkg/FinancialInstrument/demo/FIdemo2.R?view=markup&root=blotter) > > You'll also probably be interested in ?buildHierarchy > > build_series_symbols does nothing but return a character vector and it > does not store it anywhere and it does not create any instruments. (I > personally use future_id from the twsInstrument package to serve the > purpose of build_series_symbols) > > HTH, > Garrett ___ R-SIG-Finance@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-sig-finance -- Subscriber-posting only. If you want to post, subscribe first. -- Also note that this is not the r-help list where general R questions should go.
Re: [R-SIG-Finance] FinancialInstrument functions output / side effect variables
Hi Doug, You can use getInstrument to see the instruments e.g. stock("SPY", currency("USD")) getInstrument("USD") getInstrument("SPY") Please take a look at the files in the demo directory (https://r-forge.r-project.org/scm/viewvc.php/pkg/FinancialInstrument/demo/FIdemo2.R?view=markup&root=blotter) You'll also probably be interested in ?buildHierarchy build_series_symbols does nothing but return a character vector and it does not store it anywhere and it does not create any instruments. (I personally use future_id from the twsInstrument package to serve the purpose of build_series_symbols) HTH, Garrett On Fri, Aug 24, 2012 at 11:37 AM, Doug Edmunds wrote: > How can I see what the names of variables and what is being stored > in them when running functions in the FinancialInstrument package? I am > using R-Studio. > > For example, running: >> currency("USD") > outputs this to the console window: > [1] "USD" > > but gives me no clue as to where that value is being > stored or how to access it. > > Similarly, reading a tutorial such as: > > http://blog.fosstrading.com/2011/07/creating-financial-instrument-metadata.html, > it says: > > "build_series_symbols returns a vector of series symbols that we could use > to request data or create future_series instruments." > > But what is the name of the vector? Where is it stored? > > Thanks. > > ___ > R-SIG-Finance@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-sig-finance > -- Subscriber-posting only. If you want to post, subscribe first. > -- Also note that this is not the r-help list where general R questions > should go. ___ R-SIG-Finance@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-sig-finance -- Subscriber-posting only. If you want to post, subscribe first. -- Also note that this is not the r-help list where general R questions should go.
Re: [R-SIG-Finance] Bug in chart.CumReturns (PerformanceAnalytics)
Peter, I agree that this is confusing. >From ?Return.cumulative: "geometric generate geometric (TRUE) or simple (FALSE) returns, default TRUE" So, you use geometric=FALSE to create simple returns. Then you use geometric=TRUE if you want to chart them? Best, Garrett On Wed, Aug 22, 2012 at 4:08 PM, Peter Carl wrote: > Correct, if you have simple returns, set geometric=TRUE. > > pcc > -- > Peter Carl > http://www.braverock.com/peter > >> Call it what you want but for a simple (arithematic or geometric = FALSE) >> return, the equity curve should be cumprod(1+R) not cumsum(R). >> >> C. >> >> >> >> >> De : Peter Carl >> À : Chris de Bleu >> Cc : "r-sig-finance@r-project.org" >> Envoyé le : Mercredi 22 août 2012 22h55 >> Objet : Re: [R-SIG-Finance] Bug in chart.CumReturns (PerformanceAnalytics) >> >> The "arithmetic" and "geometric" tags (indicated as geometric=TRUE or >> FALSE) are used not for the returns themselves, but the *chaining method* >> used in the calculation. (I think the documentation says "simple" instead >> of "arithmetic"). Part of the confusion is that the language people are >> using in the literature is slightly different than what I adopted at the >> beginning, and it could be changed to be more clear. Also, geometric == >> compound. >> >> Perhaps we should use chaining.method=c("geometric", "simple") for all of >> these functions in a future version. Alternatively, we could use >> returns.type=c("simple", "log") and provide the transformed returns from >> the "log" case, although somewhat I'm reluctant to do that across the >> whole package. >> >> pcc >> -- >> Peter Carl >> http://www.braverock.com/peter > > ___ > R-SIG-Finance@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-sig-finance > -- Subscriber-posting only. If you want to post, subscribe first. > -- Also note that this is not the r-help list where general R questions > should go. ___ R-SIG-Finance@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-sig-finance -- Subscriber-posting only. If you want to post, subscribe first. -- Also note that this is not the r-help list where general R questions should go.
Re: [R-SIG-Finance] help with quantmod and addTA
I don't know, Oliver. You're code is not reproducible. However, a cursory search of this list suggests that wrapping your addTA calls in plot may help. HTH, Garrett On Fri, Aug 10, 2012 at 1:43 PM, Olivier MARTIN wrote: > Hi all, > > I don't understand very well the principles of oriented > programmation and I have some diffculties with the function addTA(). > > I suppose I have plotted a time serie with the function candleChart() for > example. > I have a vector y with 1,-1 and 0 values with the same length than my serie. > If i want to add a shaded region corresponding to the value 1, I can do it > with > addTA(y==1,col="gray90",border=NA,on=-1) > > So I would like to write a function that add the three different regions > I tried this > addshaded=function(x){ > addTA(x==1,col="gray90",border=NA,on=-1) > addTA(x==-1,col="green",border=NA,on=-1) > addTA(x==0,col="red",border=NA,on=-1) > } > > But the command addshaded(y) does not add the three different > shaded regions. ;-( > > Regards, > Olivier. > > ___ > R-SIG-Finance@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-sig-finance > -- Subscriber-posting only. If you want to post, subscribe first. > -- Also note that this is not the r-help list where general R questions > should go. ___ R-SIG-Finance@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-sig-finance -- Subscriber-posting only. If you want to post, subscribe first. -- Also note that this is not the r-help list where general R questions should go.
Re: [R-SIG-Finance] quantmod bug ?
Also, shouldn't patches be encouraged? On Wed, Aug 8, 2012 at 10:16 AM, G See wrote: > chartSeries is on CRAN and ?chart_Series says it's "highly experimental." > > IMHO it's really not fair to tell people that they should use > undocumented code. > > Garrett ___ R-SIG-Finance@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-sig-finance -- Subscriber-posting only. If you want to post, subscribe first. -- Also note that this is not the r-help list where general R questions should go.
Re: [R-SIG-Finance] quantmod bug ?
chartSeries is on CRAN and ?chart_Series says it's "highly experimental." IMHO it's really not fair to tell people that they should use undocumented code. Garrett On Wed, Aug 8, 2012 at 10:11 AM, Brian G. Peterson wrote: > On 08/08/2012 10:05 AM, Olivier MARTIN wrote: >> >> I recently posted a problem concerning shaded regions with quantmod >> package. More precisely, I used the function addTA with a boolean vector: > > > As has been posted to this list many times in the past year, development of > graphics in quantmod has moved wholly to chart_Series and add_TA, and the > older chartSeries and addTA are unlikely to get much (any) attention. The > old code is just too difficult to maintain. > > If you can replicate your problem with the newer functions, you're much more > likely to get a response from someone with commit access to the code. > > Regards, > > - Brian > > -- > Brian G. Peterson > http://braverock.com/brian/ > Ph: 773-459-4973 > IM: bgpbraverock > > > ___ > R-SIG-Finance@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-sig-finance > -- Subscriber-posting only. If you want to post, subscribe first. > -- Also note that this is not the r-help list where general R questions > should go. ___ R-SIG-Finance@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-sig-finance -- Subscriber-posting only. If you want to post, subscribe first. -- Also note that this is not the r-help list where general R questions should go.
Re: [R-SIG-Finance] qsiblive, how to debug code with source() as sub procedure
Please see this thread: https://stat.ethz.ch/pipermail/r-sig-finance/2012q2/010264.html If you're still unable to checkout, build and install the latest code, then see this SO post: http://stackoverflow.com/a/11105132 Don't give up until you see packageVersion("IBrokers") [1] ‘0.9.7’ Garrett On Thu, Jul 19, 2012 at 10:53 PM, unsown wrote: > Thanks for your suggestion, Soren. After getting familiar with the debugging > tools of R and the codes by you, I'm now able to looking into the codes line > by line. The command traceback() and browser() work best for me. > > BTW. I might have identified a problem with IBrokers during the debugging. > Here is the version I'm using: > IBrokers version 0.9-3: > Implementing API Version 9.64 > > After building a connection. the "nextId" filed of the returned connection > is actually the account name instead of an integer number, which cause a > problem when place an order. > > The latest IB API is version 9.66. I thought it might because of my IBrokers > is out of date and I found there is another version of IBrokers on Google > Code. But it looks like that version is even older (0.9-0). > > > -- > View this message in context: > http://r.789695.n4.nabble.com/qsiblive-how-to-debug-code-with-source-as-sub-procedure-tp4636519p4637147.html > Sent from the Rmetrics mailing list archive at Nabble.com. > > ___ > R-SIG-Finance@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-sig-finance > -- Subscriber-posting only. If you want to post, subscribe first. > -- Also note that this is not the r-help list where general R questions > should go. ___ R-SIG-Finance@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-sig-finance -- Subscriber-posting only. If you want to post, subscribe first. -- Also note that this is not the r-help list where general R questions should go.
Re: [R-SIG-Finance] IBrokers : quotes from futures combo and reqIds
:-( I'm afraid it doesn't even work with "1" and "1" Were you able to get market data for a twsBAG, Soren? In May, Jeff suggested it doesn't work: https://stat.ethz.ch/pipermail/r-sig-finance/2012q2/010258.html On Thu, Jul 19, 2012 at 11:36 AM, me wrote: > Hi Stergios > > I believe it is your ratios. They have to be integers. > your second one is > > ratio = "1.06" > > You will have to calculate the most feasible rational approximation to > your beta of > > -1.06/1 > > One solution would be > > -21/20 ~ -1.05 > > So you could set > > leg1: ratio = "21" > leg2: ratio = "20" > > That should do it. > > Cheers > > Soren > > http://censix.com > > > On Thu, 19 Jul 2012 08:28:17 -0700 (PDT) > Stergios Marinopoulos wrote: > >> I took Garrett's example and tried to get it working using IBrokers. >> It's starts writing data to a file as expected, but then the error >> below is produced and quote data is no longer written to the file. >> >> 2 1 320 Error reading request:-'wc' : cause - Unable format field - >> >> >> >> >> Here's the code: >> >> library(IBrokers) ; >> tws <- twsConnect(1) >> bag <- twsBAG( >> twsComboLeg( >> conId = "756733", #conId("SPY"), >> ratio = "1", >> action = "BUY", >> exchange = "SMART" >> ) , >> twsComboLeg( >> conId = "73128548", #conId("DIA"), >> ratio = "1.06", >> action = "SELL", >> exchange = "SMART" >> ) >> ) >> bag.csv <- file("~/bag.csv", open="w") >> reqMktData(tws, bag, >>eventWrapper=eWrapper.MktData.CSV(1), >>file=bag.csv) >> >> >> -- >> Stergios Marinopoulos >> >> >> - Original Message - >> From: G See >> To: Stergios Marinopoulos >> Cc: omerle ; "r-sig-finance@r-project.org" >> Sent: Thursday, July 19, 2012 11:11 AM >> Subject: Re: [R-SIG-Finance] IBrokers : quotes from futures combo and >> reqIds >> >> On Thu, Jul 19, 2012 at 10:09 AM, Stergios Marinopoulos >> wrote: >> > In Java, if you create a proper BAG Contract you can use it with >> > reqMktData() or reqHistoricalData(). I imagine the same holds true >> > in R as well. (I can send Java examples if interested.) >> > >> > Try using IBrokers twsBAG() function to create a combo contract, >> > and use the returned object as the contract to IBrokers's >> > equivalent of reqMktData() and data should start streaming. >> > >> >> I'm unable to get that to work. If anyone else can get it to work, >> please share your secret. >> >> Thanks, >> Garrett >> >> ___ >> R-SIG-Finance@r-project.org mailing list >> https://stat.ethz.ch/mailman/listinfo/r-sig-finance >> -- Subscriber-posting only. If you want to post, subscribe first. >> -- Also note that this is not the r-help list where general R >> questions should go. > > > > -- > Soren Wilkening > > http://censix.com ___ R-SIG-Finance@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-sig-finance -- Subscriber-posting only. If you want to post, subscribe first. -- Also note that this is not the r-help list where general R questions should go.
Re: [R-SIG-Finance] IBrokers : quotes from futures combo and reqIds
On Thu, Jul 19, 2012 at 10:09 AM, Stergios Marinopoulos wrote: > In Java, if you create a proper BAG Contract you can use it with reqMktData() > or > reqHistoricalData(). I imagine the same holds true in R as well. (I can > send Java examples if interested.) > > Try using IBrokers twsBAG() function to create a combo contract, and use the > returned object as the contract to IBrokers's equivalent of reqMktData() and > data should start streaming. > I'm unable to get that to work. If anyone else can get it to work, please share your secret. Thanks, Garrett ___ R-SIG-Finance@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-sig-finance -- Subscriber-posting only. If you want to post, subscribe first. -- Also note that this is not the r-help list where general R questions should go.
Re: [R-SIG-Finance] IBrokers : quotes from futures combo and reqIds
I don't have a complete answer, but I don't think you directly request a quote for a twsBAG. You could get a quote for each leg and calculate it yourself. Below is an example. I hope you don't mind if I use the get_quote function from my twsInstrument package (https://r-forge.r-project.org/R/?group_id=1113). I don't know how IB calculates the BidSize and AskSize of a combo, but you can look at how I calculated it and see if it makes sense. [I don't trade subscribe to market data for MATIF, so below I'll make a combo between SPY and DIA. Note that the ratio I chose is by no means a recommendation -- I just picked a number that would make the spread close to dollar neutral] require("twsInstrument") bag <- twsBAG( twsComboLeg( conId = "756733", #conId("SPY"), ratio = "1", action = "BUY", exchange = "SMART" ) , twsComboLeg( conId = "73128548", #conId("DIA"), ratio = "1.06", action = "SELL", exchange = "SMART" ) ) ## Get a quote for both legs (tmp <- get_quote(c(bag$comboleg[[1]]$conId, bag$comboleg[[2]]$conId))) #BidSize BidPrice AskPrice AskSize Last LastSize Volume #SPY 108 137.45 137.46 138 137.453 385111 #DIA 25 129.10 129.11 23 129.091 10656 data.frame(BidSize=min(c(as.numeric(bag$comboleg[[1]]$ratio) * tmp$BidSize[1], as.numeric(bag$comboleg[[2]]$ratio) * tmp$AskSize[2])), BidPrice=as.numeric(bag$comboleg[[1]]$ratio) * tmp$BidPrice[1] - as.numeric(bag$comboleg[[2]]$ratio) * tmp$AskPrice[2], AskPrice=as.numeric(bag$comboleg[[1]]$ratio) * tmp$AskPrice[1] - as.numeric(bag$comboleg[[2]]$ratio) * tmp$BidPrice[2], AskSize=min(c(as.numeric(bag$comboleg[[1]]$ratio) * tmp$AskSize[1], as.numeric(bag$comboleg[[2]]$ratio) * tmp$BidSize[2])), row.names=paste(rownames(tmp), collapse=".")) #BidSize BidPrice AskPrice AskSize #SPY.DIA 24.38 0.59340.61426.5 HTH, Garrett On Thu, Jul 19, 2012 at 8:18 AM, omerle wrote: > Dear, > > 1 - Quotes from futures combo > > I need quotes from futures combo but I cant find how to find these quotes. > I can place combo orders but I can't find how to get the quotes. For > instance, I would > like to have the quotes of the combo between ECO AUG12 (83617918) and ECO > NOV12 > (87689647). > Do you have any idea ? > Which part of the IB API documentation should I check ? > That's quite important for me ! > > 2 - reqIds > > If I understand well reqIds, it doesnt give the next iDs from Interactive > Broker but the > last iDs + 1 of the R session or TWS. Sometimes it doesn't work for me > because when I > relaunch R or TWS it forgets the real last iDs. > When the iDs count is relaunch ? How can I relaunch it ? > > > Thanks a lot, > > Olivier MERLE > > Une messagerie gratuite, garantie à vie et des services en plus, ça vous > tente ? > Je crée ma boîte mail www.laposte.net > > ___ > R-SIG-Finance@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-sig-finance > -- Subscriber-posting only. If you want to post, subscribe first. > -- Also note that this is not the r-help list where general R questions > should go. ___ R-SIG-Finance@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-sig-finance -- Subscriber-posting only. If you want to post, subscribe first. -- Also note that this is not the r-help list where general R questions should go.
Re: [R-SIG-Finance] qsiblive, how to debug code with source() as sub procedure
On Sat, Jul 14, 2012 at 9:59 AM, unsown wrote: > I'm not an experienced R user and I'm currently trying with the psiblive demo > codes. I found the source() command has been used in quite a few places in > the codes. I understand that by using this a long procedure can be separated > into several modules, but I found it is not easy to debug. One of the > difficulty is that it seems not easy to find out which file and which line > the error belonged to. Maybe ?getSrcFilename can help with this Regards, Garrett ___ R-SIG-Finance@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-sig-finance -- Subscriber-posting only. If you want to post, subscribe first. -- Also note that this is not the r-help list where general R questions should go.
Re: [R-SIG-Finance] yahoo dates
The workaround for get.hist.quote sounds like a good one, and I would love to see something similar added to getSymbols.yahoo. I did not mean to suggest that there's not a problem; the point I was trying to get at is that I think it only occurs with historical data, not "current" data. So, the user could record their own data. I realize that's a little off topic to the question though. To test my theory, I've been "streaming" quotes from yahoo for the past couple days by repeatedly requesting current quotes. I've found that the extra volume never appears using this method. When the market closes, the Volume stops changing. When the market opens, the volume jumps to zero (or close to it). So, one workaround might be to replace the last day (and it's duplicate if there is a duplicate) with the data returned by `getQuote` For reference, here's the code I used to collect data. Although, it probably shouldn't be used because Yahoo probably doesn't like folks hitting their server this hard. library(quantmod) filename <- "~/GSPCintra.csv" file.create(filename) # Add headers cat(paste0("Sys.time,", paste(make.names(colnames(getQuote("^GSPC"))), collapse=","), "\n"), file=filename) # record data; break with ctrl-c while(TRUE) { try(cat(paste0(Sys.time(), ",", paste(getQuote("^GSPC")[1, ], collapse=","), "\n"), file=filename, append=TRUE)) } # retrieve tmp <- read.table(filename, stringsAsFactors=FALSE, sep=",", header=TRUE) x <- xts(tmp[, c(6:8, 3, 9)], as.POSIXct(tmp[, 1])) Cheers, Garrett On Tue, Jul 10, 2012 at 4:56 AM, Achim Zeileis wrote: > On Mon, 9 Jul 2012, G See wrote: > >> FWIW, I download 33 fields from yahoo every night at 10 p.m. CDT using > > > I'm not sure but maybe that is still too early. The problem is real and > occurs for me "now" (around 10:00 GMT), both for individual stocks and > indexes: > > R> library("quantmod") > R> getSymbols(c("^GSPC", "IBM")) > R> tail(GSPC, 3) >GSPC.Open GSPC.High GSPC.Low GSPC.Close GSPC.Volume GSPC.Adjusted > 2012-07-06 1367.09 1367.09 1348.031354.68 274514 1354.68 > 2012-07-09 1354.66 1354.87 1346.651352.51 399252300 1352.46 > 2012-07-09 1354.66 1354.87 1346.651352.46 290486 1352.46 > R> tail(IBM, 3) >IBM.Open IBM.High IBM.Low IBM.Close IBM.Volume IBM.Adjusted > 2012-07-06 193.92 193.94 189.74191.414952900 191.41 > 2012-07-09 190.66 191.00 188.05189.653569800 189.67 > 2012-07-09 190.76 191.00 188.05189.673988100 189.67 > > Note the last line in both cases, especially the volume. The same is > visible, of course, at the Yahoo! Finance site: > > http://finance.yahoo.com/q/hp?s=^GSPC+Historical+Prices > http://finance.yahoo.com/q/hp?s=IBM+Historical+Prices > > Users of Yahoo! Finance also complained about this in the user forum. But as > nobody could offer a good explanation for this, we implemented a patch in > tseries' get.hist.quote() that omits the last observation in case its date > is dupblicated: > This sounds like something quantmod should consider doing > R> library("tseries") > R> tail(get.hist.quote("IBM"), 3) > Open HighLow Close > 2012-07-05 194.88 196.85 193.63 195.29 > 2012-07-06 193.92 193.94 189.74 191.41 > 2012-07-09 190.76 191.00 188.05 189.67 > Warning message: > In get.hist.quote("IBM") : first date duplicated, first instance omitted > > Best, > > Z > ___ R-SIG-Finance@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-sig-finance -- Subscriber-posting only. If you want to post, subscribe first. -- Also note that this is not the r-help list where general R questions should go.
Re: [R-SIG-Finance] TSE ticker problems
Paul, Although, changing the yahoo URL seemed to work to get yahoo's data for COS.TO, beware that there is a 4+ month gap in their data in 2012. tail(COS.TO) COS.TO.Open COS.TO.High COS.TO.Low COS.TO.Close COS.TO.Volume 2012-02-22 23.25 23.61 23.2323.61 1473800 2012-02-23 23.68 23.75 23.4123.62 1560800 2012-02-24 23.74 23.96 23.6223.66 1639300 2012-02-27 23.60 23.60 23.2623.34 1261100 2012-02-28 23.34 23.70 23.2723.34 2038900 2012-07-11 19.13 19.59 18.9219.40 1286400 COS.TO.Adjusted 2012-02-22 23.61 2012-02-23 23.62 2012-02-24 23.66 2012-02-27 23.34 2012-02-28 23.34 2012-07-11 23.34 Garrett On Wed, Jul 11, 2012 at 1:57 PM, Paul Gilbert wrote: > however the yahoo retrieval is fixed by the > getSymbols.yahoo URL change suggested. ___ R-SIG-Finance@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-sig-finance -- Subscriber-posting only. If you want to post, subscribe first. -- Also note that this is not the r-help list where general R questions should go.
Re: [R-SIG-Finance] TSE ticker problems
But... I see plenty of data there... including a link to "Download to Spreadsheet" http://ichart.finance.yahoo.com/table.csv?s=COS.TO&d=6&e=11&f=2012&g=d&a=7&b=13&c=1996&ignore=.csv On Wed, Jul 11, 2012 at 2:39 PM, Doug Edmunds wrote: > On http://finance.yahoo.com/q/hp?s=COS.TO , > the link to Historical Prices has no data. > > Probably why you only get headers. > > getSymbols("COS.TO", src="yahoo") > > ___ > R-SIG-Finance@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-sig-finance > -- Subscriber-posting only. If you want to post, subscribe first. > -- Also note that this is not the r-help list where general R questions > should go. ___ R-SIG-Finance@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-sig-finance -- Subscriber-posting only. If you want to post, subscribe first. -- Also note that this is not the r-help list where general R questions should go.
Re: [R-SIG-Finance] TSE ticker problems
I don't think google provides that data in a nice format (i.e. CSV) If you go to http://www.google.com/finance/historical?q=NYSEARCA:SPY you can see that on the right side of the page there is a section called "Export" with a link called "Download to spreadsheet" However, if you go the analogous page for COS, there is no such link. http://www.google.com/finance/historical?q=TSE:COS On Wed, Jul 11, 2012 at 1:57 PM, Paul Gilbert wrote: > My bad. Indeed the examples should have been: > >> getSymbols("BMO.TO", src="yahoo") >> getSymbols("COS.TO", src="yahoo") >> getSymbols("TSE:COS", src="google") > > They lost something in translation from my code. The problem is not resolved > by this correction, however the yahoo retrieval is fixed by the > getSymbols.yahoo URL change suggested. > > The google retrieval still causes problems: > >> getSymbols("TSE:COS", src="google") > Error in download.file(paste(google.URL, "q=", Symbols.name, "&startdate=", > : > cannot open URL > 'http://finance.google.com/finance/historical?q=TSE:COS&startdate=Jan+01,+2007&enddate=Jul+11,+2012&output=csv' > In addition: Warning message: > In download.file(paste(google.URL, "q=", Symbols.name, "&startdate=", : > > cannot open: HTTP status was '404 Not Found' >> > > Any further suggestions appreciated. > > Thanks, > Paul > > ___ R-SIG-Finance@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-sig-finance -- Subscriber-posting only. If you want to post, subscribe first. -- Also note that this is not the r-help list where general R questions should go.
Re: [R-SIG-Finance] TSE ticker problems
I don't have a good answer, but "dbname" is not an argument for either getSymbols or getSymbols.yahoo. It's pretty clear that you meant to use src="yahoo" and src="google" Note that the error that you got from getSymbols("TSE:COS", dbname="google") shows that it couldn't find http://chart.yahoo.com/ That's because it's using the default value of src="yahoo" which means getSymbols.yahoo is being called. Anyway, if you go into the source of getSymbols.yahoo, and change yahoo.URL <- "http://chart.yahoo.com/table.csv? To yahoo.URL <- "http://ichart.finance.yahoo.com/table.csv?"; Then it will work. But, I have no idea whether this will work for other symbols. > getSymbols("COS.TO", src='yahoo' [1] "COS.TO" > head(COS.TO) COS.TO.Open COS.TO.High COS.TO.Low COS.TO.Close COS.TO.Volume 2007-01-02 32.61 33.00 32.2032.39368500 2007-01-03 31.88 32.00 30.1530.16 1654000 2007-01-04 29.75 29.75 28.5028.87 1905400 2007-01-05 29.10 29.56 28.4728.89 2521000 2007-01-08 29.38 29.49 28.5028.60 1361300 2007-01-09 28.05 28.15 27.5027.85 1703500 COS.TO.Adjusted 2007-01-02 24.12 2007-01-03 22.46 2007-01-04 21.50 2007-01-05 21.52 2007-01-08 21.30 2007-01-09 20.74 HTH, Garrett On Wed, Jul 11, 2012 at 12:49 PM, Paul Gilbert wrote: > I have been having trouble retrieving some TSE series from yahoo: > >> require("quantmod") >> getSymbols("BMO.TO", dbname="yahoo") > > works but > >> getSymbols("COS.TO", dbname="yahoo") > > appears to have worked but has actually failed: > >> str(COS.TO) > An 'xts' object of zero-width > > It seems to be getting the header, but no data. I have also tried with > Google Finance: > >> getSymbols("TSE:COS", dbname="google") > Error in download.file(paste(yahoo.URL, "s=", Symbols.name, "&a=", from.m, > : > cannot open URL > 'http://chart.yahoo.com/table.csv?s=TSE:COS&a=0&b=01&c=2007&d=6&e=11&f=2012&g=d&q=q&y=0&z=TSE:COS&x=.csv' > In addition: Warning message: > In download.file(paste(yahoo.URL, "s=", Symbols.name, "&a=", from.m, : > cannot open: HTTP status was '404 Not Found' > > I'm not sure if I have the syntax correct for indicating an exchange on > google. Does anyone have suggestions? > > Thanks, > Paul > > ___ > R-SIG-Finance@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-sig-finance > -- Subscriber-posting only. If you want to post, subscribe first. > -- Also note that this is not the r-help list where general R questions > should go. ___ R-SIG-Finance@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-sig-finance -- Subscriber-posting only. If you want to post, subscribe first. -- Also note that this is not the r-help list where general R questions should go.
Re: [R-SIG-Finance] blotter updatePortf issues
Apologies for the misinformation. blotter was version 0.8.9 at Rev. 1027, and according to the OP version 0.8.9 does not have the error. I am unable to reproduce the error. Garrett On Tue, Jul 10, 2012 at 8:20 AM, G See wrote: > This does not have anything to do with xts. It is a blotter bug that > was introduced in Rev. 1027 > (http://r-forge.r-project.org/scm/viewvc.php/pkg/blotter/R/updatePosPL.R?sortby=rev&root=blotter&r1=1027&r2=1026&pathrev=1027) > > You can see from Hideyoshi's traceback, that updatePortf was called > with Dates=paste("::", as.Date(Sys.time())) > > 6: updatePortf(Portfolio = portfolio.st, Dates = paste("::", > as.Date(Sys.time()), >sep = "")) at macd.R#80 > > Then, later, in .updatePosPL, a "/" is added to the date string > > 8: index(prices[paste("/", .parseISO8601(Dates)$last.time, sep = "")]) > > So, it's trying to parse something that looks sort of like this > "/::2012-07-10" > > That said, I'm not sure how to patch. > > Best, > Garrett > ___ R-SIG-Finance@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-sig-finance -- Subscriber-posting only. If you want to post, subscribe first. -- Also note that this is not the r-help list where general R questions should go.