Andrew Caspersen departs after a hearing at the U.S. Federal Court in New York on March 28. (Lucas Jackson/Reuters)

Groomed at some of the country’s most elite private schools, Andrew Caspersen glided onto Wall Street with ease. His father was a well-known financier, and Caspersen followed in his footsteps. He snagged jobs in the close-knit private equity world, earning a salary of more than $3.68 million in 2015.

So when Caspersen called friends and family members last year with an investment opportunity, no one, it seems, blinked an eye. The 39-year-old quickly collected tens of millions from those closest to him, including his mother and brothers, as well as Wall Street insiders familiar with his pedigree.

But according to federal prosecutors, Caspersen was living a lie. The private equity firm executive was running a Ponzi-like scheme, they alleged, transferring money collected from investors to his personal brokerage accounts. Most of the money eventually vanished in a cloud of bad stock bets, they said. Meanwhile, Caspersen “put on a shameful charade,” said Preet Bharara, the U.S. attorney for the Southern District of New York.

Caspersen’s attorney has a different explanation for his behavior: a gambling addiction.

Starting at casinos and with sports betting, Caspersen developed a compulsive addiction that eventually included betting on the stock market, said Paul Shechtman, his attorney. He gambled away his fortune, including a $20 million inheritance, Shechtman said.

“This case is a tragedy. It is a tale of a good person with a ferocious addiction that caused damage to the people he cared about the most,” said Shechtman, a partner at the New York-based law firm Bracewell.

Caspersen pleaded guilty to securities and wire fraud in federal court Wednesday, telling the judge in a quivering voice that he was “ashamed” of his crime. “I defrauded numerous people, mostly family and close friends,” he said. “There was no real investment opportunity. It was just a way for me to get money to feed a gambling addiction.”

Caspersen faces more than 10 years in prison under the agreement struck with prosecutors, but the judge could impose a lighter sentence. The plea deal closes a “sad chapter,” Bharara said in a statement. “Parlaying his privileged background, Caspersen concocted a wild fraud scheme that involved made-up private equity ventures, fake email addresses, and fictional financiers.”

Caspersen’s case has sent shivers through Wall Street, where relationships and trust lubricate billion-dollar deals. It has also cast a spotlight on one of the financial industry’s darkest questions: What is the difference between gambling and investing?

Wall Street is filled with traders who rely on a mix of industry insight, complicated computer algorithms and gut instinct to make bets on whether a stock, bond or other complicated financial instrument will go up or down.

But “there is a fine line between gambling and trading. It is a very fine line,” said clinical psychologist Alden Cass, a performance coach and therapist to traders, CEOs and pro athletes. “What I have seen is that sometimes people stop using emotional discipline, and that is when trading becomes gambling.”

The comparison rankles Wall Street veterans, who say professional trading is a skill honed over years. And using a gambling addiction to explain or mitigate a crime may be viewed skeptically by some prosecutors, said Jordan Thomas, a partner at Labaton Sucharow and a former Justice Department trial lawyer.

“Prosecutors will want to focus on what he did and on the harm that it caused, and they will be very skeptical of arguments that attempt to shift responsibility for his wrongdoing,” he said.

Still, gambling has played a central role in several recent Wall Street crimes. Earlier this year, Michael Oppenheim, a former JPMorgan broker, was sentenced to five years in prison for embezzling more than $19 million from customers. His attorney argued that Oppenheim’s crime was fueled by a gambling addiction that included losses of more than $1 million on bets that Apple’s stock price would rise. The judge in the case, U.S. District Judge Analisa Torres, noted Oppenheim’s gambling addiction when sentencing him to less than the 10 years prosecutors said the crime called for.

Thomas Davis, a former member of Dean Foods’ board, was snagged in a high-profile insider-trading case after prosecutors say he passed along confidential information to famed sports bettor William “Billy” Walters. Davis, who is cooperating with authorities, owed Walters money after some gambling losses, prosecutors said. (Golfer Phil Mickelson was forced to return nearly $1 million in profit he made from trading on the inside information collected by Walters).

The difference between trading and gambling, psychologists say, largely lies in the motivation behind the bet.

“Both gambling and trading can be impaired by emotional trading biases and that leads to chasing losses, sentimentality, doubling down to get out of a hole. All of these trading errors can be catastrophic if they’re emotionally driven,” said Cass, the author of “Bullish Thinking: The Advisor’s Guide to Surviving and Thriving on Wall Street.”

There is no data on how prevalent gambling is in Wall Street circles, but a trader’s personality can make them more likely to cross the line, said Jonathan Alpert, a New York-based psychotherapist who counts close to half his clients as Wall Street financiers.

“Sometimes the line between Wall Street and gambling can get blurred. They both have a lot of the same driving characteristics: Type A personalities, thrill-seeking and impulsive,” said Alpert, author of “Be Fearless: Change Your Life in 28 Days.

Caspersen entered Wall Street from a life of privilege. His father, Finn M.W. Caspersen, former chairman of Beneficial Corporation, a consumer finance company, was a well-known financier and philanthropist. The elder Caspersen was also a prominent contributor to Republican candidates. There is even a building at Harvard named for the Caspersen family.

Andrew Caspersen attended Groton, a boarding school in Massachusetts, before going to Princeton and then, like his father and three brothers, Harvard Law School. He also dealt with personal tragedy. His fiance died in the Sept. 11, 2001, terrorist attacks, and his father committed suicide in 2009.

Caspersen was well known on Wall Street, eventually landing at the Park Hill Group, where he found investors for private-equity funds.

But Caspersen was also struggling with a gambling addiction, said Shechtman, his attorney. By 2014, he had burned through his $20 million inheritance

It was at about this time, Caspersen began calling friends and family about a new investment opportunity. His firm, Caspersen told them, was raising money for a new private-equity investment with a guaranteed 15 percent return.

Among those who signed on was a Princeton classmate, James McIntyre, who serves as an executive at the hedge fund Moore Capital, according to various media reports. McIntyre invested $400,000 of his own money and then recommended that a charitable trust associated with Moore Capital put in $25 million. McIntyre could not be reached for comment, and a spokesperson for Moore Capital could not be reached.

But instead of a putting the money toward a new investment, prosecutors say, Caspersen repeatedly made a simple but risky bet that the value of the Standard & Poors 500-stock index would decline.

During the early months of this year, that was a good bet. The S&P tumbled amid concerns that China’s economy was slowing and that the U.S. economy was not growing fast enough. By February, Caspersen was up more than $115 million, said Shechtman.

If he had walked away, Caspersen would have been able to pay back investors and replenish his inheritance. Instead, Caspersen bet it all — again, said Shechtman. Over the next few weeks, the markets started to recover, pushing back into positive territory, and Caspersen lost more than $100 million.

Eventually, Park Hill, Caspersen’s employer, started an investigation that uncovered the fraud and notified the Manhattan U.S. attorney’s office. Caspersen was arrested a few weeks later at La Guardia Airport while returning from a vacation in Florida with his family.

“The people I harmed are the people I care for the most. I could not be more ashamed of my crimes,” Caspersen said in court Wednesday.