Menu

Cointegrazione forex

4 Comments

Quantitative investment and trading ideas, research, and analysis. I've done a quick analysis of a GLD-GDX-USO triplet using PCA. Just can't seem to find a portfolio that is more stable than GLD-GDX for the whole now period. Could you give an example of a triplet ratio that is holds through the market? GLD, GDX, USO refer to their prices, not returns. This triplet should be stationary in the period I mentioned. By the way, I am not sure the PCA is the proper way to analyze cointegration. Ernie, would the pair return to its previous equilibrium? In other words, would the trade forex after a number of months or years? Anon, The pair would not necessarily return to its previous equilibrium, but the triplet would, as evidenced by its cointegration property throughout the period. However, the profitability of just trading the pair will still return if you use moving averages etc. Ernie, I suppose you ran OLS regression on levels, with 3 variables. Or did you use Johansen test? Jozef, I used Johansen tests to get the hedge coefficients via the eigenvectors. But you can also use regression of one variable level against the other 2. Hi Eduardo, The concept of cointegration has always been applied to more than 2 time series in econometrics. Johansen test, for e. You can read the documentation at spatial-econometrics. I have not seen this explored in the trading literature though. Below a link to a multivariate pairs trading strategy: Ernie — is it possible that the cointegration break is due the fact that gold abilities as hedging instrument have been changed? Dan, I don't think the cointegration break was due to gold's hedging ability has changed because the break only occurs in I think the reasons are more likely the 2 that I mentioned. Hi Ernie, Can you kindly advise me on the tax payable by hedge funds on their trading gains? Hi Ben, First, please let me say that I am not a CPA and am not qualified to give tax advice. Just to share my own experience though, most hedge funds are organized as limited partnerships, and thus all taxable profits pass through to the limited partners. So the limited partners have to pay tax, but not the fund itself. Hi Ernie, some suggest to use Hurst Exponent to trade mean reversion, what is your opinion. Hi Anon, I believe Hurst exponent can in fact be a reasonable measure of whether a time series is mean-reverting. Hi Erine Would you mind sharing your experience or articles of how to apply the Hurst exponent to trade mean reversion in a proper wayI applied it on FX trading in the past but no so successful. Hi Kenny, I believe the usage of Hurst exponent is the same as using the adf test to check for stationarity, or calculating the half-life of mean-reversion using the Ornstein-Uhlenbeck formula. Even after any of these criteria indicates that the time series is mean-reverting, you still have to find a suitable trading strategy to take advantage of the mean-reversion. Hi Ernie, How would you optimise for a portfolio of pairs? Hi Anon, You can treat each pair as an asset with its own returns and stddev, which you can long only. By Long, we mean long that strategy, not that we are long one side of the pair and short the other side. Hello Ernie, I tried 0. I ran a Johansen test for the to period and I found that a stationary triplet is: Do you agree with me? Hi Ernie, So what would you do if you were trading forex pair and it was no longer cointegrated say by the ADF test? Immediately get out of the pair 2. Get out normally take profit or stop loss and do not re-enter trade 3. Continue trading pair normally for a set amount of time and stop 4. Hi edba, I used data from to compute the hedge ratios for GLD-GDX-USO. If you use a different data period, you could certainly get different ratios. Anon, If you are trading a "static" mean-reversion strategy, then yes, loss of cointegration compels you to liquidate positions immediately. Hi Ernie, let me ask my question again: The triplet that you suggest 0. How do you use it for cointegration? If you find them to have strong trend in another data period, you will certainly need to use Johansen to compute a new set of hedge ratios. In the period I tested, a mean-reversion strategy is quite profitable with this triplet. What do you think of the possibility of pairs trading a commodity ETF with its underlying futures contracts contract rolling issues aside? Hi Fuzhi, If the commodity ETF holds futures also, then there is no issue, and it cointegrazione cointegrate very well with the underlying futures. One possible issue is that the ETF may hold contracts of different months. In that case, you have to hedge with contracts from those months as well. Thanks a lot Ernie. Will you by any chance offer a workshop in the New York area this year? Fuzhi, There may be a plan to offer this in New York in January Please check back in a few months. Hi Ernie, I have been trying to trade pairs using cointegration. I generally use 2 yrs rolling data to test cointegration and a shorter period to find the static hedge ratio. Once I find cointegration and take the trade, I keep on calculating the spread every day by rolling the shorter period to check for mean reversion. Though the spread mean reverts nicely, the trades are not profitable. Could you please advise what's wrong with my approach. Hi Ernie, The lookback period is at least sixty days. Do you advise a longer lookback period? I think the problem is because I calculate the new beta and new spread as I roll the lookback period and take sigma of the new spread. Since the original portfolio is formed using different beta and cointegrazione is with regard different beta, the trades are not profitable with respect to rolling mean. In this case I have two choice 1 Rebalance the portfolio with respect to new forex which leads to higher transaction cost. Could you please let me know your views? Hi basant, I like method 2. But in any case, your lookback should be set by halflife calculations, as recommended in my book. A long lookback will prevent the problem you cointegrazione experiencing. Thanks Ernie for your comments. I looked in your book for lookback period and didn't find any reference to relation between lookback period and half life. Could you please through some more light on this? Hi Basant, Yes, I didn't mention this relationship in my book I discussed this in my workshops. But you can simply try setting your lookback to or greater than the halflife of mean reversion. This usually works out pretty well. Hi Ernie, 1 Does the optimal regression period of a pair depends on the half life? I mean is it wise to take forex of a period where the half life is shortest? Hi Anon, Yes, generally you should set the period of regression to the halflife, unless the halflife is too short to give a meaningful fit. You should not detrend stocks beforehand, otherwise the cointegration test has no meaning. Hi Ernie, Could you elaborate on the following? The half life is calculated after running the regression. Therefore how does one set the period of regression prior to calculating halflife? How short is a short halflife? Sometime I get half life of 8 days in a regression period of 2 yrs. Hi Anon, That is a good question and a good example of the situation one faces in numerical methods quite often. One typically initiate the iterations by guessing an approximate lookback, and use this for regression and halflife computations. Then you set the new lookback to equal this halflife, and repeat the process. If this process converges, i. I think a linear regression fit should have at least 10 data points. Thanks Ernie forex the clarification. Does that mean in the process the beta used in trading is different from the cointegration beta. Anon, Yes, typically the beta used in trading uses a shorter lookback than that used in cointegration test. Hi Ernie, I am trying to replicate your suggestions but probably making some mistakes and not getting the expected results. Next with a lookback of 15 days I get a half life of 5 days and with lookback of 5 days HL comes to 2 days and so on. The convergence doesn't happen. In the out of sample spread crosses even 6 times the 10 day lookback sigma where as it remains with in 3 times the day sigma. Which sigma should I use? Hi Anon, Did you really use 5 days for linear regression? In any case, I think your HL calculations may not be correct. If you can't find the correct lookback this way, just try to find the optimal lookback in-sample, and test it out-of-sample. The same goes for your sigma computations. Hi Ernie, Thanks much for the valuable information shared on your blog. It seems that a lookback period of 2 years for the cointegration test is quite usual. However, do you believe that a shorter period might be useful to detect when cointegration breaks down in other words, could a coningration test on a 6 month period detect than a pair is not any more stationary when the same test on 2 years would not? Hi Henri, It is actually quite hard to detect the breakdown of cointegration except in hindsight maybe a year afterwards. This is because any drawdown in a pairs strategy can be interpreted as a breakdown. But only when the drawdown lasts for, say, a year, when we can say that the cointegration is really gone. Using EXACTLY the same data set, I'm seeing significantly different results between sequential tests on that same data when using the Spatial Econometrics cadf. Anyone else experienced this? Hi Andy, By sequential tests, do you mean running cadf on, say, the data of a price series over and over again and getting different results each time? Should I assume the pair no longer cointegrate and not trade the pair OR ignore the 1 year period lookback test and assume they cointegrate?? I am a student and working on my pairs trading project. I found that constant beta give very slow mean reversion process. Spread revert to its mean some time in months. I think that is not desirable. In this case, how to make changes such that it revert quickly. If I change beta everyday, portfolio re balancing come into picture. Everyday spread changes with new beta. If I get a Exit signal with new beta which is say, less greater than beta while entering the position. I would left fall short with short securities to square off my positions. How to overcome this problem? But in any case, I would not trade it until I believe that this condition is over. Jeet, Indeed I recommend updating your beta daily with a short lookback period. However, it doesn't necessarily mean you have to adjust your existing positions given the changed beta. You can just use it to generate an exit signal so that you are either in the current position, or exit both sides completely. Chan, Thanks for replying my previous post. I have regress S1 over S2 with points and found this pairs is co integrated by using ADF test. Now, I know the pair is cointegrated, I tried to trade with this coefficient and found some time the trade length is very large like months. It is not desirable. So I decided to find coefficient dynamically. For the cointegrated pair, I regressed first 20 values of S1[1: Jeet, Did your strategy lose in backtest, or in live trading, based on the method you described? Jeet, I suggest you decrease the lookback period in order to reduce the holding period. This usually increases the Sharpe ratio as well. You mean to say I should use let us say 10 days look back period to calculate coefficients dynamically. Ernie, I revisit this post and read the latest conversation between you and Jeet. I wonder is it meaningful to update hedge coefficient daily? I think hedge coefficient needs to be updated when fundamental changes but pairs are still cointegrated. But for those traders who desire short holding periods, and particularly when the pair does not really cointegrate but nevertheless mean-revert on a short time scale, a short lookback enables us to take advantage of this profit opportunity and exit quickly. But what if the half life is short, for example 10 days or shorter. It is less meaningful to regression on such short series. We are used to large uncertainties in finance anyway, so just because one has small error bars doesn't mean the prediction is better. Hi Ernie, In testing for cointegration in the pair, how do you decide a whether to use an Augmented DF test, or whether a simple Dickey-Fuller test is enough; and b in a ADF, what lag to use especially if different lag lengths result in different conclusions Thanks. Hi Danie, I always use ADF test, because of certain defects in the DF test. Thanks for the response Ernie. Conceptually, if the ADF test with 1-lag suggests the series is stationary, but with higher lag orders the null hypothesis cannot be rejected, how confident would you be in trading the pair? Have you found such an empirical counter-example? Thanks Ernie, It's possible I'm making a mistake in the model specification I'm working in Excel to keep it simplebut when testing two South African stocks over a day period, the test statistic increases with the the lag period i. The series being tested is the difference in log prices i. Danie, As long as you forex found one lag where the cointegrazione hypothesis cannot be rejected, than the series is stationary. Ernie, I did calculation on OIH-RKH-RTH in your book example but with past one year data. By the way, I am using pandas python module which is very handy to replicate examples in your book. It has nothing to do with cointegration of the 3 ETF's. Your numbers merely mean we should short OIH and long RTH. Thanks for mentioning Python. Yes, I have heard good things about it. Hi Ernie, I have enjoyed reading through the above comments. Very interesting and informative. I have a question regarding triplets. Once you get an entry signal from your model how do you get into the trade? One option is to cross the spread on all 3 legs which is very expensive The danger of the latter approach is that you don't get into the trade as the spread reverts. What is your opinion on this? Hi Anon, We can place limit orders for the least liquid component. Once it is executed, then use market orders for the remaining two. Hi Ernie, Yes this seems to be a standard approach. I carry out the following regression on daily prices over a 2 year period: From reading the comments above it seems that a common approach to trading the spread is to not use this ratio but instead estimate a linear regression over a shorter timeframe on a rolling basis Can you please clarify the logic in this? To me it seems that the cointegrating relationship holds for the original ratio 1, beta Hi Rob, Using a shorter time period to find a rolling estimate of the hedge ratio enables us to exit unprofitable positions naturally. Also, hedge ratio may drift over time in the out-of-sample period. You can backtest this scheme to see if this works better than a static hedge ratio out-of-sample. Obviously, a static hedge ratio will work best in-sample. Hi Ernie, Ok, I can see logic in that. I will run some backtests to investigate it further. From your experience of trading 2 leg and 3 leg mean reverting spreads what is the highest frequency you can trade the spread at before the transaction costs become to large relative to the expect profit per trade. For example, trading on a 1 second basis is too fast. Hi Rob, You can trade a pair at any frequency depending on the market and your technology. A holding period of seconds is possible. This is probably the best place for coint. Please I need clarification for following. I have 2 series closing data coming in live every minute. Then I find the spread at that particular time. Then new data comes in, I again stack the new data on to the previous data and keep checking for cointegration. This time NOW changes every minute forex every minute I calculate new spread from original start point when the cointegration started i. Is it correct appraoch to start from the beginning or should I only use NOW NOW for caluclating regression coefficients and then spread. Hi HASNAT, It is not statistically significant to determine cointegration based on 20 data points. You need at least data points. Also, coint is a long term property of time series, it is not very meaningful to determine cointegration using intraday data. But in general, you can use NOW-lookback: NOW to test for coint. Mr chan, as you have pointed out, when calculating an ADF test to determine cointegration it is a good idea to test both ways switch independent and dependent variable with each other. I have noticed that if the Y variable is smaller than the X variable it is more likely to be cointegrated for the ADF test, but not as likely when switched. This happens a lot. Does it make sense to calculate a hedge ratio with data before the start of test date and multiply X by that hedge ratio before performing ADF test? X and Y would seem to be normalized then. Hi Anon, The best way to avoid the order-dependence that you pointed out is to use Johansen test for cointegration. The eigenvector thus obtained is the best hedge ratios you can find. For details, please see my new book. You suggest me to use Johansen test to avoid this, but I have read you yourself use Engle-Granger. Do you not worry about the affect of order-dependence on your pairs? Anon, In cases where cointegration is strong, which is where I usually operate, using cadf is quite OK. However, if you have any concern about the strength of forex, I recommend you switch to Johansen. Chan, What if the cointegration tests johansen and adf show strong cointegration, but a chart of the spread has a pretty clear up or down trend not at all like the GLD, GDX pictures in your book? Could the test be giving some kind of false positive? The mean reversion is then with respect to the trend line. Can you tell me if the correct number of lags to use is 1? If this can't reject the null hypothesis, try larger numbers, but I think they usually don't help much. Hi Ernie -- are there any papers or guidance on doing cointegration with tick data, instead of time-sliced bar data? I am thinking about creating tick bars for each asset, but it seems to be that in order to assess cointegration, I need a time-consistent frame across all assets, so I need to close all the "bars" at the same instant. Is cointegrazione a more fluid but still consistent way of assessing the cointegrazione from cointegrated mean? I hope you understand my question, I believe it's quite basic but I don't want to re-invent the wheel. Hi experquisite, I think the only way to use tick data for coint test is to create volume bars, as you suggested. Ernie Chan, I have three basic questions. In coint based tading, every new data point changes the regression coefficients. How can we stabilize the regression coefficient? It seems that coint based strategies only work on daily,weekly data and should not be used for minute, hourly, intraday data. Is there a simple, basic paper, example which can give a practical coint based trading strategy? Mostly the papers calculate the regression coefficient in advance with all data forex the one to be tested. Hasnat, 1 You should run regression everyday, and update your coefficients and possibly positions everyday based on the latest coefficients. I don't know of any such papers, as these strategies are straightforward to construct and backtest yourself. Chan, I cointegrazione to replicate your johansen test and get the GLD,GDX,USO combination with the identical parameters as yours. But I did't succeed, where I used daily close price with time period So I am wondering what prices were you using? Did you do any preprocessing on your database? Li, The only adjustments are for splits and dividends, which correspond to the Adj Close column in Yahoo! Dr Ernie, When I find the APR and Sharpe ratio for the USDCAD using the stationarytest file. How can APR be so high while the equity line is so poor? Hi Leo, APR can be very high just by luck. Sharpe ratio is a much better measure of consistency. Dr Earnest, May I know the time zone of your USDCAD, CADAUD 1 minute data? Dear Dr Earnie, You used CADUSD vs AUDUSD in example 5. Does hedging helps to improve sharpe ratio? Because we can simply combine these into a single price series since they are normalised to USD. Hi D, Trading USDCAD vs AUDUSD is slightly different from trading AUDCAD. You are free to backtest which version generates better Sharpe. Dear Dr Earnie, May I know the reason why is it different? Looks the same to me. Thank you for your explanation Leo. Furthermore, trading USDCAD and AUDUSD allows you to choose an optimal hedge ratio, whereas for AUDCAD the hedge ratio is fixed by the broker. Dear Dr Earnie, When I use regression for a pair of data to get the hedge ratio between them, should I ignore the y-intercept? Hi Leo, If you think that the two assets should go to zero together due to fundamental reasons, then you can set the intercept to zero. GLD and GDX should go to zero at the same time. Hi Ernie, If you run it daily and if you're using values for Johansen as your weights. Would you adjust these weights daily as well? Hi D, Sure, at least for new positions. You might not want to change the weights of existing positions to avoid transaction costs. Dear Dr Earnie, You mention "You might not want to change the weights of existing positions to avoid transaction costs". Also we discussed before that sometimes we will choose the second eigen vector because the first eigen vector is very large. But sometimes both eigen vector are close, just that based on hindsight, one is slowly drifting away to very large number. How do you backtest with this kind of changing hedge ratio? What is the length of period you used to calculate the hedge ratio and the length of period this hedge ratio is applied to? Thank you for your teachings Leo. Hi Leo, There is no problem with changing eigenvectors if you decide to keep the eigenvector fixed during the lifetime of a position. Generally speaking, one should set the period over which the hedge ratio is calculated to be at least as long as the half-life of mean reversion, and probably a few times that. But this is a free parameter than you can optimize in-sample. Dear Dr Earnie, So the proper backtest method using bollinger will be like the following? My second question will be since there are two eigen vectors to choose, say I choose first eigen vector, it is slowly becoming bigger and bigger while the second eigen vector do not deviate much. System would not know if the chosen eigen vector is going to be wrong or is it correct due to the data. Only through hindsight, will I see the correct hedge ratio. When I backtest it through time, my system always select the wrong hedge ratio. Hi Leo, Yes, your description is accurate. Once you entered into a trade, since you have fixed the eigenvector, it doesn't matter that the updated Johansen test will change that eigenvector. Dear Dr Earnie, May I know your advice for my second question? Do I really need to build a sophisticated decision model to choose the hedge ratio based on the following problem? I need the hedge ratio to form the spread for backtest. Hi Leo, As I said, it is irrelevant whether your first eigenvector is changing or not in theory. In practice, you have fixed its value once you entered into a position. Dear Dr Chan, I mean during the period that we have not entered a position yet. During these times, the system will have to choose an eigenvector to compute the spread time-series. Hence one eigenvector maybe getting larger and larger and while the other eigenvector is not. How do you determine the eigenvector during this period automatically? Hi Leo, For the purpose of computing the spread, we cointegrazione use the most recent eigenvector 1since this is the one we will actually trade into if the spread is big enough. Then fixing this to be our hedge ratio, we can compute the spread and Bollinger bands in the lookback period. This is a late comment for me for this old post, but I think its important to note there is another reason while gold miners and spot gold may differ. Many thinks that gold miners are a proxy for pure gold investment, while the reasons you gave are definitely good there is one which many tend to miss and is less market oriented and more geopolitical. In fact, gold is 'commodity' which is situated in many hot spots around the world, so there is always a very strong risk of expropriation by government or local interest group. Thats why in my opinion while gold miners stocks should be looked into carefully especially in rising prices times. Hi Ernie, Great books. I'm trying to reproduce your 0. Please let me know which book and which example or program you are referring to. I'm referring to these comments: For GDX, GLD, USO fromusing adjusted daily closes, I found evec: Yes, that's exactly what I got 0. But if you run it ending at you don't get 0. Since we agree on this set of numbers, it means that our programs are the same. You can ignore the eigenvector values I quoted previously - I am not going to find out exactly what went wrong, whether it is the data or the program. Hi, I have cointegrazione problem with eigenvectors. My data is containing close prices of stocks over 5 years. I didn't understand what's the problem and it's meaning. Thank you Ernie your books are really great. Hi Cansin, Thanks for your kind words. Unfortunately, most implementation of Johansen's test such as that in spatial-econometrics. So stocks won't work. Friday, June 17, When cointegration of a pair breaks down. I have written a lot in the past about the cointegration of ETF pairs, and how this condition can lead to profitable pairs trading. However, as every investment advisor could have told you, past cointegration is no guarantee of future cointegration. Often, cointegration for a pair breaks down for an extended period, maybe as long as a half a year or more. Naturally, trading this pair during this period is a losing proposition, but abandoning such a pair completely is also unsatisfactory, since cointegration often mysteriously returns after a while. A case in point is the ETF pair GLD-GDX. When I first tested it init was an excellent candidate for pair trading, and I not only traded it in my personal portfolio, but we traded it in our fund too. Unfortunately, it went haywire in Forex promptly abandoned it, only to see the strategy recovered sharply in So the big question is: To answer the first question, it is often necessary to go beyond the technicals, and delve into the fundamentals of pair. Take GLD-GDX as the example. Firstly, due to the sharp increase in oil prices during the first half ofit costs the gold miners a lot more in energy to extract the gold from the ground, hence the gold miners' income lags behind the rise in gold prices. Secondly, many gold miners hedge their exposure to cointegrazione gold prices with derivatives. Hence when gold price rise beyond a certain limit, the gold miners cease to benefit from this rise. Recently, the Economist magazine published an article that essentially confirms this view. But further confirmation can be gained by introducing oil future price into the cointegration equation. If you do that, and if you trade this triplet of GLD-GDX-USO, you will find that it is profitable throughout the entire period from If you find trading a triplet too complicated, you can at least backtest a trading filter such that you will cease to trade GLD-GDX whenever USO goes beyond above, and maybe below too a certain band. If you have done all these backtests, you will have a plan in place to tell you when to resume trading this pair. But even if you haven't done this backtest, and you find that you need to stop trading a pair because of cumulating losses, you should at least continue paper trading it to see when it is turning around! By the way, if you think trading ETF pairs offers too low returns due to the low leverage allowed, consider the single stock futures on ETF's trading on the OneChicago exchange. Certainly the future on GDX is available there, while you might just trade the futures GC and CL directly on CME. There is, of course, the usual caveat that applies to futures pairs trading: But that's a story for another time. Posted by Ernie Chan at 9: Newer Post Older Post Home. Labels Automated trading platforms 13 Book reviews 3 factor model 9 Strategies Ernie Chan View my complete profile. My Trading Workshops Options Strategies. Partner Center icBrokerWidget 'epchan',55. Subscribe to my blog Enter your Email. Twitter Tweets by chanep!

Pivot Point Basics First Entry

Pivot Point Basics First Entry

4 thoughts on “Cointegrazione forex”

  1. AlexKotLeopold says:

    At the top of the goodies list is its mighty LS6 454 CI engine, here mated to a 400 Turbo automatic.

  2. aleksandr-koschey says:

    I began to open myself up to people and make good friends whom I intend on keeping for years to come.

  3. ader says:

    The IRS also warns that some telephone scams target recent immigrants, who are.

  4. Acidream says:

    Individuals will vary in the degree to which they are able to make some pattern out of experience.

Leave a Reply

Your email address will not be published. Required fields are marked *

inserted by FC2 system