예제 #1
0
    def test_heston_pricer(self):

        trade_date = date(2011, 1, 24)
        spot = 1290.58

        # option definition
        options = ds.option_quotes_template().reindex(index=range(2))
        options[nm.OPTION_TYPE] = ['C', 'P']
        options[nm.STRIKE] = [1290, 1290]
        options[nm.EXPIRY_DATE] = [date(2015, 1, 1), date(2015, 1, 1)]
        options[nm.SPOT] = [spot] * 2

        # interest rate and dividend yield
        rates = ds.riskfree_dividend_template().reindex(
            index=[date(2011, 3, 16), date(2013, 3, 16), date(2015, 3, 16)])
        rates[nm.DIVIDEND_YIELD] = [.021, .023, .024]
        rates[nm.INTEREST_RATE] = [.010, .015, .019]

        # heston model
        heston_params = dict(v0=0.051965,
            kappa=0.977314, theta=0.102573,
            sigma=0.987796, rho=-0.747033
        )

        results = heston_pricer(trade_date, options,
                                heston_params, rates, spot=1290.58)

        price_call = results[nm.PRICE][0]
        price_put = results[nm.PRICE][1]

        self.assertAlmostEqual(price_call, 194.6, 1)
        self.assertAlmostEqual(price_put, 218.9, 1)
예제 #2
0
 def test_option_quotes(self):
     x = df.option_quotes_template().reindex(index=range(10))
     x[nm.STRIKE] = range(10)
     x[nm.OPTION_TYPE] = ['C'] * 10
     x[nm.EXPIRY_DATE] = [date(2000, 1, 1)] * 10
     x[nm.SPOT] = [100] * 10
     self.assertTrue(True)
예제 #3
0
    def test_heston_pricer(self):

        trade_date = date(2011, 1, 24)
        spot = 1290.58

        # option definition
        options = ds.option_quotes_template().reindex(index=range(2))
        options[nm.OPTION_TYPE] = ['C', 'P']
        options[nm.STRIKE] = [1290, 1290]
        options[nm.EXPIRY_DATE] = [date(2015, 1, 1), date(2015, 1, 1)]
        options[nm.SPOT] = [spot] * 2

        # interest rate and dividend yield
        rates = ds.riskfree_dividend_template().reindex(
            index=[date(2011, 3, 16), date(2013, 3, 16), date(2015, 3, 16)])
        rates[nm.DIVIDEND_YIELD] = [.021, .023, .024]
        rates[nm.INTEREST_RATE] = [.010, .015, .019]

        # heston model
        heston_params = dict(v0=0.051965,
            kappa=0.977314, theta=0.102573,
            sigma=0.987796, rho=-0.747033
        )

        results = heston_pricer(trade_date, options,
                                heston_params, rates, spot=1290.58)

        price_call = results[nm.PRICE][0]
        price_put = results[nm.PRICE][1]

        self.assertAlmostEqual(price_call, 194.6, 1)
        self.assertAlmostEqual(price_put, 218.9, 1)
예제 #4
0
 def test_option_quotes(self):
     x = df.option_quotes_template().reindex(index=range(10))
     x[nm.STRIKE] = range(10)
     x[nm.OPTION_TYPE] = ['C']*10
     x[nm.EXPIRY_DATE] = [date(2000,1,1)]*10
     x[nm.SPOT] = [100]*10
     self.assertTrue(True)