Ejemplo n.º 1
0
    def test_simulate_bates(self):

        model = BatesModel(self.bates_process)

        paths = 4
        steps = 10
        horizon = 1
        seed = 12345

        res = simulateBates(model, paths, steps, horizon, seed)

        time = res[0, :]
        time_expected = np.arange(0, 1.1, 0.1)
        simulations = res[1:, :].T

        np.testing.assert_array_almost_equal(time, time_expected, decimal=4)
Ejemplo n.º 2
0
    def test_simulate_bates(self):

        model = BatesModel(self.bates_process)

        paths = 4
        steps = 10
        horizon = 1
        seed = 12345

        res = simulateBates(model, paths, steps, horizon, seed)

        time = res[0, :]
        time_expected = np.arange(0, 1.1, .1)
        simulations = res[1:, :].T

        np.testing.assert_array_almost_equal(time, time_expected, decimal=4)
Ejemplo n.º 3
0
plot(time, simulations)
show()

ival = {
    'v0': v0,
    'kappa': 3.7,
    'theta': v0,
    'sigma': 1.0,
    'rho': -.6,
    'lambda': .1,
    'nu': -.5,
    'delta': 0.3
}

spot = SimpleQuote(1200)

proc_bates = BatesProcess(risk_free_ts, dividend_ts, spot, ival['v0'],
                          ival['kappa'], ival['theta'], ival['sigma'],
                          ival['rho'], ival['lambda'], ival['nu'],
                          ival['delta'])

model_bates = BatesModel(proc_bates)

res_bates = simulateBates(model_bates, paths, steps, horizon, seed)

time = res_bates[0, :]
simulations = res_bates[1:, :].T
figure()
plot(time, simulations)
show()
Ejemplo n.º 4
0
res = simulateHeston(model, paths, steps, horizon, seed)

time = res[0, :]
simulations = res[1:, :].T

figure()
plot(time, simulations)
show()

ival = {'v0': v0, 'kappa': 3.7, 'theta': v0,
    'sigma': 1.0, 'rho': -.6, 'lambda': .1,
    'nu':-.5, 'delta': 0.3}

spot = SimpleQuote(1200)

proc_bates = BatesProcess(
    risk_free_ts, dividend_ts, spot, ival['v0'], ival['kappa'],
     ival['theta'], ival['sigma'], ival['rho'],
     ival['lambda'], ival['nu'], ival['delta'])

model_bates = BatesModel(proc_bates)

res_bates = simulateBates(model_bates, paths, steps, horizon, seed)

time = res_bates[0, :]
simulations = res_bates[1:, :].T
figure()
plot(time, simulations)
show()