Stocks extended gains through the afternoon session Wednesday as crude oil closed above $51 for the first time since July. 

The S&P 500 was up 0.37%, hovering within 1% of its all-time high. The benchmark index remains at its best level of the year. The Dow Jones Industrial Average added 0.4%. The Nasdaq rose 0.32%.

Crude was trading at its highest since last July after the Energy Information Administration reported a 3.2-million-barrel decline in domestic inventories in the past week. The data was slightly less than the 3.6-million-barrel drop reported by the American Petroleum Institute a day earlier.

West Texas Intermediate crude oil was up 1.7% to $51.23 a barrel on Wednesday.

U.S. stocks on Tuesday ended mixed but minor gains pushed the S&P 500 to score its highest close of the year for the second day in a row. The twin factors of higher oil and a less-hawkish Federal Reserve inspired small gains.

The number of job openings rose 5.8 million in April, up from a downwardly revised 5 million in March, according to the Job Openings and Labor Turnover Survey. The quits rate fell to 2% from 2.1%, while the hiring rate slid to 3.5% from 3.7%.

European shares fell for their first day in three after weaker data from China brought up issues over growth from the world's second-largest economy. Chinese trade data showed exports fall at a faster pace of 4.1% compared to an expected 3.6% decline. Imports fell just 0.4%, the smallest decrease in 18 months.

Morgan Stanley (MS - Get Report) shares were active after the Securities and Exchange Commission leveled a $1 million fine against the bank for allegedly failing to protect sensitive customer information. Morgan Stanley agreed to the settlement, though declined to admit wrongdoing.

Lululemon (LULU - Get Report) rose despite offering a weaker outlook for its current quarter. The yogawear retailer expects same-store sales to rise in the mid-single digits in its second quarter with earnings no higher than 38 cents a share. Profit guidance missed consensus by a penny. Excluding currency exchange, sales at existing stores rose 5% in its first quarter.

Yahoo! (YHOO) kicked off an auction for a portfolio of about 3,000 patents expected to fetch more than $1 billion, The Wall Street Journal reported. Preliminary bids for the patents have a mid-June deadline. The beleaguered Internet company is also currently seeking potential bids for its core assets with a number of suitors reportedly expressing interest, including Verizon (VZ - Get Report) .

Lending Club (LC - Get Report) fell on reports former CEO Renaud Laplanche is speaking with private-equity firms and banks to potentially take the company private. Laplanche, who stepped down last month, is currently seeking financing for a possible takeover.

Ralph Lauren (RL - Get Report) was upgraded to neutral from underperform with a $96 price target at Bank of America. Analysts said the company is cutting costs and estimates appear to be bottoming.

Verifone (PAY) was downgraded to equal weight at Barclays and sector weight at Pacific Crest. Barclays analysts said the company lacks near-term visibility, while Pacific Crest said it is facing pricing and macro pressures in emerging markets.