Wednesday, July 17, 2013

The impact of the American Airlines – US Airways merger on American Airlines AAMRQ stock: a curious case of stock piggy-backing

So I have been investing in stocks for 3 months now. My portfolio is in good shape; I lost a bunch of money from some bad trades, and gained a bunch from the good ones. Overall, I have come out ahead and learned a good deal about the stock market. Funny enough, most of my gains have been huge gains (think 20% or more) and come from incredible trades. One such a good trade gave me more than 50% return and really boosted my confidence for investing. And I have American Airlines and US Airways to thank for that. Specifically, I have the merger deal between them to thank for the gains from American Airlines stock. At this point I have already sold my entire position in the stock, and little did I know at the time that the movement of the stock was such a unique case in the world of investing.
The decision to sell my stake came 3 weeks ago when I decided to dedicate myself to studying for an actuarial exam and did not want to monitor the stock daily. And of course the stock has gone up another 40% since then, mostly in the past few days. Since I took the exam last Thursday, I have been fighting myself to get back in, but in the end I chickened out and missed out on the run. Oh well. Anyway, here is the deal (pun intended).
American Airlines stock files even higher.
American Airlines stock files high.
Thanks for the deal, US Airways.
Thanks for the deal, US Airways.
To give you some background, American Airlines is owned by AMR Corporation, and when I say American Airlines stock I really mean AMR Corporation stock. The stock symbol is AAMRQ. US Airways is owned by US Airways Group; their stock symbol is LCC. AMR Corporation filed for bankruptcy in late 2011. Usually that means all shares of the company become worthless, but there was an exception to this case, an exceptional exception. In early 2013, US Airways Group and AMR Corporation announced a plan to merge to become the largest airline in the world. As part of the deal, current stockholders of AMR Corporation would be rewarded with some US Airways shares.
Exactly how many? Here is where the fascinating stuff comes in, but at least we know that AAMRQ stockholders would receive something, and I jumped on the bandwagon on the news. I actually had planned to jump in earlier since I anticipated the merger to be announced soon, but I did not have my investment account soon enough: AAMRQ, since the mother company was in bankruptcy, was traded on the pink sheets, and since my Scottrade account was so new I had to wait for a few days upon opening to start trading it. The bad timing resulted in me missing out on the overnight 60% jump. But I digress.
Under the agreement between the two companies’ stockholders, apparently AAMRQ stockholders would divide 3.5% of LCC’s stock among themselves. People tend to think that this 3.5% is fixed, but according to some sources this is the minimum. Take Bloomberg for an example: http://www.bloomberg.com/news/2013-02-14/us-airways-leads-amr-merger-to-create-largest-airline.html
[Tom] Horton [CEO of AMR Corp] said AMR’s shareholders will recover “at least a 3.5 percent aggregate ownership stake” under an agreement with creditors.
The percentage of LCC stock that AAMRQ holders will receive when the deal closes is not fixed at all. It is almost free to vary. Assuming what Horton said is right, it can go down to 3.5%, or up to the double-digit.
What is determined is, AMR stakeholders will receive 72% of LCC. When a company emerges from bankruptcy, any equity is distributed to debt holders first, then to employees, and finally to stockholders. So AAMRQ holders will receive whatever is left after the 72% is distributed to creditors and employees. If LCC is high valued, the leftover is potentially huge, and if LCC is low valued, there may be nothing left over. The SEC filing for the merger can be found here:http://www.sec.gov/Archives/edgar/data/4515/000119312513060746/d487000dex21.htm
Before we get to the math, let me take a minute to thank Jamie Baker from JP Morgan for providing the analysis that I am going to walk you through. He is the only analyst I know that accurately explains the terms of the merger and values AAMRQ stock. They set a price target of almost $7 for AAMRQ, and today the stock got really close to this level.https://markets.jpmorgan.com/research/EmailPubServlet?action=open&hashcode=-khht4o7&doc=GPS-1058079-0
Math time again
It’s simple math. Don’t be intimidated.
I will be using numbers provided by JP Morgan for the calculations. We have some variables:
LCC price: let’s call it X
LCC shares oustanding: 736.8 million
AMR liabilities to creditors and employees: $7.565 billion, or $7,565 million
AMR shares outstanding: $335.3 million
To simplify, let’s get rid of the millions.
The value of US Airways is 756.8*X
The portion allocated to AMR is 72%*756.8*X=530.5*X
The leftover for AAMRQ shareholders is 530.5*X-7565
Value per AAMRQ share is (530.5*X-7565)/335.3
AAMRQ price = 1.582*LCC price – 22.56
—————————————————————————————————————————————————————-
You see, AAMRQ price totally depends on LCC price. To give you perspective, if LCC price is $15 per share, then AAMRQ will be worth $1.17. On the other hand, if LCC price gets to $20 per share, AAMRQ will be valued at $9.08. If LCC price drops below $14.26, AAMRQ shares will be worthless.
I have drawn a graph that tracks LCC price, AAMRQ price estimated from the formula, and actual AAMRQ price:
AAMRQ stock
The estimation is meaningful after February 14, the day the merger deal was announced, and only when the estimate is above 0 since a stock price cannot go negative. You see, from early March on the actual stock performance has been closely following the estimate, and finally the gap was closed about 2 weeks ago. But more importantly, a change in LCC stock price enormously amplifies a variation in AAMRQ price. If tomorrow LCC price goes up $1, which equals 5.6%, AAMRQ price will go up $1.58, an increase of a whopping 27%!
And this has happened. As LCC went from $17 to $18.1, or 6.5% between 5/6/13 and 5/14/13, AAMRQ increased to $5.79 from $4.42, or 31%.
Basically AAMRQ stock piggy-backs on LCC with much more volatility. The value of AAMRQ stock depends not only on the movement of LCC but also on the date the deal is closed, which is expected to be some time in the 3rd quarter this year. On this date, the price of LCC as well as AAMRQ will be locked in. Both stocks will be canceled, and each stockholder will receive a share of the new company equivalent to the value of their shares pre-merger.
In closing:
AMR Corporation is one of the rare bankruptcy cases where stockholders may be able to recover 100% value when the company emerges. What’s more interesting is that the price of one stock is determined completely by that of another. If you believe that US Airways will do well and see their stock appreciate, you should actually invest in American Airlines stock since the latter will go up in value even faster. If you are unsure about US Airways’ short term performance, I’d be cautious: AAMRQ is much more volatile than LCC in both directions. I would not recommend investing in AAMRQ if you are risk-averse.
This is my second article on investment, and you can expect more in the future.
I can’t tell you how liberated I feel after my exam. Feels good to start writing again. Thank you for patiently awaiting for my comeback!!!

