COOL: custom formula enhancements

Dear All,

As you may know custom formulas (located in TOOLS->CUSTOM FORMULAS) allow you to re-use your long complex formulas . However there were some key limitations that made them not very useful. We made the following upgrades:

  • You can now call a custom formula from within a custom formula. For example you can define these custom formulas:

$ttm= SalesTTM
$ptm= SalesPTM
$24mo = $ttm + $ptm

  • We no longer check for syntax when you write a custom formula. We only check for syntax at run-time. This allows you create custom formulas for any of our functions, like

$pr2sDESC = FRank(“Pr2SalesTTM”,#All,#DESC)

These enhancements take care of the following feature requests:
https://www.portfolio123.com/feature_request.jsp?featureReqID=966
https://www.portfolio123.com/feature_request.jsp?featureReqID=970
https://www.portfolio123.com/feature_request.jsp?featureReqID=1257

Thank for your suggestions & feeback.

Oh my, I just tried using a custom formula in Fundamental Charts and it works! Is that a consequence of the custom formula enhancement?

Walter

Yes. We now need to display them in the reference within Fundamental Chart. Thanks

I have an open feature request w/r/t custom formula in Fundamental Charts. That may be closed now.

Walter

Just some early glances and playing around with it, but looking at custom forumulas in Fundamental Charts is really cool.

Excellent addition Marco.
Thank you.

Thank you Marco.

Marco & Co.,

This is a very useful enhancement. Thank you. I don’t want to be a whiner, but it would be perfect if I could call a custom formula within a custom formula (rather than being restricted to calling P123 functions). Is that out of the question due to compute demands, or might we expect this at some point in the future?

D

D ? What you describe is possible

Ah, I thought $CustomVar was rejected. Will try again. Great news, thanks!

Tripped up by a silly syntax error. This is very cool indeed. Thank you.

Setting up default values sorta works, custom formula SMA2SMA defined as;

SMA(isNA(@FAST,20),0)>SMA(isNA(@SLOW,40),0)

will correctly receive values when (buy) rules like this are used;

SetVar(@FAST,10) & SetVar(@SLOW,100)
Eval($SMA2SMA,FRank("BetaFunc(1,20)",#All,#Asc)>20,True)

However, if you want a default value to be used, you must do something like;

SetVar(@FAST,NA) & SetVar(@SLOW,100) // @FAST is now set to 20 the custom formula default value
Eval($SMA2SMA,FRank("BetaFunc(1,20)",#All,#Asc)>20,True)

Leaving either @FAST or @SLOW undefined in the rules section results in an error.

Maybe someday we can have an isND - Is not Defined - function available.

Best,
Walter

I had the idea that calling custom variables from other custom variables could allow me to do complex valuations from the ranking system tool. Formerly, I did this in the Screener. While I could easily screen for performance within a pre-set quantile (e.g., @Rank > 90 AND @Rank <= 100) or value (e.g., @FairVal / MktCap > 1.2), it is incredible time consuming to run the screen 10 or 20 times to get the histogram output as the ranking system. It is also computationally 10-20x more expensive to do so.

When I attempt to replicate this process using chained series’ of custom variables, and depending on the custom variable I’m trying to call, one of four things happens:

  1. In the screener, it takes a very long time to get a response.

  2. In the ranking system, I get an error, “Error generating graph: Could not get rank data”.

  3. In the screener or ranking system, nothing happens. After I run a screen and get no feedback from the system, I will try to run a simple call and the system returns, “ERROR: You have a ‘Screen Tot’ request in progress. Please try again later.” It usually takes more than 1 minute for this error to clear.

  4. Or, for more complex custom formula, “Could not find uid 709 in function FSum – map size is 0”.

My original intent was to see how a comprehensive valuation system (i.e., outputs one number representing fair value) would stack up against a traditional ranking system comprised of many inputs. Which method is superior?

I may have to give up on that dream for now.

Any suggestions or ideas for workarounds are welcome. One idea might be to invoke a histogram from the screener, much how the correlation matrix currently works. This would in effect combine the functionality of the screener and ranking system into one all-powerful research tool.


Addendum:

This would also be possible I think if the ranking system had a function for getting the value of a previously declared node (vice the rank as “NodeRank()”).

//dpa

I think I figure out an enhancement for the custom formula for some point in the future:

It appears that a custom formula calls every variable individually as it parses through the equation. If a variable appears more than once, it will try to retrieve on as many occasions. This is not at all efficient.

Instead, it probably makes more sense to parse the entire string for unique variables, then pull those into RAM for quicker access while the routine is running.

Sorry to get in the weeds on this, but I am still figuring out if its possible to implement my model in P123.