1 alarming statistic that could mean trouble for investors

According to the latest data from the New York Stock Exchange, margin debt hit a record high of $528.2 billion in February 2017. In other words, there is currently more than half a trillion dollars in outstanding borrowed money that was used to buy shares of stock. This isn't necessarily going to cause any problems while the market is going up, but could cause major headaches if the bull market runs out of steam.

Margin debt has skyrocketed in recent years

February's margin debt total of $528.2 billion was an increase of nearly $15 billion from January's total, which itself set a record. This is generally a sign of optimism -- a bet that stocks will continue to rise -- but it doesn't always work out that way. In fact, the 2007 margin peak of $381.4 billion occurred just three months before the market hit its pre-crash peak, and the March 2000 peak of $278.5 billion occurred in the same month stocks hit their highs just before the dot-com bubble burst.

Wrecking ball with "Debt" written on it, headed for businessman.
Wrecking ball with "Debt" written on it, headed for businessman.

Image source: Getty Images.

To be clear, we don't know if margin debt has peaked, or will continue to climb, and seeing what looks like a the first part of historical pattern repeating out is no guarantee that what followed in previous cycles will recur. The point is simply that margin debt tends to be high when investors are most optimistic.

RELATED: Check out the state of the stock market before Trump took office:

Why buying stock on margin can be so dangerous

To illustrate why buying on margin can be so dangerous during market corrections and crashes, consider this simplified example.

Let's say that you have $20,000 to invest, so you buy 100 shares of a certain hot tech stock at $200 per share. The market crashes, and the share price drops to $80. Now your investment is worth $8,000. That's a pretty bad result, but your investment is still worth something, and can potentially recover.

On the other hand, let's say that you borrow an additional $20,000 to buy a total of 200 shares at a cost of $40,000. The market crashes and the share price quickly drops to $80. Now your shares are worth $16,000 -- but you owe your broker $20,000 (plus interest) for borrowing money to buy the stock. You have to sell your shares to get the funds. So, not only did you lose your entire $20,000 investment, but you're $4,000 in the hole to your broker.

As I said, this is a simplified example, and a margin call would likely have forced the sale of the stock before your investment's value turned negative, but the concept is the same. Investing with margin can potentially magnify your returns, or it could make your losses much worse if things don't go your way.

Are there ever any good reasons to use margin?

Now, I'm not saying that using margin to buy stocks is always a bad idea. When used responsibly, margin can be a valuable tool.

As a personal example, bank stocks plunged rapidly last February, and to me, it looked like an irrational knee-jerk reaction that would likely reverse course quickly. So, after some research, I decided I wanted to buy shares of Bank of America and Goldman Sachs to take advantage of the opportunity. The only problem was I didn't have enough cash in my brokerage account, so I bought shares on margin and sent my broker a check a few days later. In all, the margin I used represented less than 3% of my account's value, and the loan was only outstanding for about a week.

BAC Chart
BAC Chart

BAC data by YCharts

The point is that when used in small doses, and for relatively short periods of time, margin can add to your flexibility, without putting you at undue risk.

However, it's rarely, if ever, a good idea to buy stocks on margin to hold for an extended period. As a final thought, consider that margin interest rates tend to run in the 8% neighborhood right now, which means that for a long-term margin-purchased investment to break even, it would need to generate 8% annualized returns. The limited upside potential simply doesn't justify the cost or risk, so think twice before investing on margin.