Discussing the article: "Pair trading"

 

Check out the new article: Pair trading.

In this article, we will consider pair trading, namely what its principles are and if there are any prospects for its practical application. We will also try to create a pair trading strategy.

Pair trading is a variery of statistical arbitrage first proposed by Jerry Bamberger in the 1980s. This trading strategy is market neutral, allowing traders to profit in almost any market condition. Pair trading is based on the assumption that the characteristics of interrelated financial instruments will return to their historical averages after a temporary deviation. Thus, pair trading comes down to a few simple operations:

  • identify discrepancies in the statistical relationship between two financial instruments;

  • open positions on them;

  • close positions when the characteristics of the instruments return to the average.

Despite its apparent simplicity, pair trading is not an easy or risk-free way to make a profit. The market is constantly changing and statistical relationships may change as well. Besides, any unlikely price movement could result in significant losses. Dealing with such adverse situations requires strict adherence to the trading strategy and risk management rules.

For trading, the most interesting currency pairs are those with negative correlation. For example, this is what the movement of EURUSD and USDCHF looks like.

Author: Aleksej Poljakov

 

What is usually missing in such articles, is the implementation of formulas in code) with minimal comments of course.))))))

But so respect, good article)

 

SPS - had a quick look - the content is informative! ABC's revealed. I will see the code later - on the weekend......

just here on the list I continue (resume) to go out - trade on arbitrage...

 

It is thought that the third from the beginning formula should be this:

Lot1 * PointValue1 * ATR1 = Lot2 * PointValue2 * ATR2
 

First of all thanks to Alexei for the article.


Now the questions are.

1)

Для трейдинга наиболее интересны валютные пары с отрицательной корреляцией. Например, так выглядит движение EURUSD и USDCHF.

I don't understand why the emphasis on negative correlation. What is worse than using correlated EURUSD and GBPUSD pairs? Of course, taking into account the direction of positions, i.e. you should add positive or negative correlation in the settings.

2)

Before opening positions, you need to determine their type. If the current price of a currency pair is below the moving average, then a Buy position is opened using this symbol. And, on the contrary, if the price is above the average, a Sell position is opened. At the same time, open positions should be multidirectional. This condition must be fulfilled, otherwise opening positions is prohibited.

In the example we use pairs with negative correlation(EURUSD and USDCHF), then it turns out that multidirectional positions for these pairs will be directed either towards strengthening USD or towards weakening USD, which is one direction. I was assuming that pair trading is just the opposite, interesting in terms of hedging pairs, i.e. multidirectional positions for directly correlated ones and unidirectional positions for inversely correlated ones. Please clarify this point.


3) With default settings I was not able to get backtest as in the article, did you use any other settings for backtest?


Thanks for your attention.

 
Konstantin Kulikov direction of positions, i.e. in the settings you need to add positive correlation or negative correlation.

2)

The example uses pairs with negative correlation(EURUSD and USDCHF), then it turns out that multidirectional positions for these pairs will be directed either towards strengthening USD or towards weakening USD, which is one direction. I was assuming that pair trading is just the opposite, interesting in terms of hedging pairs, i.e. multidirectional positions for directly correlated ones and unidirectional positions for inversely correlated ones. Could you please clarify this point?


3) With default settings I was not able to get backtest as in the article, did you use any other settings for backtest?


Thanks for your attention.

1) positive correlation is a step into the unknown, let's say we take two pairs with positive correlation and they are separated (coefficient decreased), we can expect the coefficient to return to the average, but we don't know what will make this return happen - the upper pair will go to the lower one, or the lower one will start to go to the upper one. With a negative correlation there will be no such trick - they should go to the mean = towards each other. Positive correlation can be used, but then it is better to rely on the first derivative rather than prices.

2) we can't say with certainty that the price change is caused by the weakening/strengthening of some currency - there are possible variants....

3) I can't say anything, everything was default, maybe you chose the wrong first currency pair?

 
Aleksej Poljakov #:

1) positive correlation - a step into the unknown, let's say we take two pairs with positive correlation and they split up (the coefficient decreased), we can expect the coefficient to return to the mean, but we don't know what will make this return happen - the upper pair will go to the lower one, or the lower one will start to go to the upper one. With a negative correlation there will be no such trick - they should go to the mean = towards each other. Positive correlation can be used, but then it is better to rely not on prices, but on the first derivative.

2) we cannot say with certainty that the price change is caused by the weakening/strengthening of some currency - there are possible variants here....

3) I can't say anything, everything was default, maybe you chose the wrong first currency pair?

Konstantin is the only one who has questions on the merits... Inverse correlation is just visually interpretable, but direct correlation also takes place, for this purpose one of the instruments should be inverted, it is done in the following way:

1) Ask1 = 1/Bid
2) Bid1 = 1/Ask

I have inverted the glass. In other words, for example USDCHF instrument becomes CHFUSD instrument... well, it's like this.... If it is required, on the basis of all instruments you can make inversions and you will have a lot of negative correlations )). So, I still have a lot of personal questions, but I have my own code ))

 
Stanislav Korotky #:

It is thought that the third from the beginning formula should be this:

Theoretically. But how to calculate this ATR practically?

 
Konstantin Kulikov direction of positions, i.e. you need to add positive correlation or negative correlation in the settings.

2)

The example uses pairs with negative correlation(EURUSD and USDCHF), then it turns out that multidirectional positions for these pairs will be directed either towards strengthening USD or towards weakening USD, which is one direction. I was assuming that pair trading is just the opposite, interesting in terms of hedging pairs, i.e. multidirectional positions for directly correlated ones and unidirectional positions for inversely correlated ones. Please clarify this point.


3) With default settings I was not able to get backtest as in the article, did you use any other settings for backtest?


Thanks for your attention.

This example is only useful as an implementation in code. This approach has no practical application in a non-stationary environment. Pairwise or otherwise it is definitely not a trade insurance / hedge, if in this sense a hedge.

Unfortunately, the author did not give the background of where the price movements come from and why. The question is about fair price, quote and its revaluation, not revaluation. He just assumed that if prices cross up down, this process will always be there and if prices have moved far apart at approximately the same rates of differently directed instruments, it indicates that some of them are overestimated and some are underestimated and they will converge, and perhaps even cross by inertia. It works well in a stationary environment. On the currency non-stationary market, only in a more or less stationary period.

The risks of large movements in such an algorithm cannot be insured. In general, a hedge on Forex is definitely not insurance), it is not spot vs. futures))))

But the issues of instrument correlation, fair valuations are definitely not the topic of this article) Good educational article).

 
Evgeniy Ilin #:

Konstantin is the only one who has some questions on substance.... Inverse correlation is just visually interpretable, but direct correlation also takes place, for this simply one of the instruments should be inverted, it is done as follows:

1) Ask1 = 1/Bid
2) Bid1 = 1/Ask

I have inverted the glass. In other words, for example USDCHF instrument becomes CHFUSD instrument... well, it's like this.... If it is required, on the basis of all instruments you can make inversions and you will have a lot of negative correlations )). So, I still have a lot of personal questions, but I have my code ))

It is enough to multiply the correlation coefficient by -1.

 
Evgeniy Ilin #:

Konstantin is the only one who has some questions on substance.... Inverse correlation is just visually interpretable, but direct correlation also takes place, for this simply one of the instruments should be inverted, it is done as follows:

1) Ask1 = 1/Bid
2) Bid1 = 1/Ask

I have inverted the glass. In other words, for example USDCHF instrument becomes CHFUSD instrument... well, that's so.... If it is required, on the basis of all instruments you can make inversions and you will have a lot of negative correlations )). So, I still have a lot of personal questions, but I have my own code ))

These are definitely not substantive questions)))) This is an educational example, perhaps without a proper explanation of the essence and limits of application) But the essence of this question certainly does not fit into the framework of this article.

And the beginning of the article can be condescended to. )))) I haven't looked at the code yet, but it's already something)))