The Math of Pairs Trading Execution – Part II

The Math of Pairs Trading Execution – Part II

In our previous post, we introduced a couple of pairs strategies and the math behind the relative pricing of the two stocks.  In this post, we will address how to handle the relative quantities, and then introduce another variation of a statistical arbitrage strategy.

We discovered that the relative pricing of the two stocks in both of the previous examples followed a linear path and we could use the trusty old 7th grade algebra equation of y = mx + b to express the relationship.

But what about the relative volume of the two companies?  How many shares of each stock should we buy or sell relative to the other?  Let’s take a look.

Relative Quantities of Pairs Trading Executions

In our previous Risk Arbitrage example, the terms of the deal were that each share of Company B will be exchange for .44 shares of Company A plus $4.50 in cash and the trader wanted to make .50.  So our (linear) equation for pricing was:

Company B Price = (Company A price *.44) + ($4.50 - .50). 

Because the terms of the deal dictate that for each share of Company B we own, we will receive .44 of a share of Company A, the equation for relative share quantities is:

Company B Shares = Company A Shares / .44

It is noteworthy that the share ratio is the slope of our linear equation.  So, for every 1000 shares of Company B we buy, we want to short 440 shares of Company A.  Let’s expand the table from our first post to include the share quantities:

Price Quantity
Company A Company B Company A Company B
50.00 26.00 440 1000
50.50 26.22 440 1000
51.00 26.44 440 1000
51.50 26.66 440 1000
52.00 26.88 440 1000
52.50 27.10 440 1000
53.00 27.32 440 1000
53.50 27.54 440 1000
54.00 27.76 440 1000
54.50 27.98 440 1000
55.00 28.20 440 1000
55.50 28.42 440 1000
56.00 28.64 440 1000
56.50 28.86 440 1000
57.00 29.08 440 1000

We believe we now have a table showing relative pricing and relative share quantities, so let’s pick the data out of the first row of the table and see if this all makes sense.  We’ll short 440 shares of Company A at 50, which will give us proceeds of $22,000.  We’ll buy 1000 shares of Company B which will cost us $26,000, and we’ll get $4.50 per share for each share of Company B, for proceeds of $4500.  So, $22,000 - $26000 + $4,500 = $500, which matches our .50 per share profit target for each 1,000 shares that we trade.  To make sure this works at all of the levels, let’s expand the table to include the money.

Price Quantity The Money
Company A Company B Company A Company B Short A Long B Cash Rec’d Profit
50.00 26.00 440 1000 $22,000 -$26,000 $4,500 $500
50.50 26.22 440 1000 $22,220 -$26,220 $4,500 $500
51.00 26.44 440 1000 $22,440 -$26,440 $4,500 $500
51.50 26.66 440 1000 $22,660 -$26,660 $4,500 $500
52.00 26.88 440 1000 $22,880 -$26,880 $4,500 $500
52.50 27.10 440 1000 $23,100 -$27,100 $4,500 $500
53.00 27.32 440 1000 $23,320 -$27,320 $4,500 $500
53.50 27.54 440 1000 $23,540 -$27,540 $4,500 $500
54.00 27.76 440 1000 $23,760 -$27,760 $4,500 $500
54.50 27.98 440 1000 $23,980 -$27,980 $4,500 $500
55.00 28.20 440 1000 $24,200 -$28,200 $4,500 $500
55.50 28.42 440 1000 $24,420 -$28,420 $4,500 $500
56.00 28.64 440 1000 $24,640 -$28,640 $4,500 $500
56.50 28.86 440 1000 $24,860 -$28,860 $4,500 $500
57.00 29.08 440 1000 $25,080 -$29,080 $4,500 $500
57.50 29.30 440 1000 $25,300 -$29,300 $4,500 $500

OK, so it seemed to have worked!  If we follow the simple equations we created, the numbers appear to make sense and we hit our appropriate targets.

Let’s now expand on the statistical arbitrage model we created in the first post to account for relative quantities of the two stocks. The two equations for buying and selling were:

Company B = (Company A * .3610) - .50

Company B = (Company A * .3610) + .50

Where .3610 was the average ratio of the price of the two stocks over the past year and we wanted to buy at a .50 discount and sell at a .50 premium.  To calculate the relative quantities for the risk arbitrage model above, we simply divided by the share ratio, which is also the slope of our linear equation.  Let’s do the same thing here and see if it works.

