CONTACT
Language:  ▾
Follow us:


Building profitable portfolio of stock pairs

Putting together a profitable stock pair portfolio In our previous article, we started to introduce the Stock Pair Builder program. We showed how to look for stock pairs suitable for trading and introduced basic tools for back-testing one stock pair. In this article, we will focus on back-testing stock pair portfolios. We will learn how to put a portfolio together in the Stock Pair Builder program, how to back-test it, and how to evaluate it. We will discuss important parameters that must be monitored in a portfolio, and give several tips for selecting pairs.

Putting a portfolio together in Stock Pair Builder

A portfolio can be put together in the Builder by simply selecting pairs in the Table of Pairs. The table supports multiple selections based on Windows standards: by holding down the Shift or Ctrl buttons, you can add / take away pairs as required. Use the keyboard shortcut Ctrl+A to select all pairs in the Table. Every time you make a change in your selection, the list of transactions executed will be automatically updated in the “Portfolio” card, and the equity curve and performance parameters of the portfolio will also be updated.
Back test of a stock pair portfolio in Stock Pair Builder
The setting requirements in the portfolio tester are minimal – the user only needs to enter the maximum number of positions that may be open at any one time. All other logic of stock pair portfolio trading is integrated in the program and the user need not take care of anything. The Builder automatically filters out double and cross pairs (see below), checks the number of simultaneously opened positions, and puts together a table of executed transactions. The portfolio back test simulates to the greatest degree possible actual trading in the Stock Pair Trader.

Basic terms

Maximum number of open positions – the highest number of simultaneously opened positions. This setting is important for back-testing and real portfolio trading with a view to the total capital available (allocated). The sum of the capitalisation of all of the opened positions may never exceed the value of the trading account. InteractiveBrokers would refuse to open a position that would exceed the permitted margin (account value). In real trading, there would be a risk that TWS only opens one leg (e.g., Short), refusing to open the other (Long), pointing to insufficient capital. Portfolio diversification increases with the number of positions opened, and summary statistics improve (equity stability, average transaction, ratio between Drawdown and profit). A trader should therefore always try to trade the greatest possible number of pairs. On the other hand, the impact of commissions charged for the opening and closing of each position (see below) must also be taken into account.
Fitness function – When opening new positions, it may (and it often does) happen that there are more pairs with a signal for entry than there are available slots (up to the maximum number of open positions). The Builder and the Trader therefore order pairs with a signal for entry based on their Fitness Function value. The Fitness Function decides which pair will be preferred for entry into position and for which no available slot will be left. In the current version of the program, the value of the fitness function equals the absolute value of the Relative Standard Deviation. That means that pairs with a higher absolute RelStDev value are preferred. In subsequent versions, we are preparing tools that will allow the user to define the Fitness Function as he sees fit, thereby further increasing the profitability of his portfolio.
Cross pairs – are pairs that have one stock title in common, e.g., A-B, B-C. Both the StockPairTrader and the StockPairBuilder automatically monitor this and make sure that cross pairs are not in position simultaneously. It is because in that case, it would not be evident which allocation of the shared stock (“B”) belongs to which pair. Furthermore, pairs A-B and B-C would be unintentionally linked. In other words: fluctuation of stock “B” would influence both pairs at the same time, thereby linking stock “A” and “C” into a virtual A-C pair. As soon as the Builder (during portfolio back test) or the Trader (during live trading) opens a pair position, it “freezes” all cross pairs in the portfolio. A frozen pair is blocked until the cross position is closed. As long as a pair is frozen, it cannot enter into a position. Once a position is closed, the cross pairs concerned are activated and may again enter into position. This can happen even on the same day on which the cross position was closed.
Duplicate pairs – pairs made up of the same pair of stock, e.g.: A-B, B-A. A duplicate pair is a special case of cross pair. All of the rules stated above apply to it.

Portfolio performance characteristics

