[Blotter-commits] r813 - pkg/FinancialInstrument/sandbox
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Wed Oct 5 19:00:45 CEST 2011
Author: gsee
Date: 2011-10-05 19:00:44 +0200 (Wed, 05 Oct 2011)
New Revision: 813
Modified:
pkg/FinancialInstrument/sandbox/define.index.components.yahoo.R
Log:
updates to define_components.yahoo
Modified: pkg/FinancialInstrument/sandbox/define.index.components.yahoo.R
===================================================================
--- pkg/FinancialInstrument/sandbox/define.index.components.yahoo.R 2011-10-05 16:18:36 UTC (rev 812)
+++ pkg/FinancialInstrument/sandbox/define.index.components.yahoo.R 2011-10-05 17:00:44 UTC (rev 813)
@@ -2,7 +2,7 @@
#' Define an Index and it's components using yahoo
#'
#' Get the components of an index and define instruments
-#' @param Symbol character yahoo ticker symbol for a stock index (e.g. "^DJI" or "^GDAX")
+#' @param Symbol character yahoo ticker symbol for a stock index (e.g. "^DJI" or "^GDAXI")
#' @param currency
#' @return called for side-effect, but it will return a list with 2 components:
#' \item{synthetic}{name of the \code{\link{synthetic}} instrument that was defined to hold the metadata of the index.}
@@ -22,10 +22,17 @@
mdata <- x[which.max(sapply(x, NROW))][[1]][,1:2]
new.Symbol <- synthetic(Symbol, ccy, members=paste(mdata[,1]), src=list(src='yahoo',name=Symbol), identifiers=list(yahoo=Symbol))
if (!identical(integer(0), grep("There is no Components data", mdata[,1]))) stop("No Components Data Available for ", Symbol)
+ stks <- rep(NA_character_, NROW(mdata))
for (i in 1:NROW(mdata)) {
- stock(paste(mdata[i,1]), currency=ccy, Name=paste(mdata[i,2]), member.of=new.Symbol)
+ tmpsym <- paste(mdata[i,1])
+ stks[i] <- stock(tmpsym, currency=ccy, Name=paste(mdata[i,2]), member.of=new.Symbol)
+ if (!identical(tmpsym,stks[i])) {
+ # add info about how to find data and metadata
+ instrument_attr(stks[i], 'src', list(src='yahoo', name=tmpsym))
+ instrument_attr(stks[i], 'identifiers', list(yahoo=tmpsym))
+ }
}
- list(synthetic=new.Symbol, stock=paste(mdata[,1]))
+ list(synthetic=new.Symbol, stock=stks)
}
#define_components.yahoo('^STOXX50E','EUR')
@@ -36,3 +43,13 @@
#memb5
#getInstrument(memb5$member.of)
+
+#define_components.yahoo("^GDAXI","EUR")
+#getSymbols("X63DU.DE")
+#getSymbols("63DU.DE")
+#getInstrument("X63DU.DE")
+#getInstrument("63DU.DE")
+
+
+
+
More information about the Blotter-commits
mailing list