I wrote a computer program that logs into my account daily and screen scrapes my balance and data for 100 or so funds available through my employer 401k plan. I have 3 or so years worth of this data. I get the fund, daily share price, daily net change, and the yearly return.

What can I do with this data to help form an investing strategy that will help keep my returns consistently positive (hopefully) and avoid loses during a recession? I lost half my 401k during the 2008 recession.

I want to write a computer program that will analyze the data and make suggestions that I will review monthly. I'm looking for algorithms or functions/equations that I can use that will warn me that I need to reallocate my investments, find good funds that are down and rising, find funds that I'm invested in that are starting to under perform, etc.

  • Do you have the expense ratio data? Morningstar - that organization that reviews funds on a five star basis - published a report showing that choosing funds with the lowest expense ratio out-performed choosing funds with high Morningstar ratios.
    – justkt
    Dec 6, 2010 at 16:42
  • @justkt could you add a link to that report?
    – GUI Junkie
    Dec 6, 2010 at 16:58
  • 1
    @GUI - here you go, here's everything with the caveats from Morningstar and all - advisor.morningstar.com/articles/…
    – justkt
    Dec 6, 2010 at 17:00
  • Cheers @justkt, that's fast. I'm reading now.
    – GUI Junkie
    Dec 6, 2010 at 17:08
  • "I lost half my 401k during the 2008 recession." Did you really? Did you sell at a time where it wouldn't have been wise to have sold?
    – glglgl
    Aug 2, 2022 at 14:37

3 Answers 3


Trying to beat the market is a fools game. There are a lot of people out there with a lot more money, time, and experience than you have, and they cannot do it either. Just by luck, some of them will, but it is impossible to tell which ones those will be beforehand. Most mutual funds also have policies that discourage buying and selling often. If this is a retirement account, you probably don't have to deal with commissions for buying/selling, but in a taxable account that is also a consideration.

My suggestion is to decide on a basic asset allocation (US stocks, international stocks, and bonds to start), pick some index funds, and rebalance every 12-18 months. Other than that, don't pay much attention to the daily ups and downs.


Interesting question. Morningstar 4 or 5 star rated funds should be your aim. Unless I'm mistaken, Morningstar rates based on time vs index. Meaning a 3 star rated fund performs consistently like the index the compete against in the last 3 to 5 years.

If you want to develop your own algorithm, you should be looking at their star rating algorithm.

You have to look at performance during the last 3, 6, 12 months as well as 3 - 5 years against their index. Look at sectors, geographies, P/E, dividends... etc.

  • 1
    I disagree with with the value of morning star ratings. Many times it seems a fund earns a 4 or 5 star rating, only to do poorly relative to other funds of that type and inch back down the star scale. The results seem pretty random, and there's no guarantee that investing only in 4 and 5 star funds will will be any better than ignoring their stars altogether.
    – Patches
    Dec 31, 2011 at 1:50
  • I'm not sure how Morningstar does their ratings, but it should be related to historic returns. This does not guarantee future results, but it's better than random. The real problem is picking the right sector. Suppose you bought a fund in the housing sector. Maybe the fund is 5 star because it lost only -15% instead of -40% of the index.
    – GUI Junkie
    Dec 31, 2011 at 11:07

The kind of strategy that you want to do is called a fund upgrading strategy. The people that do that all have their own formulas, but generally, it revolves around comparing relative strength of the short term (3-month and 6 month) against the medium term (1-year, 3-year). They then also have rules to keep the results sensible -- like picking the best of of a certain sector that's doing well, and not all of them. For instance, when gold does well, you wouldn't want to end up with a portfolio of 5 funds all involved with gold -- a sudden price shock to gold would crater the portfolio.

Incidentally, there are a variety of investment newsletters that do an upgrading strategy. The best of these is NoLoad FundX Newsletter http://www.fundx.com/customerhome.aspx . It's been rated by Hulbert's as the best performing investment newsletter over just about any time period going out to 30 years. That's best performing newsletter period, not best performing of this strategy.

(Full disclosure: they started a mutual fund, FUNDX, about 10 years ago that uses their strategy. I own some shares in FUNDX the mutual fund.)

Ok, so, what to do with all this nice data you collected? I can't give you some formula that you can plug in and walk away. I do have some suggestions on how to build out your stratagy, though.

Clean the List:
First, clean that list of 100 mutual funds. Exclude any that you would not want to invest in, regardless of what the numbers say. Some ideas of what you could exclude: over specialized sector funds, active funds where the manager's recently left (thus making historical returns irrelevant), funds that, when you look at their prospectus just make you feel skeevy (your gut can sometimes pick up on incompetent BS artists where your head can't).

Second, categorize & group the remaining funds by investment style, sector, etc. This is so when you do have an investment signal from the strategy, you can avoid investing in duplicates.

Build the strategy
Let me start by saying that you should never finish this process. First because you can never know if you're right until after the fact, and second because the success rate of a set strategy will change over time. So, even after you've started investing with this, periodically come back and test new ideas, formula tweaks, etc.

Set yourself up with a good testing environment. You want to be able to run "what if I had invested this way" scenarios on your ideas to see what would have worked. So, either get a good back testing service, or create your own (you did say you were screen scrapping and stuff, so I'm sure you can program one:-) ).

Spend more effort on figuring out when to sell a fund rather than buy one. I was reading in one of Donald Trump's books (speaking of BS artists), something that stuck with me as wise: "Take care of the downside and the upside will take care of itself". So, when you run your scenarios, you're not looking for the one that would have made you the most money. After all, historical data is hindsight. You can tweak it to death to get the tippy-top return in hindsight, but the resulting strategy would have no bearing on reality going forward.

Instead, look for results that get a reasonable return, but minimize the drawdown (losses) and volatility (whipsawing) along the way. You want the strategy with the least drawdown and volatility for a given level of annual average return.

Start with a basic strategy, then theorize/build/test/tweak from there. For instance: invest when 3-month RSI exceeds 6-month, and 1-year exceeds 3-year, avoiding duplicates. Sell when 3-month RSI drops below 6-month RSI. See how that looks in testing, and go from there.

Final note:
Make sure that that data you've collected accounts for dividends. Remember that when you receive dividends from a mutual fund (which are no doubt auto-reinvested) the price per share goes down by that amount, but you didn't lose anything. Depending on the fund, that can make a huge difference in change-in-price vs. actual-gain over time.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .