## 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 $X$ maturing at time $T$ are given by:

Where $N$ is the distribution function of $\phi(0,1)$,

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 $d_1$ and $d_2$.

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 $t=0$. So the timehorizon $T-t$ is the maturity $T$.

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, $t \rightarrow T$, the following terms tend to 0.

Therefore $\ln{\frac{S}{X}}$ becomes important to the behaviour of $d_1$ and $d_2$.

#### If $S \rightarrow +\infty$ then $\ln{\frac{S}{X}}$ is positive.

When positive,

So at maturity, the value of the options is:

If $S$ 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 $S \rightarrow -\infty$ then $\ln{\frac{S}{X}}$ is negative.

When negative,

So at maturity, the value of the options is: