[Blotter-commits] r1035 - in pkg/FinancialInstrument: . R man
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Sat Jun 2 17:08:44 CEST 2012
Author: gsee
Date: 2012-06-02 17:08:44 +0200 (Sat, 02 Jun 2012)
New Revision: 1035
Modified:
pkg/FinancialInstrument/NAMESPACE
pkg/FinancialInstrument/R/update_instruments.yahoo.R
pkg/FinancialInstrument/man/update_instruments.yahoo.Rd
Log:
update_instruments.TTR no longer fails when called with Symbols that are not listed on 'exchange'. It also gains a 'silent' arg.
Modified: pkg/FinancialInstrument/NAMESPACE
===================================================================
--- pkg/FinancialInstrument/NAMESPACE 2012-05-30 03:12:26 UTC (rev 1034)
+++ pkg/FinancialInstrument/NAMESPACE 2012-06-02 15:08:44 UTC (rev 1035)
@@ -1,94 +1,87 @@
-S3method(all.equal,instrument)
-S3method(expires,character)
-S3method(expires,instrument)
-S3method(expires,xts)
-S3method(print,id.list)
-S3method(print,instrument)
-S3method(print,suffix.list)
export(.to_daily)
-export(C2M)
-export(ICS)
-export(ICS_root)
-export(M2C)
-export(MC2N)
export(add.defined.by)
export(add.identifier)
+export(bond_series)
export(bond)
-export(bond_series)
+export(build_series_symbols)
+export(build_spread_symbols)
export(buildBasket)
export(buildHierarchy)
export(buildRatio)
export(buildSpread)
-export(build_series_symbols)
-export(build_spread_symbols)
export(butterfly)
+export(C2M)
export(currency)
export(exchange_rate)
export(expires)
export(find.instrument)
export(fn_SpreadBuilder)
+export(format_id)
export(formatSpreadPrice)
-export(format_id)
export(fund)
+export(future_series)
export(future)
-export(future_series)
export(getInstrument)
export(getSymbols.FI)
export(guaranteed_spread)
-export(instrument)
+export(ICS_root)
+export(ICS)
+export(instrument_attr)
export(instrument.auto)
export(instrument.table)
-export(instrument_attr)
+export(instrument)
+export(is.currency.name)
export(is.currency)
-export(is.currency.name)
+export(is.instrument.name)
export(is.instrument)
-export(is.instrument.name)
export(load.instruments)
export(loadInstruments)
export(ls_AUD)
-export(ls_CAD)
-export(ls_CHF)
-export(ls_EUR)
-export(ls_FX)
-export(ls_GBP)
-export(ls_HKD)
-export(ls_ICS)
-export(ls_ICS_roots)
-export(ls_JPY)
-export(ls_NZD)
-export(ls_SEK)
-export(ls_USD)
export(ls_bonds)
export(ls_by_currency)
export(ls_by_expiry)
+export(ls_CAD)
export(ls_calls)
+export(ls_CHF)
export(ls_currencies)
export(ls_derivatives)
+export(ls_EUR)
export(ls_exchange_rates)
export(ls_expires)
export(ls_expiries)
export(ls_funds)
export(ls_future_series)
export(ls_futures)
+export(ls_FX)
+export(ls_GBP)
export(ls_guaranteed_spreads)
+export(ls_HKD)
+export(ls_ICS_roots)
+export(ls_ICS)
+export(ls_instruments_by)
export(ls_instruments)
-export(ls_instruments_by)
+export(ls_JPY)
export(ls_non_currencies)
export(ls_non_derivatives)
+export(ls_NZD)
export(ls_option_series)
export(ls_options)
export(ls_puts)
+export(ls_SEK)
export(ls_spreads)
export(ls_stocks)
export(ls_strikes)
export(ls_synthetics)
export(ls_underlyings)
+export(ls_USD)
+export(M2C)
export(make_spread_id)
+export(MC2N)
export(month_cycle2numeric)
export(next.future_id)
+export(option_series.yahoo)
+export(option_series)
export(option)
-export(option_series)
-export(option_series.yahoo)
export(parse_id)
export(parse_suffix)
export(prev.future_id)
@@ -116,14 +109,21 @@
export(sort_ids)
export(spread)
export(stock)
-export(synthetic)
export(synthetic.instrument)
export(synthetic.ratio)
+export(synthetic)
export(to_secBATV)
-export(update_instruments.TTR)
export(update_instruments.instrument)
export(update_instruments.masterDATA)
export(update_instruments.md)
+export(update_instruments.TTR)
export(update_instruments.yahoo)
export(volep)
importFrom(zoo,as.Date)
+S3method(all.equal,instrument)
+S3method(expires,character)
+S3method(expires,instrument)
+S3method(expires,xts)
+S3method(print,id.list)
+S3method(print,instrument)
+S3method(print,suffix.list)
Modified: pkg/FinancialInstrument/R/update_instruments.yahoo.R
===================================================================
--- pkg/FinancialInstrument/R/update_instruments.yahoo.R 2012-05-30 03:12:26 UTC (rev 1034)
+++ pkg/FinancialInstrument/R/update_instruments.yahoo.R 2012-06-02 15:08:44 UTC (rev 1035)
@@ -30,6 +30,7 @@
#' @param exchange character vector of names of exchanges. Used in \sQuote{TTR}
#' method. Can be \dQuote{AMEX}, \dQuote{NASDAQ}, or \dQuote{NYSE}
#' @param verbose be verbose?
+#' @param silent silence warnings?
#' @return called for side-effect
#' @author Garrett See
#' @seealso \code{\link{update_instruments.instrument}},
@@ -123,19 +124,24 @@
#' @export
#' @rdname update_instruments.yahoo
-update_instruments.TTR <- function(Symbols = c("stocks", "all"), exchange=c("AMEX","NASDAQ","NYSE")) {
+update_instruments.TTR <- function(Symbols = c("stocks", "all"),
+ exchange=c("AMEX","NASDAQ","NYSE"),
+ silent=FALSE) {
if (!suppressWarnings(is.currency.name("USD"))) currency("USD")
- df <- stockSymbols(exchange=exchange)
- if (!is.null(Symbols) && !(any(c("stocks", "all") %in% Symbols))) {
- rows <- try( match(Symbols,df$Symbol) )
- if (!inherits(rows, 'try-error')) {
- df <- df[rows,]
- } else {
- warning(paste(paste(Symbols,collapse=","), "not found among those listed on", paste(exchange,collapse=", ")))
- return(invisible(NULL))
- }
- } else if (!is.null(Symbols)) df <- df[match(ls_stocks(),df$Symbol),]
- cat('defining stocks...\n')
+ df <- stockSymbols(exchange=exchange)
+ if (any(c("stocks", "all") %in% Symbols)) {
+ Symbols <- ls_stocks()
+ }
+ df <- df[df[["Symbol"]] %in% Symbols, ]
+ if (nrow(df) == 0 && !isTRUE(silent)) {
+ warning(paste(paste(Symbols,collapse=","),
+ "not found among those listed on",
+ paste(exchange,collapse=", ")))
+ return(invisible(NULL))
+ }
+ if (!isTRUE(silent)) {
+ cat('defining stocks...\n')
+ }
symout <- NULL
for (i in 1:nrow(df)) {
primary_id <- as.character(df$Symbol[i])
Modified: pkg/FinancialInstrument/man/update_instruments.yahoo.Rd
===================================================================
--- pkg/FinancialInstrument/man/update_instruments.yahoo.Rd 2012-05-30 03:12:26 UTC (rev 1034)
+++ pkg/FinancialInstrument/man/update_instruments.yahoo.Rd 2012-06-02 15:08:44 UTC (rev 1035)
@@ -7,7 +7,7 @@
verbose = FALSE)
update_instruments.TTR(Symbols = c("stocks", "all"),
- exchange = c("AMEX", "NASDAQ", "NYSE"))
+ exchange = c("AMEX", "NASDAQ", "NYSE"), silent = FALSE)
}
\arguments{
\item{Symbols}{can be a vector of instrument names, or,
@@ -20,6 +20,8 @@
\dQuote{NASDAQ}, or \dQuote{NYSE}}
\item{verbose}{be verbose?}
+
+ \item{silent}{silence warnings?}
}
\value{
called for side-effect
More information about the Blotter-commits
mailing list