"How much profit can you generate". Well, if not specified - either 0 (if no arbitrage avaliable) or inf (do the cycle for eternity).
For arbitrary number of currencies and the algorithms - we need a criteria.
- Don't use the same edge twice
- Don't use the exact same path twice (it can be dodged by inserting a random vertex in the middle e.g. USD -> EUR -> GBP into USD -> EUR -> RUB -> GBP, RUB here just for condition not for profit).
If there are n currencies, we can construct a graph (Taking currencies as nodes and conversion rate as weights, for ex: CurrA/CurrB = x , then A ---w_X--->B)
And then in this graph if we can find a cycle whose product of weights of all the edges is greater than 1, then it's an arbitrage.
"How much profit can you generate". Well, if not specified - either 0 (if no arbitrage avaliable) or inf (do the cycle for eternity).
For arbitrary number of currencies and the algorithms - we need a criteria.
- Don't use the same edge twice
- Don't use the exact same path twice (it can be dodged by inserting a random vertex in the middle e.g. USD -> EUR -> GBP into USD -> EUR -> RUB -> GBP, RUB here just for condition not for profit).
If there are n currencies, we can construct a graph (Taking currencies as nodes and conversion rate as weights, for ex: CurrA/CurrB = x , then A ---w_X--->B)
And then in this graph if we can find a cycle whose product of weights of all the edges is greater than 1, then it's an arbitrage.