11

The following link has a good summary of a typical pair trading strategy: https://www.quantstart.com/articles/Backtesting-An-Intraday-Mean-Reversion-Pairs-Strategy-Between-SPY-And-IWM It actually has full python code as well. It doesn't include a cointegration check though. Edit: if X and Y are cointegrated: calculate Beta between X and Y ...


10

$\theta$ is the "mean" for this process. If $X_t > \theta \implies (\theta - X_t) < 0 $, which means that the drift for the process is negative and tends towards $\theta$. The opposite case can be made for $X_t < \theta$ ; the process will have positive drift when $X_t$ is below $\theta$. Therefore we can consider $\kappa$ to be the "speed" of mean ...


10

Well, "mean reversion trading" could mean a lot of things, I am not qualified to describe it in full generality. However, there is a simple model of mean reversion called the Ornstein Uhlenbeck process that is often seen. It has two parameters \lambda and \sigma, where lambda is the strength of the mean reversion (so one over lambda is the mean reversion ...


8

Similar to Juan Gil's answer but a bit differently I would say the following based on this: The OU process $$dX_t = \kappa(\theta-X_t)dt + \sigma dW_t$$ can be (Euler-Maryuama discretization) discretized at times $n \Delta t,n=1,\ldots,\infty $ which gives with $t = k \Delta t$ $$ X_{k+1} - X_k = \kappa \theta \Delta t -\kappa X_k \Delta t + \sigma (W_{k+1} ...


8

Let's say your cumulative return series is $\{R_i \mid i=0,1,...,N-1\}$ of length $N$ days. There's 3 conventional ways to do this at this stage. You may convert the cumulative dollar return curve into arithmetic returns: $\displaystyle{r_i}= \dfrac{R_i-R_{i-1}}{R_{i-1}}$ Or dollar returns: $\displaystyle{r_i=R_i-R_{i-1}}$ Then take the ratio: $\...


6

For a Ornstein-Uhlenbeck process, the maximum likelihood parameters are the ones from least squares regression. If your process is: $$ dX=\kappa (\theta-X)dt+\sigma dW $$ you can do a linear regression in the form $$ \frac{dX}{dt}=a+bX+\epsilon $$ So your parameters will be: $$ \kappa=-b $$ $$ \theta=-\frac{a}{b} $$ $$ \sigma=std(\epsilon dt) $$


6

It really depends on the source of your signal. Since you're trading options I assume it is either volatility signal, or volatility + basis signal. If you have signal only on basis don't bother with options and just trade underlying. Now if you are trading vol signal only, you will need to hedge all basis risk - so gamma hedge (dynamic hedging with ...


6

A few possibilities - Trading costs kill your returns (often a problem for very highly correlated securities) Mean reversion of the cointegration spread is either very weak, or happens over periods which are too long to be practical, or there is no mean reversion whatsoever. For example, consider the following two securities, which are clearly very ...


5

If you believe the process $Y_t$ to be stationary, you can try to profit from it via a mean-reversion strategy or any other way that exploits the stationarity. It doesn't matter whether $Y_t$ is obtained as a cointegrational combination of a few non-stationary processes, or as a linear combination of some processes that are stationary themselves. In the ...


5

You could, and it doesn't hurt for you to test this yourself. Some of my best work has come from drawing the opposite conclusion to conventional wisdom or stylized "facts" in publications. That said, it's trivial to construct an example where you won't be able to spread a correlated pair. Suppose the underlying data generation process is $y_t = x_t^2$, you ...


5

From the link in your OP, the article is talking about buying one stock versus shorting the other. The distance pair trading system they are describing always plays the distance to converge. It just depends on which stock price has appreciated more. For example, if "stock 1" has moved up excessively compared to "stock 2", you would short "stock 1" and buy ...


4

1. There are a few differences between Cointegrated ADF test and Johansen test. First of all, the former is only suitable for a pair of two time series, while the latter is also applicable for cointegration test of any number of series. Secondly, ADF test will suggest different test results when we switch the sequence of the inputs, while Johansen test ...


4

O-U is continuous time mean reverting process, hence used to model stationary series. It has closed form analytic solution. This allows insight into stationary processes and act like asymptotic limiting case for calculating coefficients that matter. EDIT: You can see AR(1) below $$x_{k+1} = c + a x_k + b\varepsilon_k$$ and by substituting c=θμΔt, a=−θΔt ...


4

There are many. Just to list a few: Capital structure arbitrage (CDS) Convertible bonds arbitrage Merger arbitrage Latency arbitrage Exchange-traded funds arbitrage Correlation and volatility arbitrage Municipal bond relative value arbitrage Regulatory arbitrage ... They are all easily googled. However, the main idea is always the same.


4

It depends on which return you precisely attempt to measure: Gross Return on trade: Forget about margin or not margin, it does not matter. When you evaluate the performance of a single position you look at the notional to which you exposed yourself to. So if you bought a stock worth 100 dollars and later on sell it for 110 dollars then you generated a ...


4

It depends on if you are trying to do a Dollar neutral hedge or a beta neutral hedge. Method 1 is a Dollar neutral hedge and Method 2 is the Beta neutral hedge ratio. Remember that even if you find a cointegrated pair, share A can have a higher beta than share B.


4

If you are correlating prices that would imply that you are sizing positions based on the number of shares in each position. This can result in a book that is very biased in terms of dollars invested. This is not conventional and actually, makes little sense--most of the time. Most pair trading strategies weight positions by dollar value which is why ...


4

To calculate the sharpe ratio of a strategy backtest you should ultimately go back in $ space and calculate for every day your PNL (profit and loss), not returns, because at the end of the day this reflects better what you practically will do. Important properties of your backtest are that it needs to be self-financing: no cash is injected from one period ...


4

first keep in mind how spread is constructed, say it's $y - \beta x$, $y$ being asset $A$'s price and $x$ being that of asset $B$. Then long the spread is when $A$ is under-performing, because our current spread is smaller than "fair value". Short the spread is when $A$ is over-performing. we always short the overperformer and long the underperformer.


3

Being very fast within a single datacenter is not as valuable as having the fastest line between two datacenters. So being able to write a very fast program wouldn't be the holy grail of trading anyway (it would be to instantaneously transport information between e.g. NJ and Chicago using quantum entanglement or something.) That said, if you found an ...


3

How about an O(N log(n)) solution ? To be a viable trading strategy, you often expect them variances to be similar, so just calculate ordinary volatility and put it in an ordered array. Of course that's going to be period dependent, so pick a few arbitrary periods and see which instruments end up being together. Then you get clusters of vastly smaller ...


3

Both models are based on a spread, which has to be as stationary / mean reverting as possible. $ y_t = \beta_0 + \beta_1 x_t + \epsilon_t $ In pairs trading, $y_t$ and $x_t$ are log prices, and (e.g.) the Johansen cointegration test is used to identify candidates for a pairs trade. For entry and exit points an error correction model is used. In the ...


3

I urge you to not compare CDS contracts and pairs with cash equity pair trades. The profiles are entirely different. CDS pairs are much more similar to being long and short an options contract. As protection buyer you are essentially long an option, you pay an "insurance premium" and that is what you are standing to lose at maximum. However, as protection ...


3

Your spread does not look similar to the random walk. Many of the observations are the same as the previous observation. This means most of the first differences are zero, which is why the test indicates your series has a unit-root. The current value is very good at explaining what the next value will be.


3

There are two ways to calculate the returns. One way is to calculate the net asset value (NAV) of your portfolio. For the long side the NAV is the value of your stock holdings. For the short side the initial NAV is zero since the cash proceeds from the sale balances the liabilities of the short holdings. The portfolio NAV is hence initially equal to the ...


3

You pretty much have this correct. You don’t have to have the spread equal to zero to unwind the trade. All you would care is that the stock you bought (stock A) outperform the stock you shorted (stock B) on a dollar basis in order for this to be a winning trade. In real life you would still need some capital in the trade due to margin requirements on the ...


3

Of course. Even if you started dollar neutral, the spread can continue to move away from its mean resulting in losses. Pairs trading isn't an arbitrage situation, it simply asserts that given correlated assets, their spread will revert to the long run mean if and when it does deviate.


3

It is very rare to find stocks that are reliably negatively correlated with each other. At least in absolute (as opposed to relative outperformance) terms. It can happen from time to time, but the positive correlation/beta to market usually prevails as the dominant driver of risk/returns. This said, the classic example of the phenomenon you're asking about ...


2

Yes you are correct. If price of A > B, then short A and long B. When prices of A and B diverge: (a) because of A: Make money since A is (by pairs trading assumption) over priced and we shorted. (b) because of B: Make money since B is (again, by pairs trading assumption) under priced and we were long. (c) Because of both A and B: Both A was overpriced ...


2

Please see e.g. wikipedia entry for cointegration. You should also probably read the original paper here and/or the book by Vidyamurtha. Vidyamurtha's book is a bit messy, but IMO quite OK. Also, I think it's going to be pretty hard to make pairs trading work in practice. It's just a too old idea and it's being done too much and you're going to have a ...


Only top voted, non community-wiki answers of a minimum length are eligible