Пример #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 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))
Пример #2
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))
Пример #3
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))
Пример #4
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))
Пример #5
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))
from probo.marketdata import MarketData
from probo.payoff import VanillaPayoff, call_payoff, put_payoff
from probo.engine import AsianMonteCarloEngine, NaiveMonteCarloPricer, AsianPricer
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)
Пример #7
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))
Пример #8
0
from probo.payoff import VanillaPayoff, call_payoff, put_payoff, ArithmeticAsianCallPayoff, ArithmeticAsianPutPayoff
from probo.engine import MonteCarloEngine, NaiveMonteCarloPricer, AsianPricer
from probo.facade import OptionFacade

## 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 = ArithmeticAsianCallPayoff(expiry, strike, call_payoff)
theput = VanillaPayoff(expiry, strike, put_payoff)

## Set up Naive Monte Carlo
nreps = 100000
steps = 1
pricer = AsianPricer
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))