## Currency exchange rates, directed graphs, and quivers

I always enjoy working with currency exchange rates because it gives me excuses to draw directed graphs. For example, an exchange rate EURUSD = 1.4 can be thought of as a directed edge from EUR to USD as shown below.

A fact of life when you work in finance is that you rarely have any say in the data available to you for analysis. When working with three currencies, e.g. USD, EUR, and KRW, it would be great if someone handed you a complete FX Matrix with all exchange rates filled in like

Instead, what is usually available is a list of exchange rates such as

With a little patience, you can usually figure out all the cross terms, e.g. it is obvious that from the given data we have

but we’d like to find a systematic way to do this that can be programmed.

So the thing I want to talk about here is starting with a list of exchange rates, i.e. FX Vector, we want to fill in as much of the FX Matrix as possible systematically. It turns out this process is identical to constructing a free category, i.e. quiver, from a directed graph.

In other words, we want to reinterpret the exchange rate as a morphism

Then, “filling in” the FX Matrix means finding all compositions of morphisms, e.g.

How would you do this? Here is what I did…

First, you take the given FX Vector and form an adjacency matrix. In the example above with EUR, USD, and KRW, the adjacency matrix looks like

but in general there will be more zeros.

We can also form an initial FX Matrix

This FX Matrix can be thought of as the currency exchanges that can occur in a single transaction.

An interesting property of the adjacency matrix is that when you raise it to the nth power, the matrix entries represent the number of paths between any two objects in the quiver that require n steps, i.e.

where is the number of paths of length or the number of ways to convert EUR to USD in transactions.

To fill out FX Matrix, we incrementally take powers of and find entries whose value is 1. Since it is getting late and I’m running out of energy, I’ll just write the procedure as a simple pseudo Matlab code:

FXMatrix = Zeros(Size(A)); For n = 1:NumCurrencies FXMatrix(A^n == 1) = FXMatrix1^n(A^n == 1); end

Although the explanation may seem a bit arduous, the final procedure is quite simple and easy to program.

Can you find a better way?

As a side note, this provides an algorithm for generating a quiver from a directed graph, i.e. it gives an adjoint functor to the forgetful functor .

Eric,

Are you acquainted with this paper: On partita doppia? Here’s an excerpt:

Accounting meets Category Theory. Looks like the kind of paper you’d write😉

Rod CarvalhoApril 1, 2010 at 2:33 am

Hi Rod,

Thanks! How are you by the way? How’s school?

I don’t recall seeing that article, but I’ll have a look. Double-entry accounting. Fun stuff

Cheers

EricApril 1, 2010 at 2:07 pm

Wow, Eric.

Have I created monster? How’s life?!?

tom

Tom KeatingOctober 16, 2010 at 10:29 pm

Tom!

Life is like a box o chocolates

How are you??? I sent an email to the address you provided so I hope it was legit. Let me know if you don’t receive it

EricOctober 16, 2010 at 11:42 pm