Tuesday, July 9, 2013

Problem with LINQ to Entities query using Sum on child object property

Given this query:
from s in services
select new
{
    s.Id,
    s.DateTime,
    Class = s.Class.Name,
    s.Location,
    s.Price,
    HeadCount = s.Reservations.Sum(r => r.PartySize), // problem here. r.PartySize is int
    s.MaxSeats
}
If the service doesn't have any reservations, this exception is thrown:
System.InvalidOperationException: The cast to value type 'Int32' failed because the materialized value is null. Either the result type's generic parameter or the query must use a nullable type.
Solutions:
1. You should check for it:
HeadCount = s.Reservations != null ? s.Reservations.Sum(r => r.PartySize) : 0,
2. There's an even simpler solution:
from s in services
select new
{
    s.Id,
    s.DateTime,
    Class = s.Class.Name,
    s.Location,
    s.Price,
    HeadCount = (int?)s.Reservations.Sum(r => r.PartySize), 
    s.MaxSeats
} 

LINQ to Entites 'parameterless constructor' error

LINQ to Entities takes a different approach than LINQ to SQL in some areas.  In part this is a matter of wanting LINQ to Entities to be more explicit about the boundary between what parts of your query execute on the server and what part execute on the client.

With LINQ to SQL, for instance, it is possible to write a LINQ query which not only involves data from the server and functions on the server but also functions that can only be executed on the client and to mix them in together.  The LINQ to SQL provider will then do its best to untangle things and execute the parts that it can on the server and other parts on the client.  This is nice because it is easy to just write whatever query you want and if at all possible it will work.  On the other hand, it's not so nice if you accidentally write a query where the only part which can execute on the server is the most basic thing that returns all the data in one or more tables and then have all the filtering happen on the client (with very nasty perf consequences).

With LINQ to Entities, the boundaries are more explicit.  When you write a LINQ query against a LINQ to Entities IQueryable implementation, the entire query executes on the server, and if some part of the query cannot be executed on the server, then an explicit boundary must be created with something like ToQueryable() or ToList().  Once that query is executed and the data retrieved, then you can use LINQ to Objects to further refine the query if you so choose.  This way you explicitly know where your boundaries are, and it's easier to track down performance issues and the like.  One of the related limitations is that the select statement in LINQ to Entities can create anonymous types or other types as long as they have a default constructor and settable parameters.  This minimizes the chance that the select statement has major side effects.

As mentioned above, if you need to construct something which does not fit these constraints, then your best option is probably to have your linq to entities query return an anonymous type, and then wrap that with a linq to objects query which extracts the values from that type and calls the constructor on your other type:
var serverQuery = from ca in context.tb_carts
                          select new
                          {
                              ID = ca.tb_items.id,
                              Name = ca.tb_items.name,
                              Description = ca.tb_items.description,
                              CategoryName = ca.tb_items.tb_item_categories.name,
                              Price = ca.tb_items.price
                          };
IEnumerable cart = from ca in serverQuery.AsEnumerable()
                                                select new ItemDetails
                                                (
                                                    ca.ID,
                                                    ca.Name,
                                                    ca.Description,
                                                    ca.CategoryName,
                                                    ca.Price
                                                );

Digest from: msdn