trendmanagement / Tmqr-framework-2

3 stars 0 forks source link

risk parity volatility example HOE alpha with CLE semi future. #23

Open spickering-git opened 7 years ago

spickering-git commented 7 years ago

image The inputs worksheet includes the campaign data for ES and ZN. Columns J and P are the percent changes. The standard deviations of the daily changes are calculated and entered into C3 and C4. The correlation matrix is calculated in D3:E4

image On the calculations sheet a co-variance matrix is calculated

image want to equalize the 'contribution to portfolio risk' by adjusting the 'optimized weights'

RiskParity_3.1 - 2 instrument.xlsx

nikolas-joyce commented 7 years ago

Alex this was the worked example where we were trying to make a product like HOE use n units of another product's liquid, options based EXO as a hedge. The example would be to take a short HOE futures alpha and hedge it with a calculated # of EXO semi futures. We would the need the ratio to be dynamic and update over time to respond to changes in volatility and correlation. This is contemplated in the above example.

alexveden commented 7 years ago

Why don't we take dollar volatility like AVG(H-L) or ATR() or Median(H-L) of asset and equalize it by dollar volatility of the other asset? I'm just thinking that correlations and co-variance matrices are useful when we trying to select assets to pair dynamically. In our case when we know the structure of the spread and understand cointegration of assets probably we don't to do extra calculation.

But some times especially for multileg spreads my way is not the best. Probably it's better to use optimization of hedge weights to reduce portfolio variance, for example at the end of the each month/week.

What do you think?

nikolas-joyce commented 7 years ago

Tell me more. Would the optimized solution be different than the one arrived at from the risk parity/ covariance approach?

Sent from my iPhone

On Jul 19, 2017, at 8:29 PM, alexveden notifications@github.com<mailto:notifications@github.com> wrote:

Why don't we take dollar volatility like AVG(H-L) or ATR() or Median(H-L) of asset and equalize it by dollar volatility of the other asset? I'm just thinking that correlations and co-variance matrices are useful when we trying to select assets to pair dynamically. In our case when we know the structure of the spread and understand cointegration of assets probably we don't to do extra calculation.

But some times especially for multileg spreads my way is not the best. Probably it's better to use optimization of hedge weights to reduce portfolio variance, for example at the end of the each month/week.

What do you think?

— You are receiving this because you were assigned. Reply to this email directly, view it on GitHubhttps://github.com/trendmanagement/Tmqr-framework-2/issues/23#issuecomment-316586447, or mute the threadhttps://github.com/notifications/unsubscribe-auth/ARobLIRbwdK5_sdQ45JarFu2SrW6iayNks5sPsmOgaJpZM4OdGiF.

alexveden commented 7 years ago

I dont think so, due to contract rounding the difference will be barely significant.

Отправлено из Mail.Ru для Android четверг, 20 июля 2017г., 07:45 +04:00 от NikolasJoyce notifications@github.com :

Tell me more. Would the optimized solution be different than the one arrived at from the risk parity/ covariance approach?

Sent from my iPhone

On Jul 19, 2017, at 8:29 PM, alexveden <notifications@github.com<mailto: notifications@github.com >> wrote:

Why don't we take dollar volatility like AVG(H-L) or ATR() or Median(H-L) of asset and equalize it by dollar volatility of the other asset? I'm just thinking that correlations and co-variance matrices are useful when we trying to select assets to pair dynamically. In our case when we know the structure of the spread and understand cointegration of assets probably we don't to do extra calculation.

But some times especially for multileg spreads my way is not the best. Probably it's better to use optimization of hedge weights to reduce portfolio variance, for example at the end of the each month/week.

What do you think?

— You are receiving this because you were assigned. Reply to this email directly, view it on GitHub< https://github.com/trendmanagement/Tmqr-framework-2/issues/23#issuecomment-316586447 >, or mute the thread< https://github.com/notifications/unsubscribe-auth/ARobLIRbwdK5_sdQ45JarFu2SrW6iayNks5sPsmOgaJpZM4OdGiF >. — You are receiving this because you were assigned. Reply to this email directly, view it on GitHub , or mute the thread .

alexveden commented 6 years ago

I've finished some prototype of HOE/RBE hedging, and compared 2 types of hedge:

  1. 1:1 spread
  2. 1:beta hedge coef.
  3. 1:vola hedge coef.

