[Blotter-commits] r981 - pkg/FinancialInstrument/R

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Sat Mar 24 17:22:35 CET 2012


Author: gsee
Date: 2012-03-24 17:22:35 +0100 (Sat, 24 Mar 2012)
New Revision: 981

Modified:
   pkg/FinancialInstrument/R/instrument.R
Log:
 if instrument.auto is creating a future_series or option_series that has pre-defined
 root, do not warn that USD is being used as the currency. (root's currency will be
 used)

Modified: pkg/FinancialInstrument/R/instrument.R
===================================================================
--- pkg/FinancialInstrument/R/instrument.R	2012-03-24 04:19:17 UTC (rev 980)
+++ pkg/FinancialInstrument/R/instrument.R	2012-03-24 16:22:35 UTC (rev 981)
@@ -809,17 +809,23 @@
         }
     }
     if (any(pid$type == 'future') || any(pid$type == 'SSF')) {
-        currency <- if (!is.null(currency)) { 
-            currency 
-        } else { if (!silent) warning('using USD as the currency'); currency("USD") } 
         root <- getInstrument(pid$root,silent=TRUE,type='future')
         if (is.instrument(root) && !inherits(root, 'future_series')) {
-            return(future_series(primary_id, currency=currency, defined.by='auto', assign_i=assign_i,...))
+            if (is.null(currency) && is.null(root[['currency']])) {
+                if (!isTRUE(silent)) warning('using USD as the currency')
+                currency <- currency("USD")
+            }
+            return(future_series(primary_id, currency=currency, 
+                                 defined.by='auto', assign_i=assign_i,...))
         } else {
-            if (!silent) {
+            if (!isTRUE(silent)) {
                 warning(paste(primary_id," appears to be a future_series, ", 
                         "but its root cannot be found. ", 
                         "Creating _", default_type, "_ instrument instead.", sep=""))
+                if (is.null(currency)){
+                    warning('using USD as the currency')
+                    currency <- currency("USD")
+                }
                 warned <- TRUE
             }
             dargs$root_id <- pid$root
@@ -828,17 +834,23 @@
         }
     }
     if (any(pid$type == 'option')) {
-        currency <- if (!is.null(currency)) { 
-            currency 
-        } else { if (!silent) warning('using USD as the currency'); currency("USD") } 
         root <- getInstrument(pid$root,silent=TRUE,type='option')
         if (is.instrument(root) && !inherits(root, 'option_series')) {
-            return(option_series(primary_id, currency=currency, defined.by='auto', assign_i=assign_i, ...))
+            if (is.null(currency) && is.null(root[['currency']])) {
+                if (!isTRUE(silent)) warning('using USD as the currency')
+                currency <- currency("USD")
+            }
+            return(option_series(primary_id, currency=currency, 
+                                 defined.by='auto', assign_i=assign_i, ...))
         } else {
-            if (!silent) {
+            if (!isTRUE(silent)) {
                 warning(paste(primary_id," appears to be an option_series, ", 
                     "but its root cannot be found. ", 
                     "Creating _", default_type, "_ instrument instead.", sep=""))
+                if (is.null(currency)){
+                    warning('using USD as the currency')
+                    currency <- currency("USD")
+                }
                 warned <- TRUE
             }
             dargs$root_id <- pid$root



More information about the Blotter-commits mailing list