A third straight day of gains on Wall Street on Wednesday raised stocks to a record, as investors took comfort in signs that the American economy was on solid footing despite risks tied to the spread of the coronavirus both inside and outside China.

The new high is the latest show of resilience from a market that over the last month has shrugged-off the threat of war with Iran, the impeachment trial of President Trump and, most recently, the outbreak of a fast-spreading virus that has upended one of the world’s largest economies.

Worried that efforts to contain the virus would dampen growth in China and elsewhere, traders had battered stock prices last week. But this week, some of the panic seems to have dissipated and shares in the United States and overseas have mostly rallied.

“It’s fear versus greed,” said Steve Sosnick, chief strategist at Interactive Brokers in Greenwich, Conn. “Last week was fear, and this week is greed.”