README.md
Arbitrage finds the arbitrage combinations of currencies of a given currency rates.
For the possible currency rates of:
USD | 1 | 0.741 | 0.657 | 1.061 | 1.005 |
EUR | 1.349 | 1 | 0.888 | 1.433 | 1.366 |
GBP | 1.521 | 1.126 | 1 | 1.614 | 1.538 |
CHF | 0.942 | 0.698 | 0.619 | 1 | 0.953 |
CAD | 0.995 | 0.732 | 0.650 | 1.049 | 1 |
the input shoul be:
[
[1, 0.741, 0.657, 1.061, 1.005],
[1.349,1, 0.888, 1.433, 1.366],
[1.521, 1.126, 1, 1.614, 1.538],
[0.942, 0.698, 0.619, 1,0.953],
[0.995, 0.732,0.650,1.049,1]
]
and the output would be:
[
{"combination":[1,3],"profit":1.000234},
{"combination":[3,1],"profit":1.000234},
{"combination":[0,1,2],"profit":1.000830168},
{"combination":[0,1,3],"profit":1.000265526},
{"combination":[0,1,4],"profit":1.0071449700000001},
{"combination":[0,2,4],"profit":1.00541367},
{"combination":[0,3,4],"profit":1.0060773349999999},
{"combination":[1,2,0],"profit":1.0008301679999998},
{"combination":[1,2,3],"profit":1.0003959359999999},
{"combination":[1,3,0],"profit":1.000265526},
...
]
Output Explanation:
The second combination tells changing USD -> EUR -> GBP -> USD will give a 1.000830168 profit.