FILE - In this Friday, Feb. 17, 2017, file photo, an American flag hangs on the front of the New York Stock Exchange hours after the market closed, in New York. Technology and health care stocks are leading U.S. market indexes slightly higher in early trading on Wall Street, Wednesday, June 7, 2017. (AP Photo/Peter Morgan, File)
FILE - In this Friday, Feb. 17, 2017, file photo, an American flag hangs on the front of the New York Stock Exchange hours after the market closed, in New York. Technology and health care stocks are leading U.S. market indexes slightly higher in early trading on Wall Street, Wednesday, June 7, 2017. (AP Photo/Peter Morgan, File) Credit: Peter Morgan

Banks and other financial companies led U.S. stocks slightly higher Wednesday, snapping a two-day losing streak for the market.

The latest gains were partially offset by a slide in energy companies following a steep slump in the price of U.S. crude oil, which fell 5.1 percent, its biggest single-day drop in nearly three months.

Trading was mostly subdued, with the major indexes trading in a narrow range as investors sized up the latest company earnings and looked ahead to testimony Thursday from former FBI Director James Comey, part of a congressional investigation into Russiaโ€™s possible election meddling.

โ€œFrom an investor perspective it would be nice to get another potential distraction out of the way and move toward the threefold mandate of the Trump administration: deregulation, reduced taxes and improved infrastructure, because they have been delayed, delayed and delayed,โ€ said Erik Davidson, chief investment officer for Wells Fargo Private Bank.

The Standard & Poorโ€™s 500 index rose 3.81 points, or 0.2 percent, to 2,433.14. The Dow Jones industrial average gained 37.46 points, or 0.2 percent, to 21,173.69. The Nasdaq composite index added 22.32 points, or 0.4 percent, to 6,297.38. The Russell 2000 index of small-company stocks picked up 1.78 points, or 0.1 percent, to 1,396.67.

The major indexes remain slightly below record highs set late last week.

Stocks wavered between small gains and losses early Wednesday as investors weighed the latest company earnings reports.

Comeyโ€™s appearance before the Senate intelligence committee will be his first public comments since he was abruptly ousted by President Donald Trump on May 9.

Oil futures fell sharply after a report showed that U.S. crude stockpiles grew 3.3 million barrels last week. Experts had expected stockpiles to shrink by 3.5 million barrels. Benchmark U.S. crude slid $2.47, or 5.1 percent, to close at $45.72 per barrel in New York. Brent crude, used to price international oils, fell $2.06, or 4.1 percent, to settle at $48.06 per barrel in London.

Financials were the biggest gainers in the S&P 500, rising 0.8 percent. The sector is up 23 percent this year.

Speculation that the Federal Reserve may raise its key interest rate at a meeting of policymakers next week likely helped lift the sector on Wednesday, said Davidson. Higher interest rates allow banks and credit card issuers to charge more for loans, which boosts profits.

JPMorgan Chase gained 95 cents, or 1.2 percent, to $83.91. American Express rose $96 cents, or 1.2 percent, to $79.81.

Oil futures fell sharply after a report showed that U.S. crude stockpiles grew 3.3 million barrels last week. Experts had expected stockpiles to shrink by 3.5 million barrels. Benchmark U.S. crude slid $2.47, or 5.1 percent, to close at $45.72 per barrel in New York. Brent crude, used to price international oils, fell $2.06, or 4.1 percent, to settle at $48.06 per barrel in London.

The steep slide in oil prices sent several oil and gas drilling companies lower. Newfield Exploration was the biggest decliner in the S&P 500, losing $2.16, or 7 percent, to $28.90. Helmerich & Payne fell $3.22, or 6 percent, to $50.08. Rig operator Transocean gave up 51 cents, or 5.6 percent, to $8.59.

Investors also kept an eye on company earnings Wednesday.

Carvana jumped 32.8 percent after the online used car seller posted its first quarterly results as a public company and issued a forecast that exceeded Wall Streetโ€™s expectations. The stock climbed $3.13 to $12.66.

Duluth Holdings slumped 18.6 percent after the clothing and tools supplier reported disappointing earnings. The stock slid $3.82 to $16.75.

Video compression chip maker Ambarella sank 10.2 percent after its guidance on sales of vision chips used by drones stoked concern among investors. The stock gave up $6.12 to $53.60.

Bond prices fell. The 10-year Treasury yield rose to 2.18 percent from 2.15 percent late Tuesday.

The dollar rose to 109.83 yen from Tuesdayโ€™s 109.54 yen. The euro weakened to $1.1252 from $1.1271.

Among metals, gold slipped $4.30 to $1,293.20 per ounce. Silver lost 9 cents to $17.62 per ounce. Copper held steady at $2.55 per pound.

In other energy futures trading, wholesale gasoline shed 6 cents, or 4.1 percent, to $1.49 per gallon. Heating oil gave up 5 cents, or 3.4 percent, to $1.42 per gallon. Natural gas dipped 2 cents to $3.02 per 1,000 cubic feet.

In Europe, Londonโ€™s FTSE 100 slid 0.6 percent ahead of Thursdayโ€™s British elections. Traders were also looking ahead to a policy meeting of the European Central Bank on Thursday. Germanyโ€™s DAX slipped 0.1 percent, while Franceโ€™s CAC 40 fell 0.1 percent. In Asia, Tokyoโ€™s Nikkei 225 and Sydneyโ€™s S&P-ASX 200 were unchanged. Hong Kongโ€™s Hang Seng fell 0.2 percent. Seoulโ€™s Kospi shed 0.4 percent.