Company B Shares = Company A Shares / Slope

More specifically:

Company B Shares = Company A Shares / .3610

Let’s skip a couple of steps and create two tables, one for buying the spread at a discount, and one for selling it at a premium.

Sell Buy Quantity The Money - Buy
Company A Company B Company A Company B Sell A Buy B Net
31.00 10.69 361 1000 $11,191 -$10,691 $500
31.50 10.87 361 1000 $11,372 -$10,872 $500
32.00 11.05 361 1000 $11,552 -$11,052 $500
32.50 11.23 361 1000 $11,733 -$11,233 $500
33.00 11.41 361 1000 $11,913 -$11,413 $500
33.50 11.59 361 1000 $12,094 -$11,594 $500
34.00 11.77 361 1000 $12,274 -$11,774 $500
34.50 11.95 361 1000 $12,455 -$11,955 $500
35.00 12.14 361 1000 $12,635 -$12,135 $500
35.50 12.32 361 1000 $12,816 -$12,316 $500
36.00 12.50 361 1000 $12,996 -$12,496 $500
36.50 12.68 361 1000 $13,177 -$12,677 $500
37.00 12.86 361 1000 $13,357 -$12,857 $500
37.50 13.04 361 1000 $13,538 -$13,038 $500
38.00 13.22 361 1000 $13,718 -$13,218 $500
Buy Sell Quantity The Money - Sell
Company A Company B Company A Company B Buy A Sell B Net
31.00 11.69 361 1000 -$11,191 $11,691 $500
31.50 11.87 361 1000 -$11,372 $11,872 $500
32.00 12.05 361 1000 -$11,552 $12,052 $500
32.50 12.23 361 1000 -$11,733 $12,233 $500
33.00 12.41 361 1000 -$11,913 $12,413 $500
33.50 12.59 361 1000 -$12,094 $12,594 $500
34.00 12.77 361 1000 -$12,274 $12,774 $500
34.50 12.95 361 1000 -$12,455 $12,955 $500
35.00 13.14 361 1000 -$12,635 $13,135 $500
35.50 13.32 361 1000 -$12,816 $13,316 $500
36.00 13.50 361 1000 -$12,996 $13,496 $500
36.50 13.68 361 1000 -$13,177 $13,677 $500
37.00 13.86 361 1000 -$13,357 $13,857 $500
37.50 14.04 361 1000 -$13,538 $14,038 $500
38.00 14.22 361 1000 -$13,718 $14,218 $500
38.50 14.40 361 1000 -$13,899 $14,399 $500

So, if we buy the spread (Short A, Buy B in this case) following the equations we developed and subsequently sell the spread (Buy A, Sell B) also using the equations, we see that we will make a total of $1000 per 1000 shares of B, which makes sense because our target was to buy at a .50 per share discount and sell at a .50 premium for a total of 1.00.  So, for each 1000 shares we should make $1000. 

Note that the absolute prices of the two stocks do not affect the outcome, it is only their relative relationship.  This is why this strategy is considered market neutral -- the directional move of the market should not affect the success or failure of the strategy.

Another Variation of Statistical Arbitrage

In our first example of statistical arbitrage, we took a fixed premium or discount to the 12 month average ratio between the two stocks.  Another, perhaps more common, approach is to simply look at the ratio and buy and sell at various ratios.  Let’s look at the chart of the pair in the first statistical arbitrage example:

CompanyAvsCompanyB1.png

Here is the same pair, but with the bottom scale using the ratio:

CompanyAvsB_Ratio.png

As we can see, the charts are similar (there are some nuanced differences between the two techniques) and could be traded with the same principle.  Buy somewhere near the lower band and sell near the upper band, for example.

So, a trader might want to buy at when the ratio reaches .34656 and sell when it reaches .37544 (4% band on each side of .361 ratio).  From earlier examples, we can create two linear equations:

Company B = Company A * .34656

and sell when

Company B = Company A * .37544

