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

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Mon Jul 11 02:05:09 CEST 2011


Author: gsee
Date: 2011-07-11 02:05:08 +0200 (Mon, 11 Jul 2011)
New Revision: 671

Modified:
   pkg/FinancialInstrument/R/redenominate.R
Log:
 dont use getPrice if it is univariate.

Modified: pkg/FinancialInstrument/R/redenominate.R
===================================================================
--- pkg/FinancialInstrument/R/redenominate.R	2011-07-10 20:16:02 UTC (rev 670)
+++ pkg/FinancialInstrument/R/redenominate.R	2011-07-11 00:05:08 UTC (rev 671)
@@ -179,7 +179,9 @@
     } else if (periodicity(x1)$frequency >= 86400) { 
         #if daily or slower use OHLC and Mid
         if (is.OHLC(x1)) { #If first leg is.OHLC, 2nd leg will be univariate
-            div <- if (has.Mid(x2)) {
+            div <- if (NCOL(x2) == 1) {
+                        x2
+                   } else if (has.Mid(x2)) {
                         Mid(x2)
                    } else getPrice(x2)
             rat <- x1[,1] / div
@@ -189,7 +191,9 @@
                 }
             }
         } else if (is.OHLC(x2)) { #1st leg will be univariate
-            num <- if (has.Mid(x1)) {
+            num <- if (NCOL(x1) == 1){
+                        x1
+                    } else if (has.Mid(x1)) {
                         Mid(x1)
                     } else getPrice(x1)
             rat <- num / x2[,1]
@@ -202,7 +206,9 @@
     } else if (periodicity(x1)$frequency < 86400) {
         #if intraday, use BAM and Cl
         if (is.BBO(x1)) { #1st leg is.BBO, 2nd leg will be univariate
-            div <- if (has.Cl(x2)) {
+            div <- if (NCOL(x2) == 1) {
+                        x2
+                    } else if (has.Cl(x2)) {
                         Cl(x2)
                     } else if (has.Ad(x2)) {
                         Ad(x2)    
@@ -214,7 +220,9 @@
                 }
             }
         } else if (is.BBO(x2)) { #1st leg will be univariate
-            num <- if (has.Cl(x1)) {
+            num <- if (NCOL(x1) == 1) {
+                        x1
+                    } else if (has.Cl(x1)) {
                         Cl(x1)
                     } else if (has.Ad(x1)) {
                         Ad(x1)



More information about the Blotter-commits mailing list