A portfolio has the same performance characteristics as a stock pair itself: aggregate net profit / loss, equity stability, Gain/DD ratio, number of transactions, average transaction, drawdown, etc.
Graph of portfolio performance
The graph displayed in the right-hand part of portfolio back test displays the development of the portfolio’s equity and the number of positons open. The black line of the portfolio’s equity displays the development of the net profit / loss of the entire portfolio in time. The green area at the bottom of the graph shows the number of positions opened in time. This information is important for setting the maximum number of open positions. Generally speaking, a portfolio whose capital is used to the maximum generates the highest profit. The number of open positions should therefore be as high as possible, it should reach the maximum number entered.

Commission for the opening and closing of a position

A commission (fee) is paid to the broker for each purchase or sale of stock. In the case of InteractiveBrokers, the commission amount is based on the number of shares we are buying / selling. For a detailed commission calculation, see here. The thing important for us now is that the minimum commission per order is USD 1.00
The opening and then the closing of a pair position means two long and two short orders, which means a total of four orders and four fees for the broker, hence at least USD 4.00. We need to take this into account when putting together our portfolio and when allocating capital to individual pairs. In the “regular area”, the average profit and commission depend on the capital allocated. Both are directly connected to the number of shares traded. When I double the allocation, I also double my profit and the commission. The relative ratio between the profit and commission is stable, the commission always carves away the same portion of profit. The capital allocated can therefore be increased or decreased within the “regular area” as we see fit. But: if we reduce the allocated capital with the number of shares dropping below the bottom limit, the minimum commission rule will apply (see above), and the commission will stop decreasing. At that point, the commission relative to profit will start growing, carving away an increasing share of our profit.
The limit capital allocation can be derived easily:
Putting the minimum commission amount of USD 1.00 in the place of Commission, we get the following final relationship:
Where Close is the higher of the current stock A and stock B prices.
Example: We have the pair ABE – HPQ. The limit capital amount is:
To obtain an optimal Profit / Commission ratio, we have to allocate at least USD 3,800 to the pair.

Commissions in the Stock Pair Builder program

The Stock Pair Builder takes the commission amount into account in all its results. The profit from each transaction is reduced by the commission charged for its opening and closing. You can check the commission amount in the pair calculation table which shows the gross and net profit from each transaction.
Table showing executed transactions. The gross profit, commission, and net profit are shown on the right
Commission calculation coefficients are set up as default based on the InteractiveBrokers list of tariffs. You can change them if you need.
Possibilities of commission set-up in the Builder

Selection of pairs for trading

In previous articles, we have explained that all stock pairs must be considered equal and approached as uniform units. In spite of that, we should pay attention to the selection of pairs of which we make our trading portfolio. Stock pair trading is based on arbitrage (balancing) of short-term sways in the prices of two stock titles that have correlated for some time. The mutual fluctuations in their prices must be sufficiently large to give room for sufficient profit and, on the other hand, they must not disrupt the long-term stability of the pair. Too small a fluctuation does not provide sufficient room for the desired profit, on which we also have to pay a commission (!). Too large a mutual fluctuation shows that the pair is not strongly connected and that it is potentially unstable.
Our long-term experience shows that some sectors of the economy are more suitable for stock pair trading than others. Leaving the fundamental reasons for this behaviour aside, let us take it as an empirically proven fact. The Stock Pair Builder program allows us to test entire sectors of the economy at the same time. You can find ways to test a sector of the economy by pair, by groups of pairs, or the entire sector at the same time on our YouTube channel. This way, you can easily and quickly identify “suitable” sectors and focus on those in your final selection of pairs.
When putting together your final portfolio, it is good to combine pairs from multiple sectors. This again brings us back to one of the main advantages of stock pairs: diversification. The more diverse pairs, the more stable and robust a portfolio.

Conclusion

In our article today, we have outlined how to look for suitable stock pairs and how to make a trading portfolio out of them. Our next article will be devoted to the Stock Pair Trader program and to live trading of stock pair portfolios. You will see that in technical terms, pair trading is very simple.