NEW YORK (TheStreet) -- Shares of Marathon Petroleum (MPC - Get Report) have jumped this year to $57.80 -- compared with $45.13 at the end of 2014 and $44.46 a year ago -- even amid volatile oil prices. Marathon, headquartered in Findlay, Ohio, has dominated the Energy Select Sector SPDR Fund (XLE), which its down more than 12% this year.

With Marathon's stock scheduled to go ex-dividend Monday, August 17, it's worth asking how much potential the stock has. Right now it's about $5 from its 52-week high. To qualify for a dividend check, investors must have owned the stock on or before Friday, August 14. That's the last day that Marathon will acknowledge its roster of shareholders and know who to send dividend checks to.

A "dividend capture" can be lucrative. This is where investors or traders buy shares of companies before their ex-dividend date for the purpose of collecting the quarterly dividend and then selling the stock within days after the dividend cash payment has been paid.

Marathon will pay its 32-cent quarterly payout on Thursday, September 10. Indeed, the company, which has a large refining business, has ways to be profitable despite weak oil prices. The company reported net income of $826 million, or $1.51 per diluted share, for the second quarter, compared with a profit of $855 million, or $1.48 per diluted share, for the same period of 2014. Total revenue for the period ending June 30, 2015 was $20.5 billion.

Marathon suffered a 7% year-over-year decline in refining margin, falling to $14.84 per barrel from $16.02 per barrel in the year-ago quarter. This led to 4.3% year-over-year decline in operating earnings for its refining and marketing segment. By contrast, other refiners like Valero Energy (VLO - Get Report) topped Wall Street's estimates by posting a year-over-year jump in refining margins.

This could suggest that the economic advantages Marathon had -- which drove its stock during the first half of the year -- are beginning to wane.

Marathon's stock should be bought for the dividend play. But until the company improves its weakening refining margins, it is not a stock to buy as part of a long-term investment strategy.

This article is commentary by an independent contributor. At the time of publication, the author held no positions in the stocks mentioned.