[Blotter-commits] r931 - in pkg/FinancialInstrument: . R man

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Mon Feb 20 21:19:54 CET 2012


Author: gsee
Date: 2012-02-20 21:19:54 +0100 (Mon, 20 Feb 2012)
New Revision: 931

Modified:
   pkg/FinancialInstrument/DESCRIPTION
   pkg/FinancialInstrument/R/all.equal.instrument.R
   pkg/FinancialInstrument/R/ls_instruments.R
   pkg/FinancialInstrument/man/ls_instruments.Rd
Log:
 - add copywrite file header to all.equal.instrument.R
 - add includeFX arg to ls_currencies (Default=FALSE)
 - switch order of match and includeFX args for ls_non_currencies to be
   consistent with other functions


Modified: pkg/FinancialInstrument/DESCRIPTION
===================================================================
--- pkg/FinancialInstrument/DESCRIPTION	2012-02-20 04:48:36 UTC (rev 930)
+++ pkg/FinancialInstrument/DESCRIPTION	2012-02-20 20:19:54 UTC (rev 931)
@@ -11,7 +11,7 @@
     meta-data and relationships. Provides support for
     multi-asset class and multi-currency portfolios. Still
     in heavy development.
-Version: 0.11.2
+Version: 0.11.3
 URL: https://r-forge.r-project.org/projects/blotter/
 Date: $Date$
 Depends:

Modified: pkg/FinancialInstrument/R/all.equal.instrument.R
===================================================================
--- pkg/FinancialInstrument/R/all.equal.instrument.R	2012-02-20 04:48:36 UTC (rev 930)
+++ pkg/FinancialInstrument/R/all.equal.instrument.R	2012-02-20 20:19:54 UTC (rev 931)
@@ -1,3 +1,18 @@
+###############################################################################
+# R (http://r-project.org/) Instrument Class Model
+#
+# Copyright (c) 2009-2012
+# Peter Carl, Dirk Eddelbuettel, Jeffrey Ryan, 
+# Joshua Ulrich, Brian G. Peterson, and Garrett See
+#
+# This library is distributed under the terms of the GNU Public License (GPL)
+# for full details see the file COPYING
+#
+# $Id: update_instruments.yahoo.R 899 2012-01-01 19:00:09Z gsee $
+#
+###############################################################################
+
+
 #' instrument all.equal method
 #'
 #' @param char.n If length of a character vector is \code{char.n} or less it 
@@ -28,6 +43,7 @@
 #' all.equal(getInstrument("DIA"), getInstrument("USD"))
 #' }
 all.equal.instrument <- function (target, current, char.n=2, collapse=";", ...) {
+    stopifnot(is.instrument(target))
     if (char.n < 0) char.n <- Inf
     msg <- NULL
     if (mode(target) != mode(current)) {

Modified: pkg/FinancialInstrument/R/ls_instruments.R
===================================================================
--- pkg/FinancialInstrument/R/ls_instruments.R	2012-02-20 04:48:36 UTC (rev 930)
+++ pkg/FinancialInstrument/R/ls_instruments.R	2012-02-20 20:19:54 UTC (rev 931)
@@ -210,25 +210,30 @@
 
 #' @export
 #' @rdname ls_instruments
-ls_currencies <- function(pattern=NULL, match=TRUE) {
-    symbols <- ls_instruments(pattern,match)
-    tmp_symbols <- NULL            
+ls_currencies <- function(pattern=NULL, match=TRUE, includeFX=FALSE) {
+    symbols <- ls_instruments(pattern=pattern, match=match)
+    tmp_symbols <- NULL
     for (instr in symbols) {
-        tmp_instr <- try(get(instr, pos = FinancialInstrument:::.instrument),silent=TRUE)
-        if (inherits(tmp_instr, 'currency') && inherits(tmp_instr, 'instrument')) {
-            tmp_symbols <- c(tmp_symbols,instr)
-        }    
+        tmp_instr <- try(get(instr, pos = FinancialInstrument:::.instrument),
+                         silent=TRUE)
+        if (inherits(tmp_instr, 'currency') 
+            && inherits(tmp_instr, 'instrument')) {
+            if (!inherits(tmp_instr, 'exchange_rate') || isTRUE(includeFX)) {
+                tmp_symbols <- c(tmp_symbols,instr)
+            }
+        }
     }
     tmp_symbols
 }
 
 #' @export
 #' @rdname ls_instruments
-ls_non_currencies <- function(pattern=NULL, includeFX=TRUE, match=TRUE) {
+ls_non_currencies <- function(pattern=NULL, match=TRUE, includeFX=TRUE) {
     symbols <- ls_instruments(pattern, match)
     tmp_symbols <- NULL            
     for (instr in symbols) {
-        tmp_instr <- try(get(instr, pos = FinancialInstrument:::.instrument),silent=TRUE)
+        tmp_instr <- try(get(instr, pos = FinancialInstrument:::.instrument),
+                         silent=TRUE)
         if (!inherits(tmp_instr, 'currency') || 
                 (inherits(tmp_instr, 'exchange_rate') && includeFX) ) {
             tmp_symbols <- c(tmp_symbols,instr)
@@ -239,14 +244,14 @@
 
 #' @export
 #' @rdname ls_instruments
-ls_exchange_rates <- function(pattern=NULL,match=TRUE) {
-    #This could use ls_currencies instead of ls_instruments, but currency class may be
-    #subject to change
-    symbols <- ls_instruments(pattern=pattern,match=match)    
+ls_exchange_rates <- function(pattern=NULL, match=TRUE) {
+    symbols <- ls_currencies(pattern=pattern, match=match, includeFX=TRUE)
     tmp_symbols <- NULL            
     for (instr in symbols) {
-        tmp_instr <- try(get(instr, pos = FinancialInstrument:::.instrument),silent=TRUE)
-        if (inherits(tmp_instr, 'exchange_rate') && inherits(tmp_instr, 'instrument')) {
+        tmp_instr <- try(get(instr, pos = FinancialInstrument:::.instrument),
+                         silent=TRUE)
+        if (inherits(tmp_instr, 'exchange_rate') 
+            && inherits(tmp_instr, 'instrument')) {
             tmp_symbols <- c(tmp_symbols,instr)
         }    
     }

Modified: pkg/FinancialInstrument/man/ls_instruments.Rd
===================================================================
--- pkg/FinancialInstrument/man/ls_instruments.Rd	2012-02-20 04:48:36 UTC (rev 930)
+++ pkg/FinancialInstrument/man/ls_instruments.Rd	2012-02-20 20:19:54 UTC (rev 931)
@@ -52,10 +52,11 @@
 
   ls_future_series(pattern = NULL, match = TRUE)
 
-  ls_currencies(pattern = NULL, match = TRUE)
+  ls_currencies(pattern = NULL, match = TRUE,
+    includeFX = FALSE)
 
-  ls_non_currencies(pattern = NULL, includeFX = TRUE,
-    match = TRUE)
+  ls_non_currencies(pattern = NULL, match = TRUE,
+    includeFX = TRUE)
 
   ls_exchange_rates(pattern = NULL, match = TRUE)
 



More information about the Blotter-commits mailing list