Skip to main content
Tweeted twitter.com/StackQuant/status/753277945540739072
added a line
Source Link
Eka
  • 657
  • 1
  • 13
  • 24

I am trying to learn about pairs trading strategy. I know that we have to long and short cointegrated assests simultaneously. But I still have some confusion in how the strategy works. I wrote the pseudo code for what I think pairs trading strategy is?

x=price data of asset x
y=price data of asset y
if x and y are correlated and cointegrated
 
 calculate pair ratio(spread) x/y or y/x?
 calculate average of pair ratio(spread)

     if spread > mean
     sell asset ?
     buy asset ?
     else spread < mean
     sell asset ?
     buy asset ?
     close if

else

 find new pair of assets x and y
 go to line 1 with new x and y

close if

Here I am taking pair ratio(x/y or y/x) as the spread? My first question is which pair ratio should I take x/y or y/x?

if I take x/y as spread then what assests should I buy and sell if spread>mean.

If I am wrong in my assesment of pseudo code of pair trading then feel free to correct me.

I am trying to learn about pairs trading strategy. I know that we have to long and short cointegrated assests simultaneously. But I still have some confusion in how the strategy works. I wrote the pseudo code for what I think pairs trading strategy is?

x=price data of asset x
y=price data of asset y
if x and y are correlated and cointegrated
 
 calculate pair ratio(spread) x/y or y/x?
 calculate average of pair ratio(spread)

     if spread > mean
     sell asset ?
     buy asset ?
     else spread < mean
     sell asset ?
     buy asset ?
     close if

else

 find new pair of assets x and y
 go to line 1 with new x and y

close if

Here I am taking pair ratio(x/y or y/x) as the spread? My first question is which pair ratio should I take x/y or y/x?

if I take x/y as spread then what assests should I buy and sell if spread>mean.

I am trying to learn about pairs trading strategy. I know that we have to long and short cointegrated assests simultaneously. But I still have some confusion in how the strategy works. I wrote the pseudo code for what I think pairs trading strategy is?

x=price data of asset x
y=price data of asset y
if x and y are correlated and cointegrated
 
 calculate pair ratio(spread) x/y or y/x?
 calculate average of pair ratio(spread)

     if spread > mean
     sell asset ?
     buy asset ?
     else spread < mean
     sell asset ?
     buy asset ?
     close if

else

 find new pair of assets x and y
 go to line 1 with new x and y

close if

Here I am taking pair ratio(x/y or y/x) as the spread? My first question is which pair ratio should I take x/y or y/x?

if I take x/y as spread then what assests should I buy and sell if spread>mean.

If I am wrong in my assesment of pseudo code of pair trading then feel free to correct me.

Source Link
Eka
  • 657
  • 1
  • 13
  • 24

What is the pseudo code for a pairs trading strategy?

I am trying to learn about pairs trading strategy. I know that we have to long and short cointegrated assests simultaneously. But I still have some confusion in how the strategy works. I wrote the pseudo code for what I think pairs trading strategy is?

x=price data of asset x
y=price data of asset y
if x and y are correlated and cointegrated
 
 calculate pair ratio(spread) x/y or y/x?
 calculate average of pair ratio(spread)

     if spread > mean
     sell asset ?
     buy asset ?
     else spread < mean
     sell asset ?
     buy asset ?
     close if

else

 find new pair of assets x and y
 go to line 1 with new x and y

close if

Here I am taking pair ratio(x/y or y/x) as the spread? My first question is which pair ratio should I take x/y or y/x?

if I take x/y as spread then what assests should I buy and sell if spread>mean.