# Futures - 009 - Pure, Functional, Financial Python Katas

A simple kata today.

A forward contract in finance is analogous to a future in computer science, it doesn't return anything until it's got the delivery price at maturity.

A forward is a contract where a delivery price of an asset is agreed upon at time 't' but no money exchanges hands until the maturity or delivery date of the contract at time 'T' in the "future".

There is little or no futzing once the maturity date is here, we receive or pay money depending on the difference between the contract's delivery price and the price of the asset at the same date.

There are forwards for many types of assets, the forward's delivery price is set so that the price paid for the contract today is zero.

If you are not familiar with forwards, you might be a little perplexed. How can we set the delivery price now so that the future is worth nothing? Surely that would require a crystal ball to forecast the, er, future?

Let's explain with the principle of 'no arbitrage'.

We will create a portfolio of assets worth nothing.

First, we sell a forward on a single stock (which is worth zippo).

Then we sell (or short) a single stock.

And finally put the amount of money we get from shorting the stock into a bank account.

In Pseudo code, the value of our portfolio is,

`P(t) = 0 - S(t) + S(t) = 0`

Which sums to zero.

Then we wait until the delivery date 'T'.

Our forward will give us the difference between the actual delivery price at 'T' and the delivery price we set at 't', now 'F'.

'F' is the forward's delivery price which we initially entered into at 't', and now we are at 'T', it has changed somehow!

I.e.

`S(T) - F`

Our stock may have grown or declined, but it is now

`-S(T)`

And our cash saved in the bank account has compounded too,

`S(t)*exp(r * (T-t))`

Our portfolio looks like this now,

`P(T) = S(T) - F - S(T) + S(t) * exp(r * (T-t))`

`P(T) = - F + S(t) * exp(r * (T-t))`

This is precisely how much money our portfolio will be worth at 'T'.

Now for the punchline. The No Arbitrage principle is super simple but also sublime.

It supposes, a priori (i.e. at 't') that we cannot expect to make or lose money.

Standing at time 't': P(t) = P(T).

Therefore,

`P(T) = - F + S(t) * exp(r * (T-t)) = 0`

(!)

This is a true academic Jedi mind trick.

The upshot is,

`F = S(t) * exp(r * (T-t))`

The exercise for today is to code up the equations here using lambdas, and ruminate on the No Arbitrage principle.