What happened

American Airlines' (AAL 3.38%) stock performed poorly in 2015, falling more than 20%. The first half of 2016 was even worse, with the stock plunging nearly 40% by late June due to weak revenue trends throughout much of the world and fears about the impact of Brexit.

However, shares of the world's largest airline have regained a lot of ground since then. The rally continued in October, surging another 10.9%, according to data from S&P Global Market Intelligence.

AAL Chart

American Airlines stock performance, 2015-present. Data source: YCharts.

So what

Weak unit revenue results were the primary cause of American Airlines stock's poor performance in 2015 and early 2016. The company actually posted record earnings throughout 2015 due to low oil prices, but investors rightly judged that American's 2015 profit margin was unsustainable. Once oil prices stabilized, American Airlines started to experience significant margin contraction.

Conversely, the stock's resurgence over the past several months has been powered by an improving unit revenue trend.

In Q2, American's revenue per available seat mile (RASM) declined 6.1% year over year. By contrast, in Q3, RASM fell just 2.2% year over year. That was significantly better than the company's original guidance. This solid result, reported last month, was the main driver of its double-digit share price gain in October.

American Airlines' unit revenue declined less than expected in Q3. Image source: American Airlines.

Now what

American Airlines expects another relatively solid revenue performance in Q4, with RASM down just 1%-3% year over year despite some unfavorable calendar shifts. That puts it on pace to be the first major airline in the U.S. to return to unit revenue growth in 2017.

However, just as American's "no-hedging" policy made it the first airline to benefit from falling fuel prices, it is also becoming the first airline to get hit by rising fuel prices. Even worse, non-fuel costs are spiraling higher.

Thus, despite the company's improving unit revenue trends, American Airlines' profit margin has quickly fallen toward the bottom of the airline industry this year. With the stock already having soared about 60% since late June, it's hard to see much further upside until the company gets its costs under control. As a result, I sold my American Airlines stock last month.