# Tricks of the Trade - 013 - Pure, Functional, Financial, Python Katas

If I have a stock listed on the Nasdaq which doubles every year and one has had its stock price halving, which one would you invest in?

There are 99 arguments to make any investment decision, and that's a problem.

A problem which has stumped academics for years.

How do you predict the future?

Let's code up a toy model using Python's lambdas.

```
P1 = lambda: 0.5
U1 = lambda: 300
D1 = lambda: 99
S1 = lambda: 100
```

where P1 is the probability that the stock will be $300 next year.

(1 - 0.5) is the probability that the stock drops to $99 next year.

Taking 'expectations' we can see that the expected stock price is about $200, which is a princely profit over the current price of $100.

Try coding this up.

Let's look at the second stock, here is what we believe we happen next year.

```
P2 = lambda: 0.5
U2 = lambda: 101
D2 = lambda: 1
S2 = lambda: 100
```

Both have the same initial price, but when we take the expectations we get a value of about $50 for next year. Losing 50% of the stock's value.

Which one would you buy?

The first of course!

But remember, there are 99 arguments to invest this way or that. We can build 99 toy models to come up with 99 different answers.

Economists haven't a way to pick the right model, but they found an ingenious way to turn 99 problems into a strength.

They assumed that the current quoted market price is best prediction of the future at any point in time, this again is the 'No Arbitrage' principle.

So, if we have a portfolio comprising of one stock now, at time 't' we expect it to be worth the same as putting an equal amount of cash in a bank account which accrues interest at time 'T'.

In turn, we are saying that every asset has the same expected return.

Is this sensible?

Perhaps.

If it was not, we could reliably predict the future, we or someone else could make large profits. This profit incentive is reflected in the market price, by people buying and selling.

Academics, recycled the idea that we cannot tell the future, and called it the Arbitrage Principle.

Make a principle out of your ignorance, very smart.

This breaks with statistics. Statistical ideas such as mean return or standard deviation are worthless in this framework.

The next problem today is to find the probabilities, which give us our current price, given the `up`

and `down`

prices.

Write a lambda function which finds the probabilities while assuming the No Arbitrage principle holds.