Beta Coef. = Covariance(r1, r2) / Variance(r2) = Correlation(r1, r2) * (stdev(r1) / stdev(r2) ) ( https://en.wikipedia.org/wiki/Beta_(finance))

Volatility coef. = HOE{Median(H-L)} / RBE{Median(H-L)}

The results: image

image

The HOE-CLE spread: image

I would say that volatility based hedging produces more stable spreads (more mean-reversible process), but the downside of this approach you should manually select spread instruments to be sure that they have cointegration.

Also I've noticed that beta hedge ratio is very sensitive to period window, because correlations and StDevs are very volatile inside tight windows.

alexveden commented 6 years ago

So finally, I need your confirmation that I've understood your idea correctly (including #19).

Here is a description of the generic algorithm: The purpose: build alphas based on MAIN instrument with dynamic hedging using the another instrument future or EXO index.

When the alpha in the position, the algorithm should calculate hedge ratio based on 'beta' or 'volatility' equality and open hedge. This algorithm should be universal enough to utilize different hedge EXOs based on their volatility and correlation with MAIN instrument.

p.s. Why it's not simpler to create HOE/RBE EXO (Spread index, futures only) and use it as the underlying asset for alphas?

nikolas-joyce commented 6 years ago

The hoe/cle is a legitimate alternative. I wanted to have a vehicle which approximates a risk limited exposure that is why the generic algorithm is a futures position hedged by an EXO. In the the case of the fundamentally cointegrated like the s&p and the sub indexes the approach we are working on should give us the ability to approach risk limitation.

Sent from my iPhone

On Jul 24, 2017, at 12:29 AM, alexveden notifications@github.com<mailto:notifications@github.com> wrote:

So finally, I need your confirmation that I've understood your idea correctly (including #19https://github.com/trendmanagement/Tmqr-framework-2/issues/19).

Here is a description of the generic algorithm: The purpose: build alphas based on MAIN instrument with dynamic hedging using the another instrument future or EXO index.

When the alpha in the position, the algorithm should calculate hedge ratio based on 'beta' or 'volatility' equality and open hedge. This algorithm should be universal enough to utilize different hedge EXOs based on their volatility and correlation with MAIN instrument.

p.s. Why it's not simpler to create HOE/RBE EXO (Spread index, futures only) and use it as the underlying asset for alphas?

— You are receiving this because you were assigned. Reply to this email directly, view it on GitHubhttps://github.com/trendmanagement/Tmqr-framework-2/issues/23#issuecomment-317341224, or mute the threadhttps://github.com/notifications/unsubscribe-auth/ARobLCeKXQSbqQjNVe-hB8KFFAWcMuBRks5sREfZgaJpZM4OdGiF.

nikolas-joyce commented 6 years ago

If that last comment was not clear enough i will probably have a use for both the HOE/CLE futures only types of spread as an alpha input and the HOE alpha plus CLE semi future.

alexveden commented 6 years ago

I've implemented HOE/CLE and ES/ZN spreads. https://10.0.1.2:8889/notebooks/indexes/EXO%20ES-ZN%20Spread.ipynb https://10.0.1.2:8889/notebooks/indexes/EXO%20HOE-CLE%20Spread.ipynb

Both of them support 'vola' and 'beta' hedge ratio calculation, from my point the 'vola' type of hedging is more reliable than 'beta'. But you can play with it as you wish.

You can set spread composition and hedge type in the context: image

Examples of spreads:

HO/CL

image

ES/ZN

beta hedging has a bug, due to ES/ZN negative correlation of daily returns! image

alexveden commented 6 years ago

Here is an alpha hedged by semi-future:

  1. CL RiskReversal semi-future calculation (I was not sure about position management and turned off all management rules except rollovers, uncomment these rules in the code if you need them) https://10.0.1.2:8889/notebooks/indexes/EXO%20Vanilla%20CL%20RiskReversal%20(Semi-future).ipynb

  2. The Alpha https://10.0.1.2:8889/notebooks/alphas/Strategy_DSP_LPBP_Combination%20-%20with%20index%20hedge%20HOE-CL.ipynb#Hedge-ratios

The context in very similar

image

Also added information about the hedge

image

Issues

In case of alpha 'beta' hedge algorithm seems to perform well, but 'vola' algorithm has issues due to extremely low EXO index volatility at some periods (because of using median and around zero volatility was occurred too often). This issue leads to extremely high hedge ratios and produces this ugly equity: image

I tried to replace 'meadian' volatility measurement by 'stdev' and the picture looks better: image

The 'beta' algorithm is also have downsides, for example the beta is a linear, but options payoffs are not linear at all.