The S&P 500 and Nasdaq experienced gains as oil prices retreated, bolstering optimism among technology stocks, partly due to media buzz surrounding Anthropic's impending public offering.