Bars since PeriodDateQ ?

How to get the price of a stock on its latest reporting period in a simulation?

Bars since PeriodDateQ looks to be the requirement, but how to calculate these bars from a date that is reported as YYYYMMDD?

Thanks in advance for your help!

There is no function like “Today()”, so it is impossible to do that even if you could convert YYYYMMDD into a serial data (which is possible, but not a pretty transformation).

You can estimate though:

Close(0,Trunc(WeeksIntoQ*(251/52)))

Since there are 251 bars in a year and 52 weeks in a year, there are about 4.827 bars in a week.

Looks WeeksIntoQ counts the weeks since the filing date instead of the reporting period.

E.g.
Ticker(“BKNG”) has WeeksIntoQ=2 and PeriodDateQ=20171231.
In this case the number of bars since 2017-12-31 is required which is a lot more than the 2 weeks since its filing.

Still looking for a solution. Suggestions are welcome. Thanks!

The lack of bar counting functionality on P123 is a pet peeve of mine. Here is my feature request asking for such a function.

As a workaround a business days calculator might be useful if you know the date to determine an offset value to use. An example of such a calculator.

indeed some form of date math or bar counting is sorely needed…

Yes. Please also the two related requests:

Feature Request: Function to call screen’s “of as” date

Feature Request: Functions to work with serial dates

Let us vote in favor of these date related requests.

Seems that the Point-In-Time dates available to P123 are currently not accessible in a meaningful way.

For now a function like “WeeksIntoP”/“WeeksIntoPeriod”, or even better a “BarsIntoP”/“BarsIntoPeriod”, would help.

What is P123 stance on this?

Three new functions have now been added for handling dates. They can be found in the reference under MISC/UTILITY/Date.
Give them a try: [font=courier new]DaysSince(date)[/font], [font=courier new]BarsSince(date)[/font], and [font=courier new]DaysDiff(from, to)[/font].

These can be used in conjunction with any date factor, but be aware that [font=courier new]DaysSince[/font] and [font=courier new]BarsSince[/font] will yield [font=courier new]NA[/font] for future dates.
For example, [font=courier new]BarsSince(LatestPeriodDate)[/font] currently yields [font=courier new]NA[/font] for TGLT, because [font=courier new]LatestPeriodDate[/font] currently yields 2018-03-31.

whooohooo… thanks Aaron

Aaron, would it be possible to specify a date (1/2/2018)…in DateSince and in other date functions?

Thanks

Nevermind…it works with yyyymmdd

This is great, thanks

Thanks a lot!!!

Since DaysSince and BarsSince already yield NA for invalid input, a case might be made to change them to yield -1 instead of NA for future date input. This could improve its robustness when having to handle these various cases. If anyone thinks this is a good idea, let me know.

Aaron,

Your suggestion seems to make sense. What about taking it one step further and just keep the count, but go negative into the future? E.g. -5 for 5 days/bars from now. That way no data is lost.

Thanks again, also for this suggestion!

Edit: Looks that in this case there is no risk for any look ahead bias as would be with close(-5).

One more thing, how can a future date for “LatestPeriodDate” be explained? Is this an anomaly or data error? IPO?

I did a few samples with the screener going back in time, but, for these samples, did not notice any companies with “LatestPeriodDate” in the future.

That’s kablamo, Aaron. Thanks for adding this sorely needed functionality. Now I will proceed to spend countless hours figuring out how I can use it to improve my stuff.

It seems to be a data error with TLGT that has since been resolved, but the result is cached on our system.
DaysSince and BarsSince will be revised to yield -1 for future dates.

NA seems a better representation if future dates are errors. What do you think?

It does seem like an incredibly unusual situation for us to support, especially since none of the date factors should behave that way.
And I suppose supporting it would allow for bizarre computations if a negative value is involved. It should probably just yield NA after all.

Dear P123 Staff,

There are scenarios when [font=courier new]LatestPeriodDate()[/font] extends to future dates. For example, TransMontaigne Partners (TLP) shows a date of [font=courier new]20181231[/font]. My suspicion is that future dates are more frequent towards earnings seasons. This behavior appears to be consistent with its definition:

For this reason, I would like to request support for future dates. I realize that adding that support for [font=courier new]DaysSince()[/font] and [font=courier new]BarsSince()[/font] may result in ambiguous syntax as since implies past perfect.

As an alternative, it seems preferable to provide an alias for the numerical value for [font=courier new]Today()[/font]. Since support for future dates (i.e., -ve values) is already available for [font=courier new]DaysDiff(from, to)[/font], we just need to be able to anchor either of the parameters to a known date.

(Maybe this is also a good place to ask for for [font=courier new]BarsDiff(from, to)[/font]???)

Thank you for your consideration.

//dpa

I have been using ShowVar(@myvar,Year10000+Month100+ MonthDay)…for today
DateDiff seems to be accepting that variable/value for whatever I have tested