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

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Fri Dec 23 16:45:13 CET 2011


Author: gsee
Date: 2011-12-23 16:45:12 +0100 (Fri, 23 Dec 2011)
New Revision: 891

Modified:
   pkg/FinancialInstrument/DESCRIPTION
   pkg/FinancialInstrument/R/instrument.R
Log:
 if currency is not specified and instrument.auto is creating a future_series or option_series, USD will be used

Modified: pkg/FinancialInstrument/DESCRIPTION
===================================================================
--- pkg/FinancialInstrument/DESCRIPTION	2011-12-23 15:32:27 UTC (rev 890)
+++ pkg/FinancialInstrument/DESCRIPTION	2011-12-23 15:45:12 UTC (rev 891)
@@ -11,7 +11,7 @@
     meta-data and relationships. Provides support for
     multi-asset class and multi-currency portfolios. Still
     in heavy development.
-Version: 0.9.17
+Version: 0.9.18
 URL: https://r-forge.r-project.org/projects/blotter/
 Date: $Date$
 Depends:

Modified: pkg/FinancialInstrument/R/instrument.R
===================================================================
--- pkg/FinancialInstrument/R/instrument.R	2011-12-23 15:32:27 UTC (rev 890)
+++ pkg/FinancialInstrument/R/instrument.R	2011-12-23 15:45:12 UTC (rev 891)
@@ -733,7 +733,7 @@
                 "and it will not be auto defined because it does not appear to be valid."))
         currency(currency)    
         if (!silent) cat(paste('Created currency', currency,'because it was not defined.\n'))
-    }
+    } 
     warned <- FALSE
     dargs <- list(...)    
     pid <- parse_id(primary_id, root=root)
@@ -762,9 +762,12 @@
         }
     }
     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,defined.by='auto', assign_i=assign_i,...))
+            return(future_series(primary_id, currency=currency, defined.by='auto', assign_i=assign_i,...))
         } else {
             if (!silent) {
                 warning(paste(primary_id," appears to be a future_series, ", 
@@ -778,9 +781,12 @@
         }
     }
     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, defined.by='auto', assign_i=assign_i, ...))
+            return(option_series(primary_id, currency=currency, defined.by='auto', assign_i=assign_i, ...))
         } else {
             if (!silent) {
                 warning(paste(primary_id," appears to be an option_series, ", 
@@ -834,7 +840,9 @@
     ss <- ss[!ss %in% ""]
     if (length(ss) == 2) primary_id <- paste(ss,collapse="_")
     dargs$primary_id <- primary_id
-    dargs$currency <- if (!is.null(currency)) { currency } else { warning('using USD as the currency'); "USD" }
+    dargs$currency <- if (!is.null(currency)) { 
+        currency 
+    } else { if (!silent) warning('using USD as the currency'); currency("USD") } 
     dargs$multiplier <- multiplier
     dargs$defined.by='auto'
     dargs$assign_i <- assign_i



More information about the Blotter-commits mailing list