Forex Factory (https://www.forexfactory.com/forum.php)
-   Trading Discussion (https://www.forexfactory.com/forumdisplay.php?f=11)
-   -   Mathematical Relationship between Forex pairs (https://www.forexfactory.com/showthread.php?t=565244)

davelansing Nov 8, 2015 2:14pm | Post# 1

Mathematical Relationship between Forex pairs
 
2 Attachment(s)
I posted this in my Journal, but thought it would be useful for a broader audience. Attached is an Excel spreadsheet that shows the calculated price relationships between the 7 majors and 22 crosses....a snapshot of the spreadsheet is shown below. Basically, the spreadsheet shows how the rate for any given currency pair can be calculated from many different pair sets, i.e. the mathematical dependency between all pairs. The exchange rate data is from late October, but you can input current exchange rate data if you wish.. I posted this because when reading through the forums, it seems that some traders are under the impression that exchange rates are completely independent of one another...not true...

Click to Enlarge

Name: 2015-11-08 14_15_29-Mathematical Relationship between Forex pairs.xlsx - Excel.png
Size: 83 KB

Please note that in several calculations, you need to take the reciprocal of the rate data. For example, to calculate the following rate data for:

EURJPY x CHFJPY = EURCHF

You need to take the reciprocal of CHFJPY:

EURJPY = 133.53
CHFJPY = 122.95 = 1/122.95 = 0.0081
133.53 x 0.0081 = 1.0861 = EURCHF

At the time of the above calculation, the bid on EURCHF = 1.0860

Hope that some folks find this useful....

Dave

Mathematical Relationship between Forex pairs.xlsx

diceman555 Nov 8, 2015 2:32pm | Post# 2

I personally could not agree more ,the intertwined relationships within a selected basket are far more revealing than the correlations show.they for the best part beat as one.

One such example would be early indications of break outs,establishing range can be determined along with volatilityand momentum to name a few

mathematician Nov 8, 2015 3:08pm | Post# 3

Hi Dave,

Yep! In fact, if you write the symbols in the "standard" notation, i.e. using a slash (like this EUR/USD), then actually the math works out exactly as it would in algebra. Then, the times when you need to take the reciprocal are obvious. In fact, you just divide instead of multiply.

In basic algebra, if you have A/B times B/C, then the Bs cancel out and you get A/C.
Similarly: (EUR/USD)*(USD/JPY) = EUR/JPY

Also, in basic algebra, if you have A/B divided by C/B, then the Bs cancel again to give you A/C. You could also think of (A/B)/(C/B) as (A/B)*(B/C), the normal rule of dividing fractions as multiplying by the reciprocal.
Similarly: (EUR/JPY)/(CHF/JPY) = EUR/CHF or rather (EUR/JPY)*(JPY/CHF) = EUR/CHF ... note the reciprocal in the second version.

Pure math!

mathematician Nov 8, 2015 3:20pm | Post# 4

2 Attachment(s)
Here are the basic rules in a more mathematically-friendly notation:

Name:  multiplication.png
Views: 5702
Size:  2 KB
Name:  division.png
Views: 5703
Size:  3 KB

In fact, it is because of these rules that currency pairs are written as little fractions, like GBP/USD.

alphaomega Nov 8, 2015 3:39pm | Post# 5

Something cool on this topic!
Inserted Video

mathematician Nov 8, 2015 4:41pm | Post# 6

1 Attachment(s)
That is interesting, alphaomega.

I don't see why he's plotting some things in the negative quadrants because all the exchange rates are positive, whether you take the reciprocal or not. But I do see why those points all have the same slope (when he drew the line throgh those three points). When the x-value is the exchange rate with respect to the USD and the y-value is the exchange rate with respect to the EUR, then the slope between any two points will equal the EUR/USD exchange rate. Here's a proof for the slope between the CHF point and the JPY point. (You could do the same for the slope between the CAD point and the CHF point or any two distinct points and you'd get the same thing.)


Name:  latex-image-2.png
Views: 6427
Size:  31 KB

Remember from high school math that the slope between two points is the change in y-vaules over the change in x-values. Also, to go from step two to step three, I just multiplied the numerator and the denominator by CHF and by JPY, (in other words, by CHF*JPY). Then I just factored out the EUR from the numerator and factored out the USD from the denominator. Finally, I cancelled the CHF - JPY.

mathematician Nov 8, 2015 5:05pm | Post# 7

I personally could not agree more ,the intertwined relationships within a selected basket are far more revealing than the correlations show.they for the best part beat as one. One such example would be early indications of break outs,establishing range can be determined along with volatilityand momentum to name a few
All of these relationships are interesting, but I'm afraid they won't really give you an edge in trading. Now, occasionally, the EUR/JPY price and the USD/JPY price might not multiply to give you the EUR/USD exact price. When an opportunity like this arises, it's called triangular arbitrage. But there are algorithmic traders out there who have very fast computers and very fast connections to the market, and they are specifically looking for these arbitrage opportunities. Whenever they find them, they jump on them in the blink of an eye, and by trading large amounts over very small distances (and by competing with other traders trying to do the same), the gap quickly closes. In fact, it is because of arbitrageurs that these mathematical relationships hold. They are the ones who keep the prices aligned.

So, for example, if EUR/JPY makes a breakout on some small scale, and USD/JPY remains basically unchanged, that is not an early signal that EUR/USD will not make a breakout. In fact, EUR/USD would have made its breakout at the same time as the EUR/JPY did. Furthermore, even if EUR/JPY does shoot up before EUR/USD (again, assuming that USD/JPY is unchanged), does that mean that EUR/USD will have to shoot up soon to stay in line, or does that mean that EUR/JPY will have to drop back down to stay in line?

So unless you want to get into the arbitrage game (and you'll need lots of money, expensive equipment, and a zero-lag connection to the market), then I'm afraid these relationships won't help you much. I could be wrong, though. And if there's a relationship anyone would like to explore, I'd be happy to provide some mathematical insight, if I can.

davelansing Nov 8, 2015 7:38pm | Post# 8

Hi Mathematician,

Thanks for the clearer algebraic expressions...by convention I just leave out the "/ " sign, but nonetheless you are right that the relationships themselves don't give you an edge (other than stat arb). But for hedging purposes, it's useful to know what those relationships are in order to minimize swap costs..plus, as diceman555 pointed out, you can set up some interesting basket trades...

Dave

mathematician Nov 9, 2015 8:56pm | Post# 9

Dave and Diceman,


Yeah, that's true: It's good to know the cheapest (lowest overall spread) way to trade the pairs you ultimately want to trade. For example, maybe some brokers have a higher spred on, say, AUD/CAD then the spread on AUD/USD and USD/CAD combined, so then it would be cheaper to "factor out" AUD/CAD and trade your position across AUD/USD and USD/CAD.

That's true, D-man, you could get some intersting baskets going. Personally I find that it's helpful to look at basic correlations just so that you don't have too much redundancy the list of markets you watch. I don't even bother with doing an exact, numerical calculation of the correlation between all pairs. I just zoom out on a daily or weekly chart and compare the basic flow of price. If I see one pair making a huge uptrend across that time, another pair making a big 'V', and another just range bouncing all over the place, then I know these pairs move rather independently of each other, so I know I'm not over-exposed in one currency or another if I happen to have trades in all of them going at the same time.

mathematician Nov 9, 2015 9:37pm | Post# 10

3 Attachment(s)
Another thing I considered for a while was to only focus on one currency triangle, i.e. say you're interested in GBP, USD, and JPY: Trade the GBP/USD, the USD/JPY, and the GBP/JPY. What I like about that idea is that because of the relationship GBP/JPY = GBP/USD*USD/JPY, it's very likely that I will see some good volatility in at least one of those markets on any given day, week, etc. Basically the only way to get no volatility is if all three were not moving much.

You could even have two isolated triangles, like GBP/USD/JPY and AUD/NZD/CAD, shown here:
Click to Enlarge

Name: two triangles.png
Size: 57 KB

Or you could take 4 currencies and make your watchlist the 6 possible combinations between them, shown here as a square with both diagonals:
Click to Enlarge

Name: K4.png
Size: 28 KB

... or shown here in 3D as a tetrahedron:
Click to Enlarge

Name: tetrahedron K4.png
Size: 50 KB

These nodes connected in every possible combination are called "complete graphs" in graph theory. By representing every pair of two currencies, you could completely cover the entire interaction between your basket of currencies so that a substantial move is almost guaranteed in at least one of these pairs every day.

roger44 Nov 10, 2015 1:23am | Post# 11

for example (not actual value, some segment trend on the candle chart, with certain inclination : sometimes) ;
usd/chf = ((dollar index(eur/usd)) x height) / sin(theta) + y
where y is a constant.

san99 Nov 10, 2015 4:52pm | Post# 12

{quote} All of these relationships are interesting, but I'm afraid they won't really give you an edge in trading. Now, occasionally, the EUR/JPY price and the USD/JPY price might not multiply to give you the EUR/USD exact price. When an opportunity like this arises, it's called triangular arbitrage. But there are algorithmic traders out there who have very fast computers and very fast connections to the market, and they are specifically looking for these arbitrage opportunities. Whenever they find them, they jump on them in the blink of an eye,...
Thanks for your clarification, I too have noticed the underlying algebra but wasn't sure how to draw any real conclusions over a pair's movement as a result of them. The one thing I have been trying to figure out more of is that with certain currencies, AUD and NZD especially (and especially the latter), the substantial discount to the dollar currently means that when AUD/USD or NZD /USD make a move, they affect any of the crosses they are a part of more than the counterpart. For example in GBP/NZD, 1 pip move of GBP/USD has less impact on GBP/NZD rate than the same 1 pip move by NZD/USD. But aside from this percent impact, not sure how else that can be used to determine trend or bias for the cross.

Likewise, some crosses like EUR/CHF (as long as SNB is not intervening!!), AUD/CAD and to a slightly lesser extent AUD/NZD are highly ranging unless one or both of the underlying USD counterparts are moving strongly.

mathematician Nov 10, 2015 8:21pm | Post# 13

2 Attachment(s)
{quote} ... The one thing I have been trying to figure out more of is that with certain currencies, AUD and NZD especially (and especially the latter), the substantial discount to the dollar currently means that when AUD/USD or NZD /USD make a move, they affect any of the crosses they are a part of more than the counterpart. For example in GBP/NZD, 1 pip move of GBP/USD has less impact on GBP/NZD rate than the same 1 pip move by NZD/USD. ...
That's a great observation! Again, I'm afraid it won't really shed much light on where any currency is heading in the future, but I can explain why you're seeing this phenomenon.

Are you familiar with calculus at all? Even just high school or first-year-university calculus will do. It's all related to the product rule and quotient rule for derivatives.

The Product Rule for Derivatives

Let's start with the product rule, which is the rule we have to use when one pair is composed of a multiple of two other pairs. For example, EUR/JPY = (EUR/USD)*(USD/JPY). In general, we can just write it like this: C = A*B. So some currency pair, C, is the product of currency pair A times currency pair B.

Now we will take the derivative with respect to time. (Remember that a derivative is basically a measure of how one variable changes with respect to another. So when you do a derivative with respect to time, you're looking at how that variable changes through time.) Below, I've first shown the derivative using the product rule for general currencies A, B, and C in calculus notation. Then I write a simplified version just using "Delta" to represent the change in some value. Finally, I wrote it out for the example of EUR/JPY = (EUR/USD)*(USD/JPY).

Click to Enlarge

Name: ProductRule.png
Size: 21 KB

What this means is this: The change in EUR/JPY (say the change between the open and close for a particular day) is equal to the closing price of EUR/USD on that day times the change in the USD/JPY over that day, plus the closing price of USD/JPY on that day times the change in the EUR/USD over that day. Remember that the change should be calculated as final price minus initial price, so Close - Open.

For example, if we look at EUR/JPY, EUR/USD, and USD/JPY for November 9th, here's what I get:

Inserted Code
EUR/JPY: open 132.87  close 132.38  ∆EUR/JPY -0.49
EUR/USD: open 1.0769  close 1.0743  ∆EUR/USD -0.0026
USD/JPY: open 123.38  close 123.22  ∆USD/JPY -0.16
 
∆EUR/JPY based on the product rule
∆EUR/JPY = (EUR/USD)*(∆USD/JPY) + (USD/JPY)(∆EUR/USD)
         = (1.0743)*(-0.16) + (123.22)(-0.0026)
         = -0.49226

As you can see, ∆EUR/JPY as calculated from the derivative is very close to the actual change between the high and low that happened over that day. There will be a slight discrepancy because we're looking at a large change over a long period of time (one day), but derivatives are supposed to represent instantaneous changes, therefore this is just an approximation. Normally to make your approximation more accurate, you could look at the change over a smaller period of time, so you could try looking at the change over just one minute. However, that will not really work with the market data we get because we don't really get a precise measurement of the change. The smallest unit we can get is usually one pip. In fact, calculus is designed to work with continuous values, but prices are actually discrete since they move in whole-number multiples of pips (pipettes at best). We don't have the full richness of the real numbers. Nevertheless, it's pretty interesting to see how this approximation is pretty good.

The Quotient Rule for Derivatives

Now we have enough background to talk about GBP/NZD and why it seems to be affected more by changes in NZD/USD than by changes in GBP/USD. The key lies in the fact that GBP/NZD = GBP/USD divided by NZD/USD. It's not a product of the other two pairs; it's quotient, so we have to use the quotient rule for derivatives. In general, we can just write it like this: C = A/B. So some currency pair, C, is currency pair A divided by currency pair B.

Again, we will take the derivative with respect to time, but the derivative of a quotient is quite different than the derivative of a product. As before, I've first shown the derivative using the quotient rule for general currencies A, B, and C in calculus notation. Then I write a simplified version just using "Delta" to represent the change in some value. Finally, I wrote it out for the example of GBP/NZD = (GBP/USD)(NZD/USD).

Click to Enlarge

Name: QuotientRule.png
Size: 22 KB

I'm too lazy to find prices and write out a numerical example for this one, but notice how this formula is different from the product rule: In this case, the denominator of the whole fraction is the price of NZD/USD, and not only that, but it's squared in the denominator! So changes in the NZD/USD will have a bigger impact than changes in GBP/USD.

davelansing Nov 10, 2015 8:46pm | Post# 14

Excellent posts Mathematician!!! As I said previously, we should be able to use this information to develop a balanced basket such that it earns a consistently modest profit with "mitigated" risk due to multiple-pair hedging...and we can make the basket so that swap is in our favor, or at least that a net negative swap is minimized. A new project!

Dave

ezcurrency Nov 10, 2015 9:17pm | Post# 15

Excellent posts Mathematician!!! As I said previously, we should be able to use this information to develop a balanced basket such that it earns a consistently modest profit with "mitigated" risk due to multiple-pair hedging...and we can make the basket so that swap is in our favor, or at least that a net negative swap is minimized. A new project! Dave
I looked at this a while back, and created a balanced basket between multiple pairs ... the result was it was exactly balanced (no net exposure) that equity never changed. It cost the spread for each pair to get into the basket. Using Oanda, you can get the lot size exact to no net exposure.

The problem is no exposure: equity won't change.

Regards,
EZ

mathematician Nov 10, 2015 9:26pm | Post# 16

I don't think I understand what you mean by "swap" in this context.

mathematician Nov 10, 2015 9:32pm | Post# 17

{quote} I looked at this a while back, and created a balanced basket between multiple pairs ... the result was it was exactly balanced (no net exposure) that equity never changed. It cost the spread for each pair to get into the basket. Using Oanda, you can get the lot size exact to no net exposure. The problem is no exposure: equity won't change. Regards, EZ
Yes, I'm not surprised. One has to take on some risk in order to make a profit.

I find these relationships interesting, but I don't really use them because I don't think they can give me any sort of edge. In fact, this sort of over-analysis tends to get in the way. I think it was said best by Brian Monieson.

A quote from Alexander Elder's Come Into My Trading Room:
A high level of education can be a handicap in trading. Brian Monieson, a noted Chicago trader, once said in an interview, "I have a Ph.D. in mathematics and a backgroun in cybernetics, but I was able to overcome those disadvantages and make money."

davelansing Nov 10, 2015 9:52pm | Post# 18

Hi EZ,

The few baskets I've been testing are not "net zero" exposure, albeit the number of units in each triangular hedge is volatility-adjusted (relative to the most volatile pair in the hedge) such that the high low equity swings of each triangular hedge is very minor. But I believe that's the advantage... you pool enough of these triangular baskets together and let them run (EURAUD(s)+AUDCAD(s)+EURCAD(b)), (GBPNZD(b) + GBPAUD(s) + AUDNZD(b)), (USDJPY(b)+USDCAD(s)+CADJPY(s)), etc...the equity sum of the total basket is generally net positive, with very low drawdown. Use 1% equity to open each pair and close the entire basket once the %gain is equal to ~0.5-1% of your equity. Not a "get rich quick" by any stretch of the imagination, but profitable nonetheless...

san99 Nov 10, 2015 11:30pm | Post# 19

{quote} That's a great observation! Again, I'm afraid it won't really shed much light on where any currency is heading in the future, but I can explain why you're seeing this phenomenon. Are you familiar with calculus at all? Even just high school or first-year-university calculus will do. It's all related to the product rule and quotient rule for derivatives. ...Then I write a simplified version just using "Delta" to represent the change in some value. Finally, I wrote it out for the example of GBP/NZD = (GBP/USD)(NZD/USD). {image} I'm too lazy...
Thanks much for taking the time to post your explanation, very clear and. Am indeed familiar with calculus so a great refresher (have to confess I am a wannabe quant here though was never *that* good in the mathematics of finance, unfortunately !). But had never thought of looking at the crosses in terms of calculus and rates of change -- whole new angle now, pretty cool! With the GBP/NZD example, I was also thinking though that you could just use the same product rule as with the first example you gave, by multiplying GBP/USD with USD/NZD. But I guess for the sake of explaining NZD's disproportionate effect we can see how the division does the amplification.

So in the case of EUR/AUD -- when AUD/USD was .9, that meant a square component in the denominator of .81 yielding a 1.23x multiplier effect from it. Now that we have AUD/USD at .7, the .49 square gives a 2.04x multiplier effect Similarly NZD/USD when it was .85 was giving 1.39x versus 2.37x at 0.65. Both currencies affecting twice as much now!

ezcurrency Nov 12, 2015 2:00am | Post# 20

Mathematician,

Have you ever looked at co-integrated pairs and triplets? I did some work on it a while back, and will revisit after my current projects are finished and trading.

Basically I did this:
1) Download 1 year of hourly closing data on 25 currency pairs. This is done daily.
2) Use R (an open source statistical analysis program) to merge all by Date / Hour
3) Remove missing data fields

(4) and below are for 2 pairs X and Y, but if you do 3 pairs X, Y, and Z its similar ... just a bit more complicated

4) Run a linear regression of each pair against all other pairs to calculate the trading coefficient. Side note: For 2 pairs, I run principal component analysis so the coefficients are reciprocals of each other. So if I run linear regression of X on Y, when I do Y on X the coef. are inverse. For 3 pairs, I do X vs. Y and Z to get 2 coef.
5) Calculate the spread. For 2 pairs, spread = X - Coef * Y
6) Run the Augmented Dickey Fuller test to see if the spread is mean reverting (P-value < 0.05)
7) Calculate mean value of spread for past 1 year, and +/- 1 and 2 stdev lines
8) Save all of this to output (only mean reverting spreads), so I can sort in Excel
9) Look for cointegrated pairs below -2 stdev to buy, exit at mean. Vice-versa for shorts.

Ex: If I have AUDCAD - 0.3EURCHF as the spread, and its at -2.1 stdev, I would buy AUDCAD and short 0.3 units of EURCHF (for every unit of AUDCAD).

10) Exit at the mean value of spread

I want to improve this more by looking at short term trends on 5, 15 min charts to enter long AUDCAD, and short 0.3 units of EURCHF. My EA can do that.

Anyway, just a project I have on the back burner. Have you ever done anything like this?

Regards,
EZ


© Forex Factory