Late last month, I sold nearly $160,000 worth of stock-based mutual funds and turned it all into certificates of deposit. That move was the largest single sale of stock based investments I have ever authorized. By making that move, I completely turned the account that held those funds to 100% cash-based holdings.

No matter what the stock market does from now on, that money will be insulated from its movements. If stocks go up, I'll miss out, but if stocks go down, that money will still be sitting there, collecting its interest along the way. For that particular account, that was the right move to make -- and I'd happily do it again.

Students in caps and gowns at a graduation ceremony.

Image source: Getty Images

Why it was the right time to sell

The account I liquidated was my daughter's 529 college savings account. I sold because she's a senior in high school and is ready to pick the college she wants to attend. With that move, I now have a pretty good idea of how much I'll have available to help her cover those costs. In addition, I'll be able to write the checks to cover those costs by their due dates, no matter what the market happens to be doing at that time.

Ultimately, that move was an asset allocation choice, based on the principle that money you need to spend in the next few years does not belong in stocks. With my daughter clearly college bound and a somewhat reasonable estimate of what her costs would be, I now have a major set of bills coming due over the next few years. That makes now a great time to liquidate that account.

Unfortunately, unlike my son's situation last year, the schools my daughter is choosing between don't have the same "cohort based pricing" programs. As a result, it's not clear that her account will be enough to cover the next four years' worth of school.

Still, her balance is enough to cover around three and a half years' of costs at the most expensive school on her list (after scholarships) at current prices. With CDs within the 529 plan paying above 4% , the numbers were close enough to be worthy of the sale. Depending on her final choice of college, we should either have enough or at least be close.

Asset allocation makes it possible

Of course, the only reason that 529 account had nearly $160,000 in it is because I opened it when she was a newborn and had been contributing to it every year since then. Those contributions, plus the stock market's returns over time, are what made it possible.

Now that the time is here to cover the costs that the account was designed to cover, it no longer makes sense to take stock market risks with the money in it. After all, even if stocks can provide higher returns over time, market returns are never guaranteed, and stock prices can go down.

The college bills will come due and need to be paid on time no matter what the stock market happens to be doing at the time. For that reason, the higher certainty of CDs is worth it now that those checks need to be written. Yet without the growth from stocks up until this point, the account's balance would not have gotten as large as it has.

The key to that balancing act is knowing what you need the money for and when you need it -- and investing accordingly. Stocks may be appropriate for the long term, but they're very risky when it comes to covering near-term expenses.

By planning in advance and following solid asset-allocation principles, you can invest in a way that improves your chances of meeting your financial needs when those needs arise.

It does take time to put such a plan in place, though. The sooner you get started, the better your chances are of making it work for you. So get started now, and give yourself the longest possible runway to reach that goal.