The energy sector has been one bright spot in the dismal market action this week. The S & P 500 energy sector has rallied more than 5% week to date, making it the only positive sector for the week. Meanwhile, the broader index was slammed Friday after Federal Reserve Chair Jerome Powell said the central bank will continue to raise interest rates to combat inflation and warned of "more pain ahead." The S & P 500 is on track for a 2.8% decline this week. Higher oil prices helped propel the stocks higher. West Texas Intermediate crude is up 1.7% this week. Energy stocks are also a good way to protect your portfolio from inflation, according to Jerry Castellini, president of CastleArk Management. They "will have the greatest upside in the event of some continuation of inflation, but also give you some downside protection in the event that there is a market that really craves yield," he said in an interview on CNBC's " Power Lunch " Thursday. What follows are the energy companies that outperformed this week, and where analysts stand on the stocks. To find these names, CNBC Pro looked for stocks in the space that had the best week-to-date performance. APA Corp was the biggest winner in the sector, jumping almost 11% week to date. It still has another 33% upside, according to the median analyst price target. Just 44% of the analysts covering the stock rate it a buy. Marathon Oil followed, seeing a 6.8% increase in its stock so far this week. Based on the average median price target, it still has 23.3% upside. Some 46.2% of analysts covering the stock believe it is a buy. Analyst favorite Baker Hughes rose 3.4% so far this week and has another 35.7% upside, according to the median analyst price target. Most analysts who cover the stock, 72%, rate it a buy. Earlier this week, Stifel analysts said they viewed carbon capture technologies incentives from the Inflation Reduction Act as positive for Baker Hughes, which is developing the technologies. Devon Energy and Diamondback Energy also have more than 70% of the analysts covering the stock rating it a buy. Devon Energy jumped 6.7% so far this week, while Diamondback gained 3%. Earlier this month, Devon Energy's earnings beat expectations . The company reported total revenue of $5.63 billion for the fiscal second quarter compared to expectations of $4.21 billion. Pioneer Natural Resources is up 6.2% for the week and has another 11.4% upside, according to the median analyst price target. Half of the analysts covering the stock give it a buy rating. The company's CEO recently told CNBC's Jim Cramer the oil company plans to continue returning most of its cash flow to shareholders. The "growth days of the industry are over," he said. —CNBC's Michael Bloom contributed to this report.