Sell and Buy based on Rank Position Spreads

Hi, I think I’ve seen this posted before, but can’t find the thread. Basically I’m interested in the ability to have buy and sell rules based somewhat upon the rank position spread between the best ranked un-owned stock and the worst ranked owned stock (or secondly, 2nd best ranked un-owned stock and 2nd worst ranked owned stock, etc.), and/or if the prior is too much to implement more simply condition a buy/sell of the lowest ranked stocks if there is an un-owned stock in the say the top 5 or top 10, for example:

If I own a stock with a rank position of 35 in the new ranking, but there is a new stock of rank position 5 that I don’t own, I’d like to be able to condition a buy or sell on that rank position spread of 30. For example sell Rule “rankpos_spread >=20” would get the job done, and sell any position for which there is a new position 20 rank positions better.

Again, I pretty sure there was a thread advocating for this, but am unable to locate it, and unsure what search words would be appropriate. If there is a feature request I’d like to support it as while there are many requests, this is one of the more valuable features I can envision. I’m sortof manually doing this anyhow right now, but it would be nice to systematize it better. Can anyone point recall or point me to that thread/discussion? thank you

I thought I made a feature request about a year ago to be able to sell your lowest position if and only if a higher-ranked position appears, but it seems to have disappeared. Or maybe I didn’t do it. It was the subject of a couple of threads, though. One is here:,10611#59030. Another is here:,10354#56825.

Do you want to write up a feature request or shall I?

With variable position weighting, this is no longer as crucial, in my opinion. My workaround is to permit leverage with a carry cost of 0, set the ideal number of positions (call it X) way higher than I’d ever actually own, use Y - rankpos as my position weight formula where Y is significantly less than X, use a buy rule of rankpos < Z where Z is significantly less than Y, and leave out the sell rule. This workaround means that as soon as a stock appears with a rankpos < Z it is bought, no matter how many other stocks you have in your portfolio, and you downsize your other positions as they move down the ranks.

You then have to use Excel to figure out what your actual return would have been since your posted return will reflect times when your leverage is greater than one. If you want to know how to do that I’ll tell you.

  • Yuval

Thanks Yuval, I think this is the request:

and discussion thread,10612_lastpage,yes#62599

I added your first link above to my post in the comment on the thread also as I think the ideas and discussion are quite similar.

thank you again,

Did this ever become a thing?

I’ll second that - have actually been thinking a lot about this lately and trying different rules. But if there’s a pre-built feature that would be fantastic.

Similarly - any update on the “buy-driven” simulations?