Buy @ .34656 Sell @ .37554
Sell Company A Buy Company B Buy Company A Sell Company B
31.00 10.74 31.00 11.64
31.50 10.92 31.50 11.83
32.00 11.09 32.00 12.01
32.50 11.26 32.50 12.20
33.00 11.44 33.00 12.39
33.50 11.61 33.50 12.58
34.00 11.78 34.00 12.76
34.50 11.96 34.50 12.95
35.00 12.13 35.00 13.14
35.50 12.30 35.50 13.33
36.00 12.48 36.00 13.52
36.50 12.65 36.50 13.70
37.00 12.82 37.00 13.89
37.50 13.00 37.50 14.08
38.00 13.17 38.00 14.27
38.50 13.34 38.50 14.45

Ok, so let’s look at the share quantities on this one.  From our previous example:

Company B Shares = Company A Shares / Ratio

More specifically, when buying the ratio:

Company B Shares = Company A Shares / .34656

And Selling:

Company B Shares = Company A Shares / .37544

If we do the calculations for 1000 shares of Company B, we find that when we buy the ratio, the number of shares for Company A would be 347 shares of Company A and when we sell the ratio, we would sell 375 shares of Company A.  That would mean when we exited the position, we would have a 28 share position in Company A.  Oops!  Did we break our model?  Not really, we just have to understand something.  If we put on a ratio trade, whatever ratio we use to calculate the volume has to be consistent for both putting on and taking off the trade.  Let’s run through an example using the average annual ratio of .361 to calculate the volume.

So, we’ll put on the position at a ratio of .34656

Sell Buy Quantity The Money
Company A Company B Company A Company B Sell A Buy B Net
31.00 10.74 361 1000 $11,191 -$10,743 $448
31.50 10.92 361 1000 $11,372 -$10,917 $455
32.00 11.09 361 1000 $11,552 -$11,090 $462
32.50 11.26 361 1000 $11,733 -$11,263 $469
33.00 11.44 361 1000 $11,913 -$11,436 $477
33.50 11.61 361 1000 $12,094 -$11,610 $484
34.00 11.78 361 1000 $12,274 -$11,783 $491
34.50 11.96 361 1000 $12,455 -$11,956 $498
35.00 12.13 361 1000 $12,635 -$12,130 $505
35.50 12.30 361 1000 $12,816 -$12,303 $513
36.00 12.48 361 1000 $12,996 -$12,476 $520
36.50 12.65 361 1000 $13,177 -$12,649 $527
37.00 12.82 361 1000 $13,357 -$12,823 $534
37.50 13.00 361 1000 $13,538 -$12,996 $542
38.00 13.17 361 1000 $13,718 -$13,169 $549
38.50 13.34 361 1000 $13,899 -$13,343 $556

And take it off at .37544

Buy Sell Quantity The Money
Company A Company B Company A Company B Buy A Sell B Net
31.00 11.64 361 1000 -$11,191 $11,639 $448
31.50 11.83 361 1000 -$11,372 $11,826 $455
32.00 12.01 361 1000 -$11,552 $12,014 $462
32.50 12.20 361 1000 -$11,733 $12,202 $469
33.00 12.39 361 1000 -$11,913 $12,390 $477
33.50 12.58 361 1000 -$12,094 $12,577 $484
34.00 12.76 361 1000 -$12,274 $12,765 $491
34.50 12.95 361 1000 -$12,455 $12,953 $498
35.00 13.14 361 1000 -$12,635 $13,140 $505
35.50 13.33 361 1000 -$12,816 $13,328 $513
36.00 13.52 361 1000 -$12,996 $13,516 $520
36.50 13.70 361 1000 -$13,177 $13,704 $527
37.00 13.89 361 1000 -$13,357 $13,891 $534
37.50 14.08 361 1000 -$13,538 $14,079 $542
38.00 14.27 361 1000 -$13,718 $14,267 $549
38.50 14.45 361 1000 -$13,899 $14,454 $556

So, if we put on and take off the spread at our targets, we appear to make a similar amount of money to the previous statistical arbitrage model (the same pair based on a similar technique).  Interestingly, though, this technique has some (relatively small) variance in the net return based on the absolute price level of the two stocks, indicating it is not strictly market neutral…  perhaps a topic for a future post.

In this post, we discussed how to determine the relative quantities of the two common pairs strategies we introduced in our first post.  We found that they both adhered to the same formula:

Company B Shares = Company A Shares / Slope

We also introduced a variation on our original statistical arbitrage model that was ratio based, and discussed how to manage the relative quantities when putting on and taking off a position using that technique.

In the next post we will discuss Cross Border equity pairs and introduce foreign exchange into the mix.