[Blotter-commits] r868 - in pkg/FinancialInstrument: . R
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Fri Dec 9 00:24:24 CET 2011
Author: gsee
Date: 2011-12-09 00:24:24 +0100 (Fri, 09 Dec 2011)
New Revision: 868
Modified:
pkg/FinancialInstrument/DESCRIPTION
pkg/FinancialInstrument/R/redenominate.R
Log:
- put column with higher frequency data first in cbind. Thanks Brian
- only return rows that original x had; if rate has more rows, filter
out the rows at the end that were na.locf'ed.
Modified: pkg/FinancialInstrument/DESCRIPTION
===================================================================
--- pkg/FinancialInstrument/DESCRIPTION 2011-12-08 19:10:53 UTC (rev 867)
+++ pkg/FinancialInstrument/DESCRIPTION 2011-12-08 23:24:24 UTC (rev 868)
@@ -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.7
+Version: 0.9.8
URL: https://r-forge.r-project.org/projects/blotter/
Date: $Date$
Depends:
Modified: pkg/FinancialInstrument/R/redenominate.R
===================================================================
--- pkg/FinancialInstrument/R/redenominate.R 2011-12-08 19:10:53 UTC (rev 867)
+++ pkg/FinancialInstrument/R/redenominate.R 2011-12-08 23:24:24 UTC (rev 868)
@@ -319,6 +319,7 @@
}
if (is.character(x)) x <- get(Symbol,pos=env)
}
+ idxx <- index(x)
#Now figure out the exchange rate
#First assume that both bases are currencies, and look for an exchange rate
rate <- try(.get_rate(new_base,old_base,env),silent=TRUE) #try with formats like EURUSD, EUR.USD, EUR/USD, and their inverses
@@ -356,15 +357,15 @@
# If you have intraday data for x and daily data for rate
# use the daily rate for all rows of each day.
if (periodicity(x)$frequency < 86400 && periodicity(rate)$frequency >= 86400) {
- df <- cbind(rate, x, all=TRUE)
- df <- df[paste(max(start(rate),start(x)), "::", sep="")]
+ df <- cbind(x, rate, all=TRUE)
df <- na.locf(df,na.rm=TRUE)
- rate <- df[,1:NCOL(rate)]
- x <- df[,(NCOL(rate)+1):NCOL(df)]
+ x <- df[, 1:NCOL(x)]
+ rate <- df[, (NCOL(x)+1):NCOL(df)]
}
ff <- merge(rate,x,all=FALSE)
ff <- na.omit(ff)
+ ff <- ff[idxx]
rate <- ff[,1:NCOL(rate)]
x <- ff[,(NCOL(rate)+1):NCOL(ff)]
More information about the Blotter-commits
mailing list