Bubble sort: how to bring order to chaos on financial markets

How to be a stock market genius (OK, perhaps a little hyberbolic)

Idea: bubble sorting: one of the first things they used to teach in programming, i.e., in a list of items try them against each other and see which ones “float” to the surface. After a maximum of n-1 iterations the ranking is finished.

Summary: Find your style of investing, including asset classes, ranking principles etc.. Then start bubble sorting the alternatives in your domain. Put your top choices in the portfolio. The rest is details (sizing, stop-loss etc.)

No matter your level, you can bubble sort your alternatives and avoid being paralyzed of too many choices. If you know nothing at all, just list a handful of industries or stocks that you come to think of. Compare one of them with all the others, one at a time, letting it sink to the bottom if it keeps losing out. The best alternatives (based on your comparison criteria, whether it be charts, valuation, business idea, owners, founders or what have you) will “float” to the top like a bubble.

Hard made easy

Do you sometimes find it hard to know where to begin when choosing investments among the thousands of alternatives that exist? Just begin anywhere, make a list of what springs to mind and bubble sort the list. Add more items and bubble sort those. There, a complicated problem is suddenly made ridiculously easy and mechanistic.

Guidelines for bubble sorting

Start with a “universe” of investables – however you define that. The rest is just a question of ranking them and deciding how many of the top alternatives to invest in.

  1. Choose method, style, assets and time frame, including how much time you’ll spend on your investing and how much of your portfolio will go into a certain asset class
    1. Style
      1. Value (the only style as far as I’m concerned; what cash flows will the company’s assets produce to me, regardless of what others think they’re worth)
      2. Trend, model (identifying fads, hoping to sell to bigger fools, based on charts, stats and math)
      3. Derivatives (fundamental, technical, arbitrage or perhaps some other strategy; not for beginners)
      4. Special situations (ahead or after earnings, take overs, news etc.)
      5. Arbitrage (taking advantage of market imperfections)
    2. Asset class (don’t limit yourself to stocks, in particular public, domestic stocks) 
      1. Stocks
      2. Bonds
      3. Commodities
      4. Currencies
      5. Private equity
      6. Real estate
      7. Precious metals
    3. Time horizon
      1. Investor (years)
      2. Swing trader (weeks)
      3. Day trader (minutes)
      4. High Frequency (micro seconds)
  2. Bubble sort, e.g., industries and then stocks within industries (e.g., 5-7 industries, and then let 1-2 stocks per industry bubble to the top)
    1. Industry based on view of macro picture (see below)
    2. Relative multiples (see this previous article for more on relative multiples)
      1. PE, PS, yield, P/B, PEG (and many more; you find multiples you like and trust)
    3. Absolute measures
      1. Growth rate, DCF valuation, various multiples, ROE
  3.  Market (it might be worthwhile taking the general market into account, but remember that individual stocks trump markets):
    1.  trend (go with the trend, if possible)
    2. internals (be careful if technicals look shaky from a historical perspective; divergence between various gauges instead convergence caused by indiscriminate risk seeking)
    3. valuation (if the market is ridiculously expensive and set for a correction, perhaps avoid going all in on your investments)
    4. exhaustion gap (Hussman recently wrote about peak signals such as exhaustion gaps close to all time highs)
  4. Macro:
    1. central banks (easing or hiking cycle; when do you prefer to take more risk?)
    2. GDP (growth tail winds can’t hurt… unless they can)
    3. point in cycle (long in the tooth, or new and shaky?)
  5. Details:
    1. stop loss (well, do you want one? Do you feel lucky? Well, do ya, punk?!)
    2. stop profit (my own invention, I don’t like the idea of letting profits run)
    3. sizing (size according to knowledge, level of certainty, form…)
  6. Read these books:
    1. Margin Of Safety (mindset)
    2. The Most Important Thing (risk)
    3. Reminiscences of a stock operator (execution, holism)
    4. possibly Valuation, by Copeland (math)
    5. or The Intelligent Investor (booooring but perhaps useful basics for beginners)
    6. TAOS (my own psychological framework: The Art Of Sprezzatura)
    7. The Retarded Hedgefund Manager (my own book about 15 years at a successful hedge fund)
  7. Find a few blogs or newsletters you like, e.g.,
    1. Hussman (clear and instructive, lots of useful charts and thoughtful comments on macro, valuation, financial history and more)
    2. GMO
    3. Marks’ Memos
    4. Find your own favorites
  8. Start small, make your big bets later when you are more knowledgable. There’s no need to hurry
  9. Document every decision in a way that can be evaluated afterward on other parameters than profit/loss or volatility
  10. Read up on my other articles on investing, such as this one on portfolio construction. You’ll find the rest here under Investments

P.S. Bubble sort your final portfolio as well as the individual stocks vs. a market index. If they don’t beat the index why would you bother with individual stocks? And, if all your components are better than the index, why not buy more and short the index against the portfolio?

Final thoughts: try it, it’s fun and easy

Start easy. Take your current portfolio. Bubble sort it; try them against each other until you know which one you’d sell now if you had to, and which one to double up on if you had to.

If you have more than ten holdings, do that; sell the bottom one and double up on your best holding (unless you already have an outsize holding).

Next up: bubble sort the 10-20 stock market industries or 5-7 sectors. Which 5-7 sectors would you want to hold the most? Bubble sort within each of those industries and find the 1-2 stocks within each industry you prefer. Take those stocks and bubble sort them. Invest in the top 8 stocks, but make sure they belong to a minimum of 4 industries.



  1. Hej!
    I just discovered you through the CapEx podcasts and am starting to dig into your writings. Did you hear that Grant’s Interest Rate Observer recently launched a podcast? It’s called “Grant’s Podcast” and is available on iTunes. I’m guessing you’d enjoy it if you aren’t already listening to it.

  2. Hi Mikael.

    After having read you for a while I never thought you were much of a technician. Are you? The guys from Macrovoices which I discovered through your blog also seem to be (I always sigh when they talk about what I think are irrelevant levels in oil, gold or the dollar index in their initial commentary).

    Also after reading half of this Hussmanfunds article on Exhaustion gaps it all seems to me like trying to find patterns where they don’t exist and a bit of confirmation bias. I don’t even agree with the definition of gap or the fact that they signal investor desperation after large prior moves in the same direction.

    I like your writing and life hacks though. When will you post more about your current investments?


    • Hi. Coming soon. I had planned to go through my portfolio and the underlying reasoning in one of the first posts for June. So, stay tuned.

      I hear you regarding technicals. Ever since business school my mantra has been “TA is like reading tea leaves”, and all my money has been made on fundamentals. On the other hand, I’ve witnessed the rise of trend following/pattern recognition/machine learning algo funds over the last 15-20 years. My conclusion is that you should always first apply a fundamental filter, and then see if technicals can improve your entry/exit points in the stocks that qualified fundamentally.

      The exhaustion gap letter is just one single point of curiosity on top of Hussman’s real analysis. It’s not important, but it’s interesting to see that that kind of upside gaps at least haven’t worked as bullish signals at similar points in market history – quite the opposite.

Leave a Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.