[Blotter-commits] r173 - pkg/blotter/R
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Sun Jan 17 15:41:23 CET 2010
Author: braverock
Date: 2010-01-17 15:41:23 +0100 (Sun, 17 Jan 2010)
New Revision: 173
Modified:
pkg/blotter/R/updatePosPL.R
Log:
- make updatePosPL robust to lack of price data, iterating until it has data without fatal error
Modified: pkg/blotter/R/updatePosPL.R
===================================================================
--- pkg/blotter/R/updatePosPL.R 2010-01-16 10:04:19 UTC (rev 172)
+++ pkg/blotter/R/updatePosPL.R 2010-01-17 14:41:23 UTC (rev 173)
@@ -43,6 +43,9 @@
# if(i>1) # if it isn't the first price in the time series
#PrevDate = time(Prices[grep(CurrentDate,time(Prices))-1])
PrevDate = time(Prices[Prices[CurrentDate,which.i=TRUE]-1]) # which.i is new in [.xts
+ if (length(PrevDate)==0) next() #no price data, keep looking
+ # NOTE the line above iterates to the next Date in the Dates collection,
+ # this can be the case as with contract rolls, or missing data. price data may not cover the entire period
PrevDateWidth = xts:::.parseISO8601(PrevDate)
PrevDateLast = PrevDateWidth$last.time
PriorPrevDate = time(Prices[Prices[CurrentDate,which.i=TRUE]-1])
More information about the Blotter-commits
mailing list