A binary option, or asset-or-nothing option, is a type of options in which the payoff is structured to be either a fixed amount of compensation if the option expires in the money, or nothing at all if the option expires out of the money. Because of this property, we could apply Monte Carlo Simulation to find a solution. The Python codes are given here:
import random import scipy as sp # def terminalStockPrice(S, T,r,sigma): tao=random.gauss(0,1.0) terminalPrice=S * sp.exp((r - 0.5 * sigma**2)*T+sigma*sp.sqrt(T)*tao) return terminalPrice # def binaryCallPayoff(x, sT,payoff): if sT >= x: return payoff else: return 0.0 # input area S = 40.0 # asset price x = 40.0 # exercise price T = 0.5 # maturity in years r = 0.01 # risk-free rate sigma = 0.2 # vol of 20% fixedPayoff = 10.0 # payoff nSimulations =10000 # number of simulations # payoffs=0.0 for i in xrange(nSimulations): sT...