Exemplo n.º 1
0
def main():
    """Set up the option!"""
    strike = 40.0
    expiry = .25 
    
    """Set up the Market Data!"""
    spot = 41.0
    rate = 0.08
    volatility = 0.30
    dividend = 0.0
    
    """Set up the European Binomial Pricing Engine!"""
    steps = 500 
    call = VanillaPayoff(expiry, strike, call_payoff)
    data = MarketData(rate, spot, volatility, dividend)
    binom_engine = BinomialPricingEngine(steps, EuropeanBinomialPricer)
    
    """Calculate the Price"""
    the_option = OptionFacade(call, binom_engine, data)
    price = the_option.price()
    print("The European Binomial Call Price is {0:.3f}".format(price))
    
    """Set up Black Scholes Price!"""
    the_call = VanillaPayoff(expiry, strike, call_payoff)
    BS_engine = BlackScholesPricingEngine("call", BlackScholesPricer)
    BS_option = OptionFacade(the_call, BS_engine, data)
    BS_price = BS_option.price()
    print("The call price via BLack Scholes is:  {0:.3f}".format(BS_price))
Exemplo n.º 2
0
def main():
    strike = 40.0
    expiry = .25 
    
    spot = 41.0
    rate = 0.08
    volatility = 0.30
    dividend = 0.0
    steps = 500 

    the_call = VanillaPayoff(expiry, strike, call_payoff)
    the_data = MarketData(rate, spot, volatility, dividend)
    binom_engine = BinomialPricingEngine(steps, EuropeanBinomialPricer)
    
    the_option = OptionFacade(the_call, binom_engine, the_data)
    price = the_option.price()
    print("The Call Price is {0:.3f}".format(price))
Exemplo n.º 3
0
def main():
    strike = 40.0
    expiry = 0.25 
    
    spot = 41.0
    rate = 0.08
    volatility = 0.30
    dividend = 0.0
    steps = 3 

    the_call = VanillaPayoff(expiry, strike, call_payoff)
    the_data = MarketData(rate, spot, volatility, dividend)
    A_binom_engine = BinomialPricingEngine(steps, AmericanBinomialPricer)
    
    the_option = OptionFacade(the_call, A_binom_engine, the_data)
    price = the_option.price()
    print("The call price is {0:.3f}".format(price))
Exemplo n.º 4
0
def main():
    strike = 40.0
    expiry = 0.25 

    spot = 41.0
    rate = 0.08
    volatility = 0.30
    dividend = 0.0
    time_steps = 100
    replications = 1000

    the_call = VanillaPayoff(expiry, strike, call_payoff)
    the_data = MarketData(rate, spot, volatility, dividend)
    convar_mc_engine = MonteCarloPricingEngine(time_steps, replications, ControlVariatePricer)
    the_option = OptionFacade(the_call, convar_mc_engine, the_data)
    price = the_option.price()
    print("The Call Price via Control Variate Monte Carlo is {0:.3f}".format(price))
Exemplo n.º 5
0
def main():
    strike = 40.0
    expiry = .25 
    
    spot = 41.0
    rate = 0.08
    volatility = 0.30
    dividend = 0.0
    time_steps = 100
    replications = 1000

    the_call = VanillaPayoff(expiry, strike, call_payoff)
    the_data = MarketData(rate, spot, volatility, dividend)
    strat_mc_engine = MonteCarloPricingEngine(time_steps, replications, Stratified_Monte_Carlo_Pricer)
    
    the_option = OptionFacade(the_call, strat_mc_engine, the_data)
    price = the_option.price()
    print("The Call Price is {0:.3f}".format(price))
Exemplo n.º 6
0
def main():
    """Set up the option!"""
    expiry = 0.25
    strike = 40.0
    """Set up the data!"""
    spot = 41.0
    rate = 0.08
    volatility = 0.30
    dividend = 0.0
    """set up the engine!"""
    #steps = 500
    #type = "Put"

    bs_engine = BlackScholesPricingEngine("call", BlackScholesPricer)
    the_data = MarketData(rate, spot, volatility, dividend)
    the_call = VanillaPayoff(expiry, strike, call_payoff)
    option2 = OptionFacade(the_call, bs_engine, the_data)
    price2 = option2.price()
    print("The call price via Black-Scholes is: {0:.3f}".format(price2))
Exemplo n.º 7
0
def main():
    """Set up the option!"""
    strike = 40.0
    expiry = .25 
    
    """Set up the Market Data!"""
    spot = 40.0
    rate = 0.08
    volatility = 0.30
    dividend = 0.0
    
    """Set up the Pricing Engine!"""
    time_steps = 10
    replications =10000
    
    call = ExoticPayoff(expiry, strike, arithmetic_asian_call_payoff)
    data = MarketData(rate, spot, volatility, dividend)
    
    Arithmetic_A_engine = MonteCarloPricingEngine(time_steps, replications, Asian_Option_Pricer)
    AA_option = OptionFacade(call, Arithmetic_A_engine, data)
    AA_price = AA_option.price()
    print("The call price for an Arithmetic Asian Call Option using a Geometric Asian control Variate is:  {0:.3f}".format(AA_price))
Exemplo n.º 8
0
def main():
    """Set up the option!"""
    strike = 40.0
    expiry = .25
    """Set up the Market Data!"""
    spot = 41.0
    rate = 0.08
    volatility = 0.30
    dividend = 0.0
    """Set up the European Binomial Pricing Engine!"""
    steps = 500
    call = VanillaPayoff(expiry, strike, call_payoff)
    data = MarketData(rate, spot, volatility, dividend)
    binom_engine = BinomialPricingEngine(steps, EuropeanBinomialPricer)
    """Calculate the Price"""
    the_option = OptionFacade(call, binom_engine, data)
    price = the_option.price()
    print("The European Binomial Call Price is {0:.3f}".format(price))
    """Set up Black Scholes Price!"""
    the_call = VanillaPayoff(expiry, strike, call_payoff)
    BS_engine = BlackScholesPricingEngine("call", BlackScholesPricer)
    BS_option = OptionFacade(the_call, BS_engine, data)
    BS_price = BS_option.price()
    print("The call price via BLack Scholes is:  {0:.3f}".format(BS_price))
Exemplo n.º 9
0
from probo.payoff import VanillaPayoff, call_payoff, put_payoff
from probo.engine import MonteCarloEngine, lsmPricer
from probo.facade import OptionFacade

## Set up the market data
spot = 1.0
rate = 0.06
volatility = 0.30
dividend = 0.0
thedata = MarketData(rate, spot, volatility, dividend)

## Set up the option
expiry = 3.0
strike = 1.10 
thecall = VanillaPayoff(expiry, strike, call_payoff)
theput = VanillaPayoff(expiry, strike, put_payoff)

## Set up Naive Monte Carlo
nreps = 8
steps = 3
pricer = lsmPricer
mcengine = MonteCarloEngine(nreps, steps, pricer)

## Calculate the price
option2 = OptionFacade(theput, mcengine, thedata)
price2 = option2.price()
print("The put price via Least Squares Monte Carlo is: {0:.3f}".format(price2))



Exemplo n.º 10
0
    return paths


paths = AssetPaths(spot, rate, volatility, expiry, dividend, nreps, steps)
maxSpot = np.amax(paths[1])
minSpot = np.amin(paths[1])

#-------------------------------------------------------------------
#MonteCarlo
pricer = NaiveMonteCarloPricer

mcengine = MonteCarloEngine(nreps, steps, pricer)

## Calculate the prices
startTime1 = time.time()
option1 = OptionFacade(thecall, mcengine, thedata)
mcCallPrice, mcCallSe = option1.price()
endTime1 = time.time()
totalTime1 = endTime1 - startTime1

startTime2 = time.time()
option2 = OptionFacade(theput, mcengine, thedata)
mcPutPrice, mcPutSe = option2.price()
endTime2 = time.time()
totalTime2 = endTime2 - startTime2

#-------------------------------------------------------------------

#Control Variate
pricer = ControlVariatePricer
Exemplo n.º 11
0
from probo.marketdata import MarketData
from probo.payoff import VanillaPayoff, call_payoff, put_payoff
from probo.engine import MonteCarloEngine, lsmPricer
from probo.facade import OptionFacade

## Set up the market data
spot = 1.0
rate = 0.06
volatility = 0.30
dividend = 0.0
thedata = MarketData(rate, spot, volatility, dividend)

## Set up the option
expiry = 3.0
strike = 1.10
thecall = VanillaPayoff(expiry, strike, call_payoff)
theput = VanillaPayoff(expiry, strike, put_payoff)

## Set up Naive Monte Carlo
nreps = 8
steps = 3
pricer = lsmPricer
mcengine = MonteCarloEngine(nreps, steps, pricer)

## Calculate the price
option2 = OptionFacade(theput, mcengine, thedata)
price2 = option2.price()
print("The put price via Least Squares Monte Carlo is: {0:.3f}".format(price2))
Exemplo n.º 12
0
from probo.facade import OptionFacade

## Set up the market data
spot = 100.0
rate = 0.06
volatility = 0.20
dividend = 0.03
thedata = MarketData(rate, spot, volatility, dividend)

## Set up the option
expiry = 1.0
strike = 100.0
thecall = VanillaPayoff(expiry, strike, call_payoff)
#theput = VanillaPayoff(expiry, strike, put_payoff)

## Set up Naive Monte Carlo
nreps = 100
steps = 10
pricer = AsianPricer
mcengine = AsianMonteCarloEngine(nreps, steps, pricer)

## Calculate the price
option1 = OptionFacade(thecall, mcengine, thedata)
price1 = option1.price()
print("The call price via Naive Monte Carlo is: {0:.3f}".format(price1))

## Only works for calls
#option2 = OptionFacade(theput, mcengine, thedata)
#price2 = option2.price()
#print("The put price via Naive Monte Carlo is: {0:.3f}".format(price2))
Exemplo n.º 13
0
spot = 41.0
rate = 0.08
volatility = 0.30
dividend = 0.0
thedata = MarketData(rate, spot, volatility, dividend)

## Set up the option
expiry = 1.0
strike = 40.0
thecall = ExoticPayoff(expiry, strike, lookbackCallPayoff)
theput = ExoticPayoff(expiry, strike, lookbackPutPayoff)

## Set up Naive Monte Carlo
nreps = 100000
steps = 252
pricer = NaiveMonteCarloPricer
#pricer = PathwiseNaiveMonteCarloPricer
mcengine = MonteCarloEngine(nreps, steps, pricer)

## Calculate the price
option1 = OptionFacade(thecall, mcengine, thedata)
price1 = option1.price()
print("The call price via Naive Monte Carlo is: {0:.3f}".format(price1[0]))

option2 = OptionFacade(theput, mcengine, thedata)
price2 = option2.price()
print("The put price via Naive Monte Carlo is: {0:.3f}".format(price2[0]))



Exemplo n.º 14
0
## Set up the market data
spot = 41.0
rate = 0.08
volatility = 0.30
dividend = 0.0
thedata = MarketData(rate, spot, volatility, dividend)

## Set up the option
expiry = 1.0
strike = 40.0
thecall = VanillaPayoff(expiry, strike, call_payoff)
theput = VanillaPayoff(expiry, strike, put_payoff)

## Set up Naive Monte Carlo
nreps = 100000
steps = 1
pricer = NaiveMonteCarloPricer
mcengine = MonteCarloEngine(nreps, steps, pricer)

## Calculate the price
option1 = OptionFacade(thecall, mcengine, thedata)
price1, se1 = option1.price()
print("The call price via Naive Monte Carlo is: {0:.3f}".format(price1))

option2 = OptionFacade(theput, mcengine, thedata)
price2, se2 = option2.price()
print("The put price via Naive Monte Carlo is: {0:.3f}".format(price2))



Exemplo n.º 15
0
spot = 41.0
rate = 0.08
volatility = 0.30
dividend = 0.0
thedata = MarketData(rate, spot, volatility, dividend)

## Set up the option
expiry = 1.0
strike = 40.0
thecall = ExoticPayoff(expiry, strike, arithmeticAsianCallPayoff)
theput = ExoticPayoff(expiry, strike, arithmeticAsianPutPayoff)

## Set up Naive Monte Carlo
nreps = 100000
steps = 1
pricer = NaiveMonteCarloPricer
# pricer = PathwiseNaiveMonteCarloPricer
mcengine = MonteCarloEngine(nreps, steps, pricer)

## Calculate the price
option1 = OptionFacade(thecall, mcengine, thedata)
price1 = option1.price()
print("The call price via Naive Monte Carlo is: {0:.3f}".format(price1))

option2 = OptionFacade(theput, mcengine, thedata)
price2 = option2.price()
print("The put price via Naive Monte Carlo is: {0:.3f}".format(price2))



volatility = 0.30
dividend = 0.0
thedata = MarketData(rate, spot, volatility, dividend)

## Set up the option
expiry = 1.0
strike = 40.0
thecall = VanillaPayoff(expiry, strike, call_payoff)
theput = VanillaPayoff(expiry, strike, put_payoff)

## Set up the European Binomial pricer
steps = 3
pricer = EuropeanBinomialPricer
binomengine = BinomialPricingEngine(steps, pricer)

## Calculate the price
option1 = OptionFacade(thecall, binomengine, thedata)
price1 = option1.price()
print("The call price via European Binomial is: {0:.3f}".format(price1))

option2 = OptionFacade(theput, binomengine, thedata)
price2 = option2.price()
print("The put price via European Binomial is: {0:.3f}".format(price2))

## Set up the Black-Scholes pricer
#bsengine = BlackScholesPricingEngine(BlackScholesPayoffType.call, BlackScholesPricer)
bsengine = BlackScholesPricingEngine("call", BlackScholesPricer)
option3 = OptionFacade(thecall, bsengine, thedata)
price3 = option3.price()
print("The call price via Black-Scholes is: {0:.3f}".format(price3))
dividend = 0.03
thedata = MarketData(rate, spot, volatility, dividend)
## Set up the option
expiry = 1.0
strike = 100.0
thecall = VanillaPayoff(expiry, strike, call_payoff)
theput = VanillaPayoff(expiry, strike, put_payoff)

## Set up Simple Monte Carlo
nreps = 10000
steps = 10
pricer = PathwiseNaiveMonteCarloPricer
call_mcengine = MonteCarloEngine(nreps, steps, pricer, "call")
put_mcengine = MonteCarloEngine(nreps, steps, pricer, "put")

calloption = OptionFacade(thecall, call_mcengine, thedata)
call_price = calloption.price()
print("\nThe call price and standard error via Naive Monte Carlo are: " +
      str(call_price))

putoption = OptionFacade(theput, put_mcengine, thedata)
put_price = putoption.price()
print("\nThe put price and standard error via Naive Monte Carlo are: " +
      str(put_price))

## control variate
pricer = PathwiseControlVariatePricer

print(
    "\nThe call price and standard error via Control Variate Monte Carlo are: "
    + str(call_price))
Exemplo n.º 18
0
def main():
    """Set up the option!"""
    strike = 40.0
    expiry = .25 
    
    """Set up the Market Data!"""
    spot = 41.0
    rate = 0.08
    volatility = 0.30
    dividend = 0.0
    
    """Set up the Pricing Engine!"""
    time_steps = 25
    replications =500
    
    call = VanillaPayoff(expiry, strike, call_payoff)
    data = MarketData(rate, spot, volatility, dividend)
    
    """Set up Black Scholes Price!"""
    the_call = VanillaPayoff(expiry, strike, call_payoff)
    BS_engine = BlackScholesPricingEngine("call", BlackScholesPricer)
    BS_option = OptionFacade(the_call, BS_engine, data)
    BS_price = BS_option.price()
    print("The call price via BLack Scholes is:  {0:.3f}".format(BS_price))

    """Naive Monte Carlo"""    
    the_call = VanillaPayoff(expiry, strike, call_payoff)
    the_data = MarketData(rate, spot, volatility, dividend)
    mc_engine = MonteCarloPricingEngine(replications, time_steps, Naive_Monte_Carlo_Pricer)
    
    the_option = OptionFacade(the_call, mc_engine, the_data)
    MC_price = the_option.price()
    print("The Naive Monte Carlo Call Price is {0:.3f}".format(MC_price))
    
    """Antithetic Monte Carlo"""
    anti_mc_engine = MonteCarloPricingEngine(replications, time_steps, Antithetic_Monte_Carlo_Pricer)
    anti_option = OptionFacade(the_call, anti_mc_engine, the_data)
    anti_price = anti_option.price()
    print("The Antithetic Monte Carlo Call Price is {0:.3f}".format(anti_price))
    
    """Stratified Monte Carlo"""
    strat_mc_engine = MonteCarloPricingEngine(replications, time_steps, Stratified_Monte_Carlo_Pricer)
    strat_option = OptionFacade(the_call, strat_mc_engine, the_data)
    strat_price = strat_option.price()
    print("The Stratified Monte Carlo Call Price is {0:.3f}".format(strat_price))
    
    """Control Variate Monte Carlo"""
    convar_mc_engine = MonteCarloPricingEngine(replications, time_steps, ControlVariatePricer)
    convar_option = OptionFacade(the_call, convar_mc_engine, the_data)
    convar_price = convar_option.price()
    print("The Call Price via Control Variate Monte Carlo is {0:.3f}".format(convar_price))
Exemplo n.º 19
0
rate = 0.06
volatility = 0.2
dividend = 0.03
thedata = MarketData(rate, spot, volatility, dividend)

## Set up the option
expiry = 1.0
strike = 100.0
thecall = VanillaPayoff(expiry, strike, call_payoff)

## Set up Asian Control Variate Pricer
nreps = 10000
steps = 10
pricercontvar = AsianControlVariatePricerCall
enginecontvar = MonteCarloEngine(nreps, steps, pricercontvar)

## Set up Naive Asian Pricer (nreps and nsteps are the same)

pricernaive = NaiveAsianCall
enginenaive = MonteCarloEngine(nreps, steps, pricernaive)

## Calculate the price
option1 = OptionFacade(thecall, enginecontvar, thedata)
price1, se1 = option1.price()

option2 = OptionFacade(thecall, enginenaive, thedata)
price2, se2 = option2.price()

print("The Asian Control Variate Call  is   {0:.3f}".format(price1),
      " The SE is{0:.6f}".format(se1))