New error thrown by Correl Function

In screen, for example:
https://www.portfolio123.com/app/screen/summary/236677?st=1&mt=1

Correl(10,50#Sector)<1 & Correl(10,50,#Industry)<1

Throws error:

ERROR: Encountered error in Rule 1: Not enough samples in the ‘series’ parameter

Was working up until a couple days ago…

We added two safety features to Correl()

  1. an error is generated if there aren’t at least 80% of the # of samples you request in the ‘series’ parameters.
  2. if the stock being analyzed doesn’t have at least 80% of the # of samples returns NA (previously it was returning a value if it had at least 3 samples, which is likely meaningless to you).

In you case you are requesting the correlation coefficient for 50 samples of 10 bar return which requires a time series of 500 bars. The Industry “Interactive Media & Services” with GICS 502030, does not have 500 bars. It was created 9/30/18. You can avoid the error by adding a rule like “close(500,#industry) != NA” , which will exclude that industry.

However…

Not sure the rule makes much sense. What were you trying to do ? Correl() returns a value between -1 to +1 so you are not excluding anything. You can see the values by running a screen with the rule below then click on “Screen Factors” for the report. You’ll see coefficients between -1 and +1 and N/As.

showvar(@s,Correl(10,50,#Sector)) or showvar(@i,Correl(10,50,#Industry))

PS. I updated the documentation to include the new safety features

Thanks for the quick reply-
Yes, I do not actually use 1 for the threshold (Max correl value), just wanted to demonstrate the error message occured under loose conditions…
I will try your fix-

Steve

Is there a reason not to return NA for these conditions? I think I would rather handle incomplete cases by wrapping Correl in isNA.

Walter

NA is returned for case 2. The stock being analyzed is too short.

Case 1 is very different. In case 1 the “series” that you are specifying as the benchmark against which all coefficients will be calculated doesn’t have at least 80% of the samples. Seems like a major issue that should not go quietly

Throwing an error concerns me. Maybe unduly. If a new Industry classifications occurs, what would happen to a live port? Would it error out?

Well if you are using Correl then it must be important to the system. I think generating an error will make you fully aware of things. You can then decide what to do with those stock, either reduce the samples or screen them out

Btw, I noticed this problem bc I was looking for etfs with high correlation with AAPL and the top ones made no sense since they were very short and used very few samples. If I was doing this in a simulation I would have never noticed.

We’ll have to disagree on this one.

NA can be handled by the system with isNA; errors can’t be handled like that. I would hate to see a live port die b/c a new industry appeared - which is what I expect would happen. Then I would need to scan my ports for those that didn’t update. Ugh. Maybe I have that wrong.

Walter

EDIT: And what would happen if Correl were used in a ranking system? How are errors handled there?