Open ignl opened 8 years ago
Your example does not run. You didn't initialize the portfolio. Even if I do that, the chart.Posn
call throws an error.
R> chart.Posn("TEST", Symbol = 'SPY')
Error in chart.Posn("TEST", Symbol = "SPY") :
no transactions/positions to chart
It might be because there's only one transaction... or because you didn't call updatePortf
. This also may be a bug with blotter, if you can't replicate this issue independent of chart.Posn
.
OK fixed it on empty environment. Not sure if its quantmod or blotter issue.
library(blotter);
currency("USD");
stock("SPY",currency="USD",multiplier=1);
initDate <- '2006-01-01';
startDate <- '2006-01-01';
endDate <- '2016-03-16';
initEq <- 10000;
suppressWarnings(try(rm(list=c("TEST", paste0("account.TEST"), paste0("portfolio.TEST")), pos=.GlobalEnv$.blotter), silent=TRUE))
initPortf("TEST", symbols="SPY", initDate=initDate)
initAcct("TEST", portfolios="TEST", initDate=initDate, initEq=initEq)
Sys.setenv(TZ = "UTC");
getSymbols('SPY', from=startDate, to=endDate, index.class="POSIXct", adjust=T)
addTxn("TEST", Symbol='SPY', TxnDate='2006-01-03', TxnPrice=SPY[1,]$SPY.Close, TxnQty = 100, TxnFees=0, verbose = TRUE)
chart.Posn("TEST", Symbol = 'SPY')
zoom_Chart("2008-01::2008-03")
I came back to work a bit with quantmod and remembered about this error as I am still getting it. Maybe you have taken a look at it? It basically fails when you try to zoom into a date range that does not have any transactions.
Ok finally found time to create reproducible example on this error which I seem to encounter randomly. On most periods zoom_Chart works but sometimes I get this error:
And here is my reproducible example: