[R-SIG-Finance] blotter: updatePortf Error in call to updatePosPL when instrument has no price

algotr8der algotr8der at gmail.com
Tue May 15 21:43:57 CEST 2012


I am backtesting an intraday strategy (using daily bars) that trades a list
of equities. The system begins testing on 1999-05-13 but not every equity
has a price for that date because some of the names listed at some point in
the future (i.e. GOOG for example).

The problem is updatePortf  pukes when it finds a stock that does not have a
price.

Error in if (is.na(tmpPL$Prices[1])) { : argument is of length zero
In addition: Warning messages:
1: In .updatePosPL(Portfolio = pname, Symbol = as.character(symbol),  :
  no Prices available for AKAM in 1999-05-12 23:59:59::1999-05-13 23:59:59 :
using last available price and marking to 1999-05-13 23:59:59
2: In is.na(tmpPL$Prices[1]) :
  is.na() applied to non-(list or vector) of type 'NULL'
> traceback()
2: .updatePosPL(Portfolio = pname, Symbol = as.character(symbol),
       Dates = Dates, Prices = Prices, ... = ...)
1: updatePortf(portfolio, Dates = CurrentDate) at #25

This is exactly the same issue as that found here:

http://r.789695.n4.nabble.com/quantstrat-getting-an-error-when-using-many-symbols-and-based-order-sizing-function-td4398323.html#a4427842

I don't think its desirable to cut the testing period to the shortest date
range because some of the stocks listed at a future date. I'm afraid I don't
quite understand the logic behind why updatePortf  *needs* to get a price
for a stock that has no Txns. It makes sense to me if there was a valid Txn
then updatePortf needs a price to perform a daily mark but in this case
trading can't begin on the stock in question until at least the date with
the first price.

Anyone have any interesting ways to circumvent this problem? Appreciate the
feedback. Thank you very much. 

--
View this message in context: http://r.789695.n4.nabble.com/blotter-updatePortf-Error-in-call-to-updatePosPL-when-instrument-has-no-price-tp4630176.html
Sent from the Rmetrics mailing list archive at Nabble.com.



More information about the R-SIG-Finance mailing list