[R-SIG-Finance] Fwd: Error in addTxn - Quantstrat
Daniel Cegiełka
daniel.cegielka at gmail.com
Wed May 24 21:37:17 CEST 2017
---------- Forwarded message ----------
ok, I found a bug.
https://github.com/braverock/blotter/blob/master/R/addTxn.R#L81
as.Date("2017-01-01") return time-based object:
if(!is.timeBased(TxnDate) ){
TxnDate<-as.POSIXct(TxnDate)
}
and TxnDate != POSIXct
Best,
Daniel
-------------- next part --------------
diff -urN blotter.orig/R/addTxn.R blotter/R/addTxn.R
--- blotter.orig/R/addTxn.R 2017-05-24 21:24:42.000000000 +0200
+++ blotter/R/addTxn.R 2017-05-24 21:27:01.000000000 +0200
@@ -78,9 +78,10 @@
PrevPosQty = getPosQty(pname, Symbol, TxnDate)
- if(!is.timeBased(TxnDate) ){
+ if(is.timeBased(TxnDate) ){
TxnDate<-as.POSIXct(TxnDate)
- }
+ } else
+ stop("TxnDate requires an appropriate time-based object")
lastTxnDate <- end(Portfolio$symbols[[Symbol]]$txn)
if (TxnDate < lastTxnDate) {
More information about the R-SIG-Finance
mailing list