NEW: Portfolio() function now available in buy/sell rules of a live portfolio

Dear All,

The Portfolio() function is now available in buy/sell rules as well as in the screener. It returns true when the stock being analyzed in the rules is a holding in other specific portfolio(s). A good use case for this functions is when multiple strategies are used to avoid buying “duplicates”.

The function was also moved, it is now located in MISC->Group->Portfolio. Below is the documentation. Let us know of any issues or feedback.

Thank You.

Portfolio(id1 [,…,id10])

Return TRUE if stock being analyzed is held in the portfolio(s). Use either the portfolio name in quotes, or the numerical id. This function is not point-in-time: it only looks at the current holdings of a portfolio or the last holdings of a simulation.

Examples

Screen for stocks in the universe that are being held in either portfolio “My Port” or the portfolio with the unique id 1230

Portfolio(1230 , “My Port”)=TRUE

Screen for stocks that are held in both portfolios “My Port” and id 1230

Portfolio(1230 ) AND Portfolio (“My Port”)

NOTE: Only portfolios owned by you can be used as parameters

Thank you, very useful function!

I’m not sure I fully understand this.

Since we can’t control the order of (live) portfolio rebalancing, for two portfolios to not have duplicate holdings, both ports will need to refer to the other with a buy rule like;

PortA Portfolio("PortB")=False
PortB Portfolio("PortA")=False

Is that right?

Walter

I have 5 ports that I trade weekly. I have a sequence that I developed for re-balancing. I now use a separate Screen that uses the Portfolio function to allow me to keep track of this. But the issue is for me that even though I do it sequentially, I still see what the other ports own that are after the one being re-balanced. Plus I look at Industry concentration at the overall portfolio level. So having this new function for me does not really help. Too many other knobs being turned as well.

Does the portfolio function also look at any pending trades scheduled with the trade tool?

If it looks only at the holdings of the previous iteration (that’s what I understand from the “not point-in time” note), this function cannot be used to avoid duplicate holdings.
If I am wrong (I hope so), we need a priority order on portfolios and resolve each conflict only once. A random order in executing Walter’s rules will give random results in simulations and live books. Imagine with 4 or 5 portfolios. Butterfly effect guaranteed.

Let me start off by pointing this out: The way that the Screen rule has worked in the past is that you can use screens to feed into another screen.

Let’s say that you have two screens, A and B. You want the top 10 of each. You’d use:

Screen("A",10) or Screen("B",10)

in a third screen.

So you should be able to use Portfolio in the same way in a portfolio:

Portfolio("A") or Portfolio("B")

in Portfolio C. Note that there’s a possibility that a single company could be in both Portfolio A and Portfolio B in which case you’ll end up with one fewer holding than you’d like.

And yes, you can use it in the way that piard2 describes, having two portfolios reference each other. BUT…

Let me lead off by saying that if you care deeply and want to dot your eyes and cross your tees, you need to do manual rebalances of all the portfolios involved. That’s the only way to guarantee that you know exactly when each of these portfolios has been rebalanced. There’s no way around it.

That said, the order of automatic portfolio rebalances is actually fairly straightforward: First, Smart Alphas. Then all automatic and semi-automatic portfolios are rebalanced in portid order (which is going to be order of creation). (And then automatic books, but it’s not important to this discussion.)

Corollary: You can’t use this in Smart Alphas. Nyahh. :slight_smile:

However that order means that you can assume that if your hypothetical PortA and PortB are fighting over hypothetical ticker ABC (and are set to automatic) then the one that is evaluated first will get the company. And the one that is evaluated first is going to be the one that was created first.

Oh, and I can verify that the function will not be looking at pending trades, only current holdings.

I find that a bit surprising. I expected job submission via a load-balancing system like LSF so that they would execute simultaneously. While LSF can be forced to execute jobs sequentially, that’s not it’s typical usage. Does P123 use LSF? Does P123 guarantee sequential execution in portID order?

Walter

If sequential execution by PortID is guaranteed, then
how about doing the portfolio rebalance by portfolio name rather than ID?
Subscribers who need to predict the rebalance order could rename their ports as AA port1, BB port2

You have a quick workaround: cloning ports in the order you want. Paul wrote IDs are in creation order.
It should work if and as long as P123 doesn’t use parallel tasks for portfolio updates. Not only the processes must be started sequentially, but we must be sure that each one is ended before starting the next one.

Concurrency is atomic per user: any given user’s portfolios are guaranteed to be rebalanced in the aforementioned order.

Very good!

Aaron, Thanks for your answer. A summary of Paul’s points and yours about priority and non-concurrency would be very useful in the “full description” of the function.

P123: would it be possible to also let us use the portfolio() function in the custom formulas? For example, we could set a custom formula for each port/book or group of ports, and then just reference the custom formula which is more meaningful than the port number. (like $BookShortName).

Hi Marco & team: any feedback?

Correction of previous feedback regarding rebalance order:
Portfolios are rebalanced in order of portfolio name, not portfolio ID.
Apologies for any troubles this may have caused.

Is anyone using this feature? I’m still unclear what [quote]
This function is not point-in-time: it only looks at the current holdings of a portfolio or the last holdings of a simulation.
[/quote] really means.

If the function literally considers only the last set of holdings, then how can it be useful in a simulation?

Walter

It is not good for sims.

It is for people who do not want 2 active ports to buy the same stock. Especially, if the 2 ports are in one book and there is not enough liquidity or they do not want to put that much money on one stock.

I have not used it yet but I keep looking at it. The problem is that the port that uses this rule is likely to take a hit in performance. And, as you say, how much of a hit cannot be easily determined by backtesting.

Thanks for the reply. In that case, Portfolio() isn’t congruent with the P123 methodology. That’s a shame.

Walter

Hi Aaron & Marco, Could you please clarify:

  1. would it be possible to also let us use the portfolio() function in the custom formulas? For example, we could set a custom formula for each port/book or group of ports, and then just reference the custom formula which is more meaningful than the port number. (like $BookShortName).
    If not, why not?
  2. could you please be a little bit more specific how this can be used in simulations, or not? or is this really only to be used for live rebalancing?

Thank you.