## Black Scholes differential equation

where

### Pricing call and put with a given strike price X and maturity T

According the Black-Scholes formula, the values of call and put with the strike price maturing at time are given by:

Where is the *distribution function* of ,

and:

## Java

### BlackScholes.java

```
public class BlackScholes implements PricingType
```

`PricingType`

, is an interface that defines two abstract methods `getCall()`

and `getPut()`

.
In `BlackScholes`

, we implement these methods.

Our input variables are stored in a collection `HashMap<String, Double>`

. At the constructor we initialize a number of instance variables.

```
stock = hashMap.get("stock");
strike = hashMap.get("strike");
volatility = hashMap.get("volatility");
interest = hashMap.get("interest");
timehorizon = hashMap.get("timehorizon");
```

#### d1 & d2

Also at the constructor, we calculate and .

```
d1 = (Math.log(stock / strike)
+ (interest + (Math.pow(volatility, 2) / 2))
* timehorizon)
/ (volatility * Math.sqrt(timehorizon));
d2 = d1 - (volatility * Math.sqrt(timehorizon));
```

#### getCall()

```
public double getCall() {
return (stock * distribution.cumulativeProbability(d1))
- (strike * Math.exp(-interest * timehorizon)
* distribution.cumulativeProbability(d2));
}
```

#### getPut()

```
public double getPut() {
return strike * Math.exp(-interest * timehorizon)
* distribution.cumulativeProbability(-d2)
- stock * distribution.cumulativeProbability(-d1);
}
```

### BlackScholes.txt

In the Java implementation, we simply assume . So the timehorizon is the maturity .

Let’s suppose the following:

So in `BlackScholes.txt`

, we have

```
stock,115
strike,80
volatility,0.48
interest,0.07
timehorizon,0.5
```

### Output

```
Black Scholes
Call:39.63234093141300
Put:1.88077423201832
```

## The Black Scholes Formulas

### Nearing Maturity

As we approach maturity, , the following terms tend to 0.

Therefore becomes important to the behaviour of and .

#### If then is positive.

When positive,

So at maturity, the value of the options is:

If is big, the call will be executed with high probability and becomes similar to a forward! Likewise, the Put will not likely be executed.

#### If then is negative.

When negative,

So at maturity, the value of the options is: