2
$\begingroup$

I'm Trying to implement the binomial option price model in python and get reasonable performance by using memoization. I checked the output against a black and scholes model and for European options it seems to be working. However, when try to price an American option, I get the same result as a European and I can't for the life of me figure out why. Can anyone help or point me in the right direction ? Thanks

import numpy as np
from functools import lru_cache
steps =40
riskFreeRate=0.215
stepSize = 1/36
@lru_cache(maxsize=1000000) # Memoize the result to reduce number of calls
def callOption(price,strike=100,sigma=0.1,american=False):
    u =np.exp(sigma*np.sqrt(stepSize)) #The factor by which price increases
    d =np.exp(-1*sigma*np.sqrt(stepSize)) # factor by which price descreases
    p =(np.exp(riskFreeRate*stepSize) -d) / (u-d) #Probability that price goes up
    @lru_cache(maxsize=steps**2)  # Per memoized callOption, memoize the value at a given step
    def atTime(step):
        exVal = np.max([price-strike,0]) # The excercise value at this time
        if step==steps:
            val =np.max([price-strike,0]) # if this is a terminal node 
        else:
            pd = np.round(price*d,3) # The new up price, 
            pu = np.round(price*u,3) # The new down price
            #Rounding the prices means we remeber fewer nodes with minimal affect on accuracy  

            down = callOption(price=pd,sigma=sigma,strike=strike,american=american)(step+1) # Get the value of the next node when price went down
            up = callOption(price=pu,sigma=sigma,strike=strike,american=american)(step+1) # Get the value of the next node when price went up
            discount = np.exp(-1*riskFreeRate*stepSize) # the discount rate
            val = (p*up+(1-p)*down)*discount # THis is the binomial value of the option at this node
            if american : 
                #If its an american option, the value is the greater of the binomial value or excercise value
                val = np.max([val,exVal]) 
        return val
    return atTime
$\endgroup$
  • 1
    $\begingroup$ Why would you expect the two prices to differ in your example? $\endgroup$ – LocalVolatility Jan 27 at 16:04
  • $\begingroup$ Well, I'd expect an American option to almost always be worth than an equivalent european option. You can call the functions above with any set of numbers, but when you do they always come out equal for Americans and Europeans, which is against my expectation $\endgroup$ – user38310 Jan 27 at 17:24
  • $\begingroup$ My comment was meant to be a strong hint that you consider a case where the time value of the European option is always positive. Thus you'd never exercise the corresponding American option early and the two values agree. Either price a put or set the interest rate to sth. negative to get different American and European prices. $\endgroup$ – LocalVolatility Jan 27 at 17:26
  • $\begingroup$ Thanks. This answers my question but raises another one. For the American and European to be the same, the time value of both needs to be equal, not just positive. Intuitevly, an American option should have a higher time value, since there are possible price paths that would lead the option to be ITM at time t but out of the money at T. I think that those paths would make the value of the American higher, but it seems I am wrong. Why ? $\endgroup$ – user38310 Jan 27 at 21:13
  • $\begingroup$ This is indeed a different question and you should ask it as such. But please search before - I would image it has been asked and answered before. Short answer is that you would never exercise an American option if the otherwise identical European option has a positive time value. Then the added optionality is worthless and the prices are exactly the same. $\endgroup$ – LocalVolatility Jan 27 at 21:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.