Pairs Trading Strategy: Difference between revisions

From SharpTrader Arbitrage Software Wiki: A Detailed Overview of High-Speed Trading Technology
Jump to navigation Jump to search
No edit summary
Formatting cleanup: unified image layout (block, no float, border)
 
(12 intermediate revisions by the same user not shown)
Line 1: Line 1:
[[File:Pairs trading instruments and orders.png|1387x1387px]]
===== Introduction to Pairs Trading =====
Pairs trading is a market-neutral strategy that allows traders to profit from the relative performance of two historically correlated instruments, rather than relying on overall market direction. The core idea is simple: when the price relationship between two assets temporarily diverges from its historical norm, traders open offsetting positions expecting the prices to revert to their mean.


'''Enabled –''' enables or disables trading on a selected instrument.
Originally developed by quantitative analysts at major Wall Street firms, pairs trading is now widely used across Forex, indices, commodities, and even cryptocurrencies. It is especially appealing in volatile or uncertain markets, where directional trades carry higher risk.


'''Symbol 1 –''' symbol name on side 1
This strategy works best when:


'''Symbol 2''' – symbol name on side 2.
* The two instruments have a strong statistical correlation.
* There is a temporary spread or price divergence.
* There is a high likelihood of mean reversion.


'''Lot size 1 –''' lot size to be traded on side 1.
In this guide, we will explore the fundamentals of pairs trading, how to select suitable instruments, and how to configure key parameters to maximize performance while minimizing risk. [https://bjftradinggroup.com/product/pair-trading-strategy/ learn more...]


'''Lot size 2 –''' lot size to be traded on side 2.
[[File:Pairs trading instruments and orders.png|none|frameless|border|1387x1387px]]


'''Important:''' It is important to '''check the contract size''' for both the left and right instruments in the pair and '''adjust the lot sizes accordingly'''.
; Enabled
: enables or disables trading on a selected instrument.
; Symbol 1
: symbol name on side 1
; Symbol 2
: symbol name on side 2.
; Lot size 1
: lot size to be traded on side 1.
; Lot size 2
: lot size to be traded on side 2.
: '''Important:''' It is important to '''check the contract size''' for both the left and right instruments in the pair and '''adjust the lot sizes accordingly'''.
: For example, if '''Instrument 1''' (on the left) has a contract size of '''100''', and '''Instrument 2''' (on the right) has a contract size of '''1''', then the lot size for Instrument 2 should be '''100 times larger''' to properly balance the exposure. Additionally, you must verify the '''minimum allowed lot size''' for both instruments to ensure that your configured values are acceptable by the broker and the platform.
: It is also required identify '''Quote currency, Commission per lot''' (for FIX API Broker) and '''Lot multiplier''' for Indices in the Sessions -> Indices tab.


For example, if '''Instrument 1''' (on the left) has a contract size of '''100''', and '''Instrument 2''' (on the right) has a contract size of '''1''', then the lot size for Instrument 2 should be '''100 times larger''' to properly balance the exposure. Additionally, you must verify the '''minimum allowed lot size''' for both instruments to ensure that your configured values are acceptable by the broker and the platform.
[[File:Pairs trading indices.png|none|frameless|border]]


It is also required identify '''Quote currency, Commission per lot''' (for FIX API Broker) and '''Lot multiplier''' for Indices in the Sessions  -> Indices tab.  
; S/L
: hidden stoploss for an arbitrage trade, expressed in currency.
; T/P
: hidden takeprofit for an arbitrage trade, expressed in currency.
; Min profit
: starting point for trailing, expressed in currency.
; Trail distance
: distance arbitrage trade is trailed at.
; Trailing step
: Number of points by which stop loss is moved once trailing is activated.
; Trail units
: allows to switch trailing units between currency and percent's.
; Order lifetime
: maximum arbitrage deal duration (expressed in seconds)
; Comment
: Virtual comment added to each trade for identification
: '''Z-index Open''': Minimum Z-score deviation needed to open a trade.
: '''Z-index Close''': Z-score threshold at which the trade will be closed (if defined).
; Timeframe
: Candle period used for Z-index calculation (e.g., 15 Min). This timeframe determines how the correlation and Z-score are measured.
; Min Slope
: Minimum slope value to trigger a trade.
; Slope Period
: Number of bars used to calculate the slope.
; Regression Coefficient
: Minimum linear regression value required for entry.


[[File:Pairs trading indices.png|left]]
'''Direction'''


 
; ZIndexBased
 
: we open orders if the value of the Current Zindex is greater than the value of the Zindex Open. If Current Zindex >= 0, we open sell order on left side and buy order on right side. If Current Zindex < 0, we open a buy order on the left side and a sell order on the right side.
 
; PriceBased
 
: we open orders if the value of the Current Zindex is greater than the value of the Zindex Open. If Current Ask price on left side is greater than Current Ask price on right side, we open sell order on left side and buy order on right side. Otherwise, we open a buy order on the left side and a sell order on the right side.
 
; Buy1Sell2
 
: we open a buy order on the left side and a sell order on the right side, if the Current Zindex is greater than the value of Zindex Open and the Current Zindex < 0,
 
; Sell1Buy2
 
: we open a sell order on the left side and a buy order on the right side if the value of the Current Zindex is greater than the value of the Zindex Open and the Current Zindex >= 0.
 
; Reversed
 
: we open orders if the value of Current Zindex is greater than the value of Zindex Open. If Current Zindex >= 0, we open buy order on left side and sell order on right side. If Current Zindex < 0, we open a sell order on the left side and a buy order on the right side.
 
; Inversed
 
: we open orders if the absolute value of the Current Zindex is lower than the value of the ZIndex Open. If Current Zindex >= 0, we open buy order on left side and sell order on right side. If Current Zindex < 0, we open a sell order on the left side and a buy order on the right side.
 
; ZIndexSign
 
: we open orders if the absolute value of the Current Zindex is greater than the absolute value of the Zindex Open, and both have the same sign. If Current Zindex >= 0, we open sell order on left side and buy order on right side. If Current Zindex < 0, we open buy order on left side and sell order on right side.
 
; ZIndexSignInv
 
: we open orders if the absolute value of the Current Zindex is greater than the absolute value of the Zindex Open, and both have the same sign. If Current Zindex >= 0, we open buy order on left side and sell order on right side. If Current Zindex < 0, we open a sell order on the left side and a buy order on the right side.
 
; Max Spread Slow 1
 
: maximum allowed spread on side 1. If actual spread is higher than Max spread slow value, arbitrage signals are ignored.
'''S/L''' – hidden stoploss for an arbitrage trade, expressed in currency.
; Max Spread Slow 2
 
: maximum allowed spread side 2. If actual spread is higher than Max spread fast value, arbitrage signals are ignored.
'''T/P''' – hidden takeprofit for an arbitrage trade, expressed in currency.
: '''Time correction (based on VPS's time)'''
 
'''Min profit''' – starting point for trailing, expressed in currency.
 
'''Trail distance''' – distance arbitrage trade is trailed at.
 
'''Trailing step''' - Number of points by which stop loss is moved once trailing is activated.
 
'''Trail units''' – allows to switch trailing units between currency and percent's.
 
'''Order lifetime''' – maximum arbitrage deal duration (expressed in seconds)
 
'''Comment -'''  Virtual comment added to each trade for identification
 
'''Z-index Open''': Minimum Z-score deviation needed to open a trade.
 
'''Z-index Close''': Z-score threshold at which the trade will be closed (if defined).
 
'''Timeframe''' -Candle period used for Z-index calculation (e.g., 15 Min). This timeframe determines how the correlation and Z-score are measured.
 
'''Min Slope -''' Minimum slope value to trigger a trade.
 
'''Slope Period -''' Number of bars used to calculate the slope.
 
'''Regression Coefficient -''' Minimum linear regression value required for entry.
 
'''Direction''' <code>ZIndexBased</code>: Open trades based on Z-score deviations (statistical arbitrage).
 
'''Max Spread Slow 1''' – maximum allowed spread on side 1. If actual spread is higher than Max spread slow value, arbitrage signals are ignored.
 
'''Max Spread Slow 2 –''' maximum allowed spread side 2. If actual spread is higher than Max spread fast value, arbitrage signals are ignored.
 
'''Time correction (based on VPS's time)'''


* '''Manual''': You set time manually. In this case you need to set '''Time to start trade''' and T'''ime to stop trade''' - Defines the daily time window during which trades are allowed for the pair.
* '''Manual''': You set time manually. In this case you need to set '''Time to start trade''' and T'''ime to stop trade''' - Defines the daily time window during which trades are allowed for the pair.
* '''Automatic''': System calculates time offset automatically.
* '''Automatic''': System calculates time offset automatically.


'''Min correlation''' - Minimum correlation between the two assets required for trading to be allowed.
; Min correlation
: Minimum correlation between the two assets required for trading to be allowed.


'''Real-time statistical data from the system:'''
Real-time statistical data from the system:


* '''Curr Z-index''': Current calculated Z-score.
* '''Curr Z-index''': Current calculated Z-score.
* '''Closing Z-index''': Z-score at which the last trade was closed.
* '''Closing Z-index''': Z-score at which the last trade was closed.
* '''Min/Max Z-index''': Historical min/max Z-score for analysis.
* '''Min/Max Z-index''': Historical min/max Z-score for analysis.
* '''Curr Spread Slow 1''' – current spread for instrument 1
* '''Curr Spread Slow 1''' – current spread for instrument 1
* '''Curr Spread Slow 2''' – current spread for instrument 2
* '''Curr Spread Slow 2''' – current spread for instrument 2
* '''Profit -''' Displays the current net profit for that instrument pair.
* '''Profit -''' Displays the current net profit for that instrument pair.


==== 🧮 '''Correlation Matrix''' ====
==== 🧮 Correlation Matrix ====
 
* The main grid shows the '''Pearson correlation coefficients''' between symbol pairs.
* The main grid shows the '''Pearson correlation coefficients''' between symbol pairs.
* '''Green cells''' indicate strong '''positive correlations''' (close to +1.00), where two instruments tend to move together.
* '''Green cells''' indicate strong '''positive correlations''' (close to +1.00), where two instruments tend to move together.
Line 104: Line 110:
----
----


==== 🔘 '''Show Filter''' ====
🔘 Show Filter


* You can filter pairs to show only those meeting specific criteria (e.g., All, Strong Correlations, etc.)
* You can filter pairs to show only those meeting specific criteria (e.g., All, Strong Correlations, etc.)
Line 110: Line 116:
----
----


==== ➕ '''Symbols List''' (Left Panel) ====
➕ Symbols List (Left Panel)


* A list of available instruments that can be included or excluded from the analysis.
* A list of available instruments that can be included or excluded from the analysis.
Line 117: Line 123:
----
----


==== 🔁 '''Recalculate Button''' ====
🔁 Recalculate Button


* After adjusting parameters like timeframe or symbol list, press '''Recalculate''' to refresh the table.
* After adjusting parameters like timeframe or symbol list, press '''Recalculate''' to refresh the table.
Line 123: Line 129:
----This module is crucial for identifying pairs suitable for '''correlation-based trading''', '''statistical arbitrage''', or '''mean-reversion strategies'''.
----This module is crucial for identifying pairs suitable for '''correlation-based trading''', '''statistical arbitrage''', or '''mean-reversion strategies'''.


[[File:Pairtrading-correlation-table-1-1024x501 (1).png]]
[[File:Pairtrading-correlation-table-1-1024x501 (1).png|none|frameless|border]]
 
== Related YouTube videos ==
https://youtu.be/Ncrbn4T4Mpk
 
https://youtu.be/kBjDGaGHrV8
 
https://youtu.be/q0NcSoqerkw

Latest revision as of 19:55, 21 October 2026

Introduction to Pairs Trading

Pairs trading is a market-neutral strategy that allows traders to profit from the relative performance of two historically correlated instruments, rather than relying on overall market direction. The core idea is simple: when the price relationship between two assets temporarily diverges from its historical norm, traders open offsetting positions expecting the prices to revert to their mean.

Originally developed by quantitative analysts at major Wall Street firms, pairs trading is now widely used across Forex, indices, commodities, and even cryptocurrencies. It is especially appealing in volatile or uncertain markets, where directional trades carry higher risk.

This strategy works best when:

  • The two instruments have a strong statistical correlation.
  • There is a temporary spread or price divergence.
  • There is a high likelihood of mean reversion.

In this guide, we will explore the fundamentals of pairs trading, how to select suitable instruments, and how to configure key parameters to maximize performance while minimizing risk. learn more...

Enabled
enables or disables trading on a selected instrument.
Symbol 1
symbol name on side 1
Symbol 2
symbol name on side 2.
Lot size 1
lot size to be traded on side 1.
Lot size 2
lot size to be traded on side 2.
Important: It is important to check the contract size for both the left and right instruments in the pair and adjust the lot sizes accordingly.
For example, if Instrument 1 (on the left) has a contract size of 100, and Instrument 2 (on the right) has a contract size of 1, then the lot size for Instrument 2 should be 100 times larger to properly balance the exposure. Additionally, you must verify the minimum allowed lot size for both instruments to ensure that your configured values are acceptable by the broker and the platform.
It is also required identify Quote currency, Commission per lot (for FIX API Broker) and Lot multiplier for Indices in the Sessions -> Indices tab.
S/L
hidden stoploss for an arbitrage trade, expressed in currency.
T/P
hidden takeprofit for an arbitrage trade, expressed in currency.
Min profit
starting point for trailing, expressed in currency.
Trail distance
distance arbitrage trade is trailed at.
Trailing step
Number of points by which stop loss is moved once trailing is activated.
Trail units
allows to switch trailing units between currency and percent's.
Order lifetime
maximum arbitrage deal duration (expressed in seconds)
Comment
Virtual comment added to each trade for identification
Z-index Open: Minimum Z-score deviation needed to open a trade.
Z-index Close: Z-score threshold at which the trade will be closed (if defined).
Timeframe
Candle period used for Z-index calculation (e.g., 15 Min). This timeframe determines how the correlation and Z-score are measured.
Min Slope
Minimum slope value to trigger a trade.
Slope Period
Number of bars used to calculate the slope.
Regression Coefficient
Minimum linear regression value required for entry.

Direction

ZIndexBased
we open orders if the value of the Current Zindex is greater than the value of the Zindex Open. If Current Zindex >= 0, we open sell order on left side and buy order on right side. If Current Zindex < 0, we open a buy order on the left side and a sell order on the right side.
PriceBased
we open orders if the value of the Current Zindex is greater than the value of the Zindex Open. If Current Ask price on left side is greater than Current Ask price on right side, we open sell order on left side and buy order on right side. Otherwise, we open a buy order on the left side and a sell order on the right side.
Buy1Sell2
we open a buy order on the left side and a sell order on the right side, if the Current Zindex is greater than the value of Zindex Open and the Current Zindex < 0,
Sell1Buy2
we open a sell order on the left side and a buy order on the right side if the value of the Current Zindex is greater than the value of the Zindex Open and the Current Zindex >= 0.
Reversed
we open orders if the value of Current Zindex is greater than the value of Zindex Open. If Current Zindex >= 0, we open buy order on left side and sell order on right side. If Current Zindex < 0, we open a sell order on the left side and a buy order on the right side.
Inversed
we open orders if the absolute value of the Current Zindex is lower than the value of the ZIndex Open. If Current Zindex >= 0, we open buy order on left side and sell order on right side. If Current Zindex < 0, we open a sell order on the left side and a buy order on the right side.
ZIndexSign
we open orders if the absolute value of the Current Zindex is greater than the absolute value of the Zindex Open, and both have the same sign. If Current Zindex >= 0, we open sell order on left side and buy order on right side. If Current Zindex < 0, we open buy order on left side and sell order on right side.
ZIndexSignInv
we open orders if the absolute value of the Current Zindex is greater than the absolute value of the Zindex Open, and both have the same sign. If Current Zindex >= 0, we open buy order on left side and sell order on right side. If Current Zindex < 0, we open a sell order on the left side and a buy order on the right side.
Max Spread Slow 1
maximum allowed spread on side 1. If actual spread is higher than Max spread slow value, arbitrage signals are ignored.
Max Spread Slow 2
maximum allowed spread side 2. If actual spread is higher than Max spread fast value, arbitrage signals are ignored.
Time correction (based on VPS's time)
  • Manual: You set time manually. In this case you need to set Time to start trade and Time to stop trade - Defines the daily time window during which trades are allowed for the pair.
  • Automatic: System calculates time offset automatically.
Min correlation
Minimum correlation between the two assets required for trading to be allowed.

Real-time statistical data from the system:

  • Curr Z-index: Current calculated Z-score.
  • Closing Z-index: Z-score at which the last trade was closed.
  • Min/Max Z-index: Historical min/max Z-score for analysis.
  • Curr Spread Slow 1 – current spread for instrument 1
  • Curr Spread Slow 2 – current spread for instrument 2
  • Profit - Displays the current net profit for that instrument pair.

🧮 Correlation Matrix

  • The main grid shows the Pearson correlation coefficients between symbol pairs.
  • Green cells indicate strong positive correlations (close to +1.00), where two instruments tend to move together.
  • Red cells indicate strong negative correlations (close to -1.00), where two instruments tend to move in opposite directions.
  • Darker colors represent stronger correlations; lighter or black cells represent weak or no correlation.

For example:

  • AUDUSD vs NZDUSD: 0.48 – moderately positive correlation.
  • AUDUSD vs USDCAD: -0.94 – very strong negative correlation.
  • BTCUSD vs ETHUSD: 0.88 – strong positive correlation.

🔘 Show Filter

  • You can filter pairs to show only those meeting specific criteria (e.g., All, Strong Correlations, etc.)

➕ Symbols List (Left Panel)

  • A list of available instruments that can be included or excluded from the analysis.
  • You can add new symbols using the input field and the "Add" button.

🔁 Recalculate Button

  • After adjusting parameters like timeframe or symbol list, press Recalculate to refresh the table.

This module is crucial for identifying pairs suitable for correlation-based trading, statistical arbitrage, or mean-reversion strategies.

https://youtu.be/Ncrbn4T4Mpk

https://youtu.be/kBjDGaGHrV8

https://youtu.be/q0NcSoqerkw