Investing in stocks remains one of the best ways to build real wealth over time. But there's one stock that's particularly risky for you to buy. It's so risky, in fact, that you should probably avoid buying it altogether. Which stock is this, you ask?

It's your employer's.

From a pure investment perspective, it's no riskier for you for you to own your employer's stock than it is for any other investor to own it. But from a total financial risk perspective, trouble at that particular company can hurt you far harder than it would hurt an outside investor. After all, should the company get into trouble, not only would your investment be at risk, but your job could be, too.

Can it happen to you?
In the 12 months ending June 30, 30,133 companies filed bankruptcy in the U.S. In the 12 months prior to that, 36,061 filed. Many of those bankruptcies were smaller companies, but even big businesses can run into trouble that forces them into bankruptcy.

Just this past April, Energy Future Holdings filed bankruptcy. The company was taken over in a leveraged buyout that saddled it with over $40 billion in debt. That, combined with some bad bets on natural-gas prices, sent Energy Future Holdings into bankruptcy. It wasn't a small company, either -- it had over 9,000 employees and nearly $6 billion in revenue in 2013.  

Energy Future Holdings is restructuring and will likely stay in business, though probably as a leaner organization. That's cold comfort for those who wind up on the wrong end of its bankruptcy restructuring plans.

But isn't "employee ownership" a good thing?
Of course, there's a lot to be said from both an investor's perspective and an employee's perspective for employee ownership of the business. After all, it more tightly aligns the interests of the employees and the owners, as employees see the company as more than just the source of their paychecks. However, it doesn't remove the extra layer of risk associated with the potential simultaneous loss of your job and your investment.

Additionally, many companies offer some sort of equity stake as part of employee compensation. Sometimes it's because they know the benefits of employee ownership, sometimes it's for the tax benefits, and other times it's because shares are easier and cheaper to come by than cash (particularly in start-ups). A common practice, for instance, is for companies to make their matching contributions to 401(k) plans in the form of company stock.

Whatever the reason, chances are decent that if company stock is available to you, you'll find yourself owning some shares -- without having to buy it on your own. Don't turn down that kind of offer just because it's your company's stock. Nonetheless, understand that if your company does offer you equity, it's easy for that stake to become a larger share of your portfolio than you'd willingly buy as an outside investor if you didn't work there.

Find the right balance and protect yourself from your employer's troubles
If you find yourself with a significant stake in your employer's stock, it's not automatically a bad thing. After all, if your company does well, as a part-owner, you'll likely do well, too. The trick is finding the right balance that enables you to participate in your employer's success without leveraging your financial future to its results to the point where if the company fails, your retirement fails, too.

A reasonable rule of thumb is this: Save and invest for your retirement as if your company's stock were to wind up worthless. That way, even if that unfortunate future comes to pass, you'll still find yourself primed for a comfortable retirement. If -- thanks in no small part to your hard work -- your employer manages to thrive, then the shares you'll likely accumulate throughout your career will provide excellent feathering for your nest egg.

Consider that company stock you receive a bonus, an opportunity to retire earlier, or a chance to enjoy life while you're still young and healthy enough to be active. Just don't rely too heavily on your employer's stock as the foundation for your net worth. Otherwise, a slip-up by your employer could cost you both your job and your financial future.

Chuck Saletta is a Motley Fool contributor. Try any of our Foolish newsletter services free for 30 days. We Fools may not all hold the same opinions, but we all believe that considering a diverse range of insights makes us better investors. The Motley Fool has a disclosure policy.