|
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. |
|
On Tue, 2012-05-15 at 12:43 -0700, algotr8der wrote:
> 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. The startDate on your *portfolio* and *account* need to be before the first trade in any instrument. You need to have market data for *at least one observation* before the first trade in that instrument, so that we have something to mark against. I'm not aware of any restriction that you need data for all the same dates/times, in fact, it was designed to not need this. We pretty routinely include contracts that expire in a larger portfolio, for example. This error: 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 suggests that you have a position for AKAM. There is one simplification in the code that I am aware of that might cause something similar. You could make it go away by putting the symbol that has the longest time series *first* in your portfolio. If that doesn't work, I can work with you off-list to try to find and fix the problem. Regards, - Brian -- Brian G. Peterson http://braverock.com/brian/ Ph: 773-459-4973 IM: bgpbraverock _______________________________________________ [hidden email] mailing list https://stat.ethz.ch/mailman/listinfo/r-sig-finance -- Subscriber-posting only. If you want to post, subscribe first. -- Also note that this is not the r-help list where general R questions should go. |
| Powered by Nabble | Edit this page |
