NEW YORK - A federal judge on Wednesday revoked the $5 million bail of Martin Shkreli, the infamous former hedge fund manager convicted of defrauding investors, after prosecutors complained that his out-of-court antics posed a danger to the community.

While awaiting sentencing, Shkreli has harassed women online, prosecutors argued, and even offered his Facebook followers $5,000 to grab a strand of Hillary Clinton's hair during her book tour. Shkreli, who faces up to 20 years in prison, apologized, saying that he did not expect anyone to take his online comments seriously.

"He does not need to apologize to me. He should have apologized to the government, the Secret Service and Hillary Clinton," said U.S. District Judge Kiyo Matsumoto, in revoking his bail.

"This is a solicitation of assault. That is not protected by the First Amendment."

Shkreli was taken into custody immediately after the hourlong hearing. He did not visibly react though he appeared more nervous than when he entered court. He will remain jailed until his sentencing hearing, later this fall.

Shkreli's attorneys argued that his comments, while distasteful, did not make him dangerous. "I understand now, that some may have read my comments about Mrs. Clinton as threatening, when that was never my intention when making those comments," Shkreli said in an earlier letter to the judge.

"It never occurred to me that my awkward attempt at humor or satire would cause Mrs. Clinton or the Secret Service any distress."

Shkreli's attorney called his client's conduct "stupid" but begged the judge to give him another chance.

On Facebook, Shkreli has struck a more defiant note. "Lol Hillary Clinton's presumptive agents are hard at work. It was just a prank, bro! But still, lock HER up. Spend your resources investigating her, not me!!" he said in a post the same day prosecutors filed their motion to have his bail revoked.

Shkreli, 34, is best known for raising the price of an AIDS drug by 5,000 percent but was convicted by a Brooklyn jury of defrauding the investors in his hedge funds. Shkreli lied to obtain investors' money then didn't tell them when he made a bad stock bet that led to massive losses, prosecutors argued. Instead, they said, he raised more money to pay off other investors or took money and stock from a pharmaceutical company, Retrophin, he was running.

Shkreli, who has indicated that he will appeal his conviction, argued at trial that he ultimately made money for his investors and did not intend to defraud them.

Since his conviction, the loquacious executive has kept an active online presence. In addition to asking for someone to grab a strand of Clinton's hair, he has offered investment advice and announced the sale of the only known copy of "Once Upon a Time in Shaolin," a Wu Tang Clan album, that he purchased for $2 million in 2015.

"I hope someone with a bigger heart for music can be found for this one-of-a-kind piece and makes it available for the world to hear," he added.

The most recent bid is for $1,001,300 - a potential loss for Shkreli.