Cointegration and mean-reversion
- crowlogic
- Posts: 0
- Joined: Thu Jan 01, 2004 12:00 am
Cointegration and mean-reversion
That makes a lot of sense, so you calculate your edge/expected return per unit of spread.. and then multiply that by the number of units you are trading and then use the formula as usual to determine the optimum size.
One should respect public opinion insofar as is necessary to avoid starvation and keep out of prison, but anything that goes beyond this is voluntary submission to an unnecessary tyranny. --Bertrand Russell
- dgn2
- Posts: 0
- Joined: Thu Jan 01, 2004 12:00 am
Cointegration and mean-reversion
Right. As long as you are only trading one thing (where a spread is defined as one thing) this is pretty straight forward. Things get tricky when you have multiple strategies with one capital pool. The combined bankroll can diversify manager wide drawdowns by side stepping a recovery hurdle. What I mean by that is if you are in a prolonged drawdown your capital base has been eroded. One first has to earn the recovery hurdle before one can begin earning the objective yearly return using the original capital base. This is one of the reasons why managing conditions of drawdown is so important. If two strategies use a combined bankroll and have drawdowns at different times, the combined bankroll will be more stable. If the strategy uses reinvestment to create compound growth, then the modeling of dependence between strategies becomes paramount. This can also work the other way. Using kelly-type approaches will shift your capital use to the highest expectation strategies. At this point you have moved right back to the assumptions required in option pricing, risk management, etc...You can make 'better' assumptions, but you still have to assume something implicitly or explicitly. If you use backtested results your assumptions are implicit and difficult to stress test. If you use Monte Carlo you can get a wider appreciation for what can happen but you still only get the consequence of your assumptions.
This can also be expanded to allow you to vary your expectation by market mode (i.e., range-bound, trending, gapping, etc...). The ECM does the detrending so that you can make the dominant mode range-bound trading. In other words, the ECM tells you which way to lean in the spread to neutralize the trend. If you incorporate a feedback mechanism you can adapt to slow changes. Sudden 'regime switch' type changes can be dealt with using a forgetting factor or a filter parameter reset type approach. This gaps are pretty difficult to control though. If you can reduct the number of gaps in some creative way then that will help a lot. But some of the time you are just going to eat it and you - in my view - just have to do everything you can to reduce the frequency of these gaps.
I should note again that there are two common 'formulas'. Neither - unadapted - will provide what you need. The parametric version can be expanded to be more accurate. I think you should only use the more common formula to get a really rough idea. The common formula can be very misleading.
This can also be expanded to allow you to vary your expectation by market mode (i.e., range-bound, trending, gapping, etc...). The ECM does the detrending so that you can make the dominant mode range-bound trading. In other words, the ECM tells you which way to lean in the spread to neutralize the trend. If you incorporate a feedback mechanism you can adapt to slow changes. Sudden 'regime switch' type changes can be dealt with using a forgetting factor or a filter parameter reset type approach. This gaps are pretty difficult to control though. If you can reduct the number of gaps in some creative way then that will help a lot. But some of the time you are just going to eat it and you - in my view - just have to do everything you can to reduce the frequency of these gaps.
I should note again that there are two common 'formulas'. Neither - unadapted - will provide what you need. The parametric version can be expanded to be more accurate. I think you should only use the more common formula to get a really rough idea. The common formula can be very misleading.
...WARNING: I am an optimal f'er
- Nonius
- Posts: 0
- Joined: Thu Jan 01, 2004 12:00 am
Cointegration and mean-reversion
yeah, I shouldn't have mentioned Kelly, because that wasn't central to what I was saying.....just that the VECM allows for a potential increase in forecasting each marginal distribution's expected value over the next incrmennt in time. how you size the bet is another story. that phrog paper sort of alludes to the first order obviuos thought- to trade the linear combination. I'm just saying that that is very restrictive and that one could trade each of the component assets with improved forcasting.
btw, kelly doesn't rely on any distributional assumptions. in the context of trading, it would rely on being able to trade "enough" along the time dimension so that you could appeal to CLT. interpreted in scaling to high frequency, if you could trade on intervals in the time scale of seconds, then in a year you've done in the order of, say 1.5 million trades per asset....one thing the original proof/construction DOES rely on is the assumption that the outcomes are independent. obviously if you really believe there are inefficiencies in asset price movements, you probably will not expect successive price returns to be independent. in fact, over small time scales, there is autocorrelation and that autocorrelation fades away over larger time scales. Johnny gave me a link on Telegraph Equation/persistent random walk and I think this is the right idea. anyway, it is easy to extend the kelly argument to the case where you replace an assumption of independent trials with dependent trials.
btw, kelly doesn't rely on any distributional assumptions. in the context of trading, it would rely on being able to trade "enough" along the time dimension so that you could appeal to CLT. interpreted in scaling to high frequency, if you could trade on intervals in the time scale of seconds, then in a year you've done in the order of, say 1.5 million trades per asset....one thing the original proof/construction DOES rely on is the assumption that the outcomes are independent. obviously if you really believe there are inefficiencies in asset price movements, you probably will not expect successive price returns to be independent. in fact, over small time scales, there is autocorrelation and that autocorrelation fades away over larger time scales. Johnny gave me a link on Telegraph Equation/persistent random walk and I think this is the right idea. anyway, it is easy to extend the kelly argument to the case where you replace an assumption of independent trials with dependent trials.
Chiral is Tyler Durden
- crowlogic
- Posts: 0
- Joined: Thu Jan 01, 2004 12:00 am
Cointegration and mean-reversion
Nonius:
Great point about independent vs. dependent trials with Kelly, has there been any formal research done in this area? One interesting thing with this is, if your conditional expectation changes after you are in the position, you have the possibility of taking money off of the table by reversing the position.. it seems to be that would be pretty straightforward but I might be missing something.
dgn2:
Now I see what you are saying with regards to the ECM providing the direction to learn. Standard VECM models are just vector-autoregressive models with spreads thrown in as explanitory variables, correct? (Still working on my terminology..)
Which formulas are you saying are misleading? The VAR-VECM formula?
The VAR assumptions seems pretty restrictive.. couldn't you use more advanced models, ARFIMA, neural nets possibly.., nearest neighbor techniques? Should I be searching for interesting multi-variate forecasting methods and using the spreads as explanitory variables?
Great point about independent vs. dependent trials with Kelly, has there been any formal research done in this area? One interesting thing with this is, if your conditional expectation changes after you are in the position, you have the possibility of taking money off of the table by reversing the position.. it seems to be that would be pretty straightforward but I might be missing something.
dgn2:
Now I see what you are saying with regards to the ECM providing the direction to learn. Standard VECM models are just vector-autoregressive models with spreads thrown in as explanitory variables, correct? (Still working on my terminology..)
Which formulas are you saying are misleading? The VAR-VECM formula?
The VAR assumptions seems pretty restrictive.. couldn't you use more advanced models, ARFIMA, neural nets possibly.., nearest neighbor techniques? Should I be searching for interesting multi-variate forecasting methods and using the spreads as explanitory variables?
One should respect public opinion insofar as is necessary to avoid starvation and keep out of prison, but anything that goes beyond this is voluntary submission to an unnecessary tyranny. --Bertrand Russell
- dgn2
- Posts: 0
- Joined: Thu Jan 01, 2004 12:00 am
Cointegration and mean-reversion
The ECM uses cointegration to provide an 'error correction' for a longer term relationship between two or more variables.
What I meant was that the kelly formula that uses win / loss frequency and average payoffs on wins and losses from backtest can be misleading.
And there is no reason that you have to use a simple VECM. You can extent the idea of cointegration to include fractional cointegration, regime-switching cointegration...pretty much anything you can think of. Be creative.
What I meant was that the kelly formula that uses win / loss frequency and average payoffs on wins and losses from backtest can be misleading.
And there is no reason that you have to use a simple VECM. You can extent the idea of cointegration to include fractional cointegration, regime-switching cointegration...pretty much anything you can think of. Be creative.
...WARNING: I am an optimal f'er
- crowlogic
- Posts: 0
- Joined: Thu Jan 01, 2004 12:00 am
Cointegration and mean-reversion
I understand.. backtesting can always be misleading... I've been reading up on fractional cointegration and smooth-transition/nonlinear error correcting models as well. For some reason I get the feeling that a relatively small neural network could replace the standard linear error-correction term. Or possibly a recurrent neural net.. maybe using unscented-kalman-filtering techniques for online learning of the neural error correction model. That introduces a whole host of other things to optimize though.. you have to select the noise matrices, etc, which I guess can be done via simulation/maximum likelhood, etc.
Do you have any general guidelines for 'good' r-squared values of the 1-step forecasts of levels?
I estimated a model of 6 variables and 1 cointegrating vector, 34 lags.
The r-squared values of the VECM 1-step forecasts range from 7% to 16%
I calculated r-squared values for the 1-step forecasts using univariate ARMA models on the differences and the r-squares were very poor (0.25% or so) so the 7-16 results seem really good to me.
I suppose the proper way to forecast all the prices in realtime is to use an iterated kalman filter and use the error estimates for position sizing.. and betas for hedging?
Do you have any general guidelines for 'good' r-squared values of the 1-step forecasts of levels?
I estimated a model of 6 variables and 1 cointegrating vector, 34 lags.
The r-squared values of the VECM 1-step forecasts range from 7% to 16%
I calculated r-squared values for the 1-step forecasts using univariate ARMA models on the differences and the r-squares were very poor (0.25% or so) so the 7-16 results seem really good to me.
I suppose the proper way to forecast all the prices in realtime is to use an iterated kalman filter and use the error estimates for position sizing.. and betas for hedging?
One should respect public opinion insofar as is necessary to avoid starvation and keep out of prison, but anything that goes beyond this is voluntary submission to an unnecessary tyranny. --Bertrand Russell
- Nonius
- Posts: 0
- Joined: Thu Jan 01, 2004 12:00 am
Cointegration and mean-reversion
[b][i]The ECM uses cointegration to provide an 'error correction' for a longer term relationship between two or more variables.[/i][/b]
dgn2,
here is what I was thinking. the error correction is for longer term relationships, but, I would think that in terms of splicing together thousands of short term forecasts with that error correction term to the drift estimate, then, sort of by a law of large numbers argument, that you will be better off including that error correction even if your trade horizon is very short. would you agree? in other words, you have a wealth process associated with your (possibly short term) trading strategy, and this wealth process should, in limit, be higher than it would have been had you NOT included that error correction term.
dgn2,
here is what I was thinking. the error correction is for longer term relationships, but, I would think that in terms of splicing together thousands of short term forecasts with that error correction term to the drift estimate, then, sort of by a law of large numbers argument, that you will be better off including that error correction even if your trade horizon is very short. would you agree? in other words, you have a wealth process associated with your (possibly short term) trading strategy, and this wealth process should, in limit, be higher than it would have been had you NOT included that error correction term.
Chiral is Tyler Durden
- dgn2
- Posts: 0
- Joined: Thu Jan 01, 2004 12:00 am
Cointegration and mean-reversion
Yes, I agree Nonius. In the ideal world I would like to be scalping on a group of things at very high frequency and using the cointegration to help remove the trend across the group. In my mind it is kind of like having one process that finds rich/cheap and another process that keeps the book roughly immunized against the trend. The cointegration piece is part of the mechanism that works to keep you roughly immunized against the trend. Sometimes you will lose some on the trend mismatch, sometimes you will gain some on the trend mismatch, but the point of the cointegration-type correction is to be roughly flat over changes in the trend for the group as a whole over the long run. In my view, one still has to find other things to determine which things to be long and which things to be short. The correction mechanism is meant to allow one to focus on the mean-reversion in individual instruments. It is not likely ever enough to just have things cointegrated and to trade divergence/convergence. If you can find something like long memory in returns it seems unlikely to me that you can capitalize on it without somehow economically removing the gaps and pronounced trends. Hopefully we will see whether I am full of sheah over the next little while. I definitely don't have all the answers
crowlogic,
You seem like you have the right idea from my perspective. I am looking at something related to your first paragraph and you can read what I posted about that a couple years ago on W****tt. I am just getting back to the scalping on groups after working on a bunch of other FX sheah.
crowlogic,
You seem like you have the right idea from my perspective. I am looking at something related to your first paragraph and you can read what I posted about that a couple years ago on W****tt. I am just getting back to the scalping on groups after working on a bunch of other FX sheah.
...WARNING: I am an optimal f'er
- crowlogic
- Posts: 0
- Joined: Thu Jan 01, 2004 12:00 am
Cointegration and mean-reversion
dgn2, I checked your old posts on W****tt.. reallly good stuff, especially liked your approach to modelling/theory, etc. I'm not sure I found the exact posts you were referring to, do you have some keywords that might ring a bell?
So now that I have some reasonable return forecasts.. what exactly is the approach to trading them? It's obvious to trade spreads because that is an instanenous measure. How do you determine the optimal forecast horizon, and, as you approach that horizon how do you modify your position? I've been trying to find some literature on how to apply trading rules to moving return forecats but im having trouble figured out what to search on.
I've hacked up some existing VECM code from the spatial-econometrics library and used to it generate a couple of quick plots.. the dashed lines are the forecasts.
All I'm trying to do here is get the 'basic' cointegrated vecm trading model up and running and then I'll refine from there. So far everything I've been doing has been using historical data, theory testing, etc, I just want to get the final component plugged into my system and have it start generating trading signals in real time and simulating trades so I can start to get a more real-word feel for how the model is going to behave.
Will the impulse-response analyis be handy in designing trading rules?
Also, should I remove any constants from the auto-regressive terms? I would think so since I want my predictions to flatline after some horizon rather than drift in either direction.
[img]/User%20Files/1210/vecmForecast3.png[/img]
So now that I have some reasonable return forecasts.. what exactly is the approach to trading them? It's obvious to trade spreads because that is an instanenous measure. How do you determine the optimal forecast horizon, and, as you approach that horizon how do you modify your position? I've been trying to find some literature on how to apply trading rules to moving return forecats but im having trouble figured out what to search on.
I've hacked up some existing VECM code from the spatial-econometrics library and used to it generate a couple of quick plots.. the dashed lines are the forecasts.
All I'm trying to do here is get the 'basic' cointegrated vecm trading model up and running and then I'll refine from there. So far everything I've been doing has been using historical data, theory testing, etc, I just want to get the final component plugged into my system and have it start generating trading signals in real time and simulating trades so I can start to get a more real-word feel for how the model is going to behave.
Will the impulse-response analyis be handy in designing trading rules?
Also, should I remove any constants from the auto-regressive terms? I would think so since I want my predictions to flatline after some horizon rather than drift in either direction.
[img]/User%20Files/1210/vecmForecast3.png[/img]
One should respect public opinion insofar as is necessary to avoid starvation and keep out of prison, but anything that goes beyond this is voluntary submission to an unnecessary tyranny. --Bertrand Russell
- dgn2
- Posts: 0
- Joined: Thu Jan 01, 2004 12:00 am
Cointegration and mean-reversion
crowlogic, I don't think you will find a single optimal forecast horizon. I would suggest looking at a set of horizons, particularly to start. I am also not sure that you want to remove the auto-regressive terms. I definitely wouldn't.
Check out the books written by Ralph Vince. His book, "The Mathematics of Money Management: Risk Analysis Techniques For Traders" outlines a parametric kelly-type measure (fraction of your bankroll) that can be modified using some of the newer developments in risk management. You can learn stuff from VaR and ETL even if you don't plan to use it the way it gets used at a large institution. I would also suggest you take a look at the book by Kevin Dowd.
Check out the books written by Ralph Vince. His book, "The Mathematics of Money Management: Risk Analysis Techniques For Traders" outlines a parametric kelly-type measure (fraction of your bankroll) that can be modified using some of the newer developments in risk management. You can learn stuff from VaR and ETL even if you don't plan to use it the way it gets used at a large institution. I would also suggest you take a look at the book by Kevin Dowd.
...WARNING: I am an optimal f'er