CS代写 Triangular arbitrage is the result of a discrepancy between three or more f

Triangular arbitrage is the result of a discrepancy between three or more foreign currencies
that occurs when the currency’s exchange rates do not exactly match up. A trader employing
triangular arbitrage, for example, would exchange an amount at one rate (EUR/USD),
convert it again (EUR/GBP), and then convert it finally back to the original (USD/GBP),

Copyright By PowCoder代写 加微信 powcoder

and assuming zero or low transaction costs, net a profit.
Given n currencies, and an n x n matrix M where Mi is the rate at which one can exchange
currency i into currency , where Mi; = 1 for i = 0, …
., n- 1 and Mij= 1/M;. We assume
the transaction cost is 0.
Problem 8.1 (10 points). Write a function to return true if any triangular arbitrage
opportunities exist for a given numpy array M. For example, your function should return
false for Mi
as it does not admit triangular arbitrage. On the other
hand, your function should return true for M2
exists where trader can turn 1 unit of currency O into 2 units by the following:
because an arbitrage
• Converting 1 unit of currency 0 to 4 units of currency 2
Converting 4 units of currency 2 to 1 unit of currency 1

• Converting 1 unit of currency 1 to 2 units of currency 0
Since this question does not require you to identify the arbitrage paths, your implementation
should not implement any graph searching algorithms. Instead, your implementation should
only consider the basic properties of the input matrix (e.g. determinant, eigenvalue, norm,
rank, trace etc). You can make use of the corresponding methods in numpylinalg. Please
qive a brief reasoning for your algorithm.
def hasArbitrage (M : list )->bool:
Problem 8.2 (20 points). Write a function to return an arbitrage path for currency 0 if
such opprtunities exist.
• For Mi, your function should return an empty list as no arbitrage opportunities exist
• For M2, your function should return [0, 2, 1, 0
def listArbitrage (M: list)-›list :

# Programming 8.1
def hasArbitrage(M : list) -> bool:
@param M: an n by n list of list
@return: boolean indicating if arbitrage exists or not
@package: you may use numpy for computation of matrix properties
import numpy as np
# Programming 8.2
def listArbitrage(M : list) ->list:
@param M:an n by n list of list
@return: a list of the arbitrage path if exists, otherwise [I
@Instruction: You may use any built-in data structures and built-in operations on these data structures
@package: you may use the numpy package
import numpy as np

程序代写 CS代考 加微信: powcoder QQ: 1823890830 Email: powcoder@163.com