The longest bull market in history could be showing worrying echoes of one of the greatest crashes Wall Street has ever seen.

Robert Shiller, professor of economics at Yale University and a Nobel laureate, says the steep run-up in this market rally is similar to the excesses of the 1920s before the October 1929 market crash and Great Depression.

"The 1920s is quite a legend that people are often thinking about," Shiller said Friday on CNBC's "Trading Nation." "I look at 1929 particularly as the end of the roaring '20s and it ended in a bout of speculation. Between May and September of '29 the stock market went up over 30 percent in just a few months."

Rapid stock market rises began even earlier. From the beginning of 1928 to Black Thursday on Oct. 24, 1929, the surged nearly 50 percent. Over the next five days, the index plummeted 23 percent. It had reached an all-time high just a month before the crash.

"At that time it seemed like it was a kind of gambling. The word gambling was used a lot to describe the market at that time so it became vulnerable. We're not exactly in that circumstance but we do have the market that has surged since 2009 so there is something of that spirit today," he said.

The S&P 500 hit its market bottom in March 2009. Since those lows, the S&P 500 has rallied 334 percent in the longest stretch on record since World War II without dipping into a bear market.

While markets briefly fell into a correction earlier this year, stocks quickly recovered to reach new heights as recently as late September. Shiller says this rebound is driven more by the bullish market narrative than hard data.

"It's something about capitalism and the advancement of people willing to take risks. We have a role model in the White House who models that," said Shiller. "Something like that has driven not just the stock market but the whole economy up in the United States and makes the United States the most expensive stock market in the world."

The roaring '20s and dot-com mania of the 1990s share in some of that bullish sentiment, said Shiller.

"It was a similar story that was boosting the market but they don't last forever and eventually the story starts to wilt," he said. "It's animal spirits — people's excitement about the stock market, bitcoin and other things."