1. Homepage
2. Programming
3. BUS 215F/FIN 215F Python and Applications to Business Analytics - Exercise 1. Foreign Exchange (FX) Arbitrage

# BUS 215F/FIN 215F Python and Applications to Business Analytics - Exercise 1. Foreign Exchange (FX) Arbitrage

FinanceForeign ExchangePythonBusiness AnalyticsBUS 215FPython and Applications to Business AnalyticsFIN 215FPython and Applications to FinanceUKBrandeis University

# Assignment: Foreign Exchange (FX) Arbitrage

Professor Ahmad Namini Python and Applications to Business Analytics Python and Applications to Finance

## Exercise 1. Foreign Exchange (FX) Arbitrage

The foreign exchange (FX) market, where one currency is traded (exchanged) for another, is the largest financial market in the world, with about 5 trillion US dollars (USD) being traded everyday. This market determines the exchange rate for local currencies when someone travels abroad and when international banks settle accounts between each other.

If one wishes to convert currency A into currency B, one could do the following:

• Sell currency A and simultaneously Buy currency B.

For currencies of underdeveloped nations, typically one converts to USD first and then converts the USD to the other currency. Converting from currency A to currency B one would do the following:

1. Sell currency A and simultaneously Buy currency USD
2. Sell currency USD and simultaneously Buy currency B

Graphically, one can see the process of converting from one currency to another currency if buy and sell quotes of any currency to and from USD is known. Also, a fee is usually present that accounts for the exchange trader (bank) to underwrite the transaction.

To model FX currency exchange rates from any two currencies, typically a quantitative analyst will create a weighted graph, where each node represents a currency (e.g. CNY, JPY, USD) and each edge represents the conversion to and from the currency and the base currency. The weighted graph’s edge cost is the FX conversion rate between the two end currencies. Attached with this assignment is Python code that uses the Dijkstra’s Algorithm for finding the shortest path from two nodes along a weighted network, i.e. what is the conversion rate between currencies A and currency B. From the results of the code given, modify the code so that CNY becomes the base currency and re-run to compute exchange rates between all currencies. Are they the same exchange rates when using USD or any other currency as the base currency.