コード例 #1
0
ファイル: test_simulate.py プロジェクト: AlexArgus/pyql
    def test_simulate_heston_2(self):

        s0 = SimpleQuote(100.0)
        v0 = 0.05
        kappa = 5.0
        theta = 0.05
        sigma = 1.0e-4
        rho = 0.0

        process = HestonProcess(self.risk_free_ts, self.dividend_ts, s0, v0, kappa, theta, sigma, rho)

        model = HestonModel(process)

        nbPaths = 4
        nbSteps = 100
        horizon = 1
        seed = 12345
        res = simulateHeston(model, nbPaths, nbSteps, horizon, seed)

        self.assertAlmostEqual(res[1, -1], 152.50, delta=0.1)
コード例 #2
0
    def test_simulate_heston_2(self):

        s0 = SimpleQuote(100.0)
        v0 = 0.05
        kappa = 5.0
        theta = 0.05
        sigma = 1.0e-4
        rho = 0.0

        process = HestonProcess(self.risk_free_ts, self.dividend_ts, s0, v0,
                                kappa, theta, sigma, rho)

        model = HestonModel(process)

        nbPaths = 4
        nbSteps = 100
        horizon = 1
        seed = 12345
        res = simulateHeston(model, nbPaths, nbSteps, horizon, seed)

        self.assertAlmostEqual(res[1, -1], 152.50, delta=.1)
コード例 #3
0
ファイル: test_simulate.py プロジェクト: Xelaadryth/pyql
    def test_simulate_heston_1(self):

        settings = self.settings
        settlement_date = today()
        settings.evaluation_date = settlement_date

        # simulate Heston paths
        paths = 4
        steps = 10
        horizon = 1
        seed = 12345

        model = HestonModel(self.heston_process)

        res = simulateHeston(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)
コード例 #4
0
ファイル: test_simulate.py プロジェクト: systemtrader/pyql
    def test_simulate_heston_1(self):

        settings = self.settings
        settlement_date = today()
        settings.evaluation_date = settlement_date

        # simulate Heston paths
        paths = 4
        steps = 10
        horizon = 1
        seed = 12345

        model = HestonModel(self.heston_process)

        res = simulateHeston(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)
コード例 #5
0
ファイル: HestonSimulation.py プロジェクト: surfmaverick/pyql
# The simulation
# --------------
# 
# The *simulate* function is not part of Quantlib. It has been added
# to the pyQL interface (see folder quantlib/sim). This illustrates
# how to create extensions to Quantlib and expose them to python.

# <codecell>

import pylab as pl
from quantlib.sim.simulate import simulateHeston

# simulate and plot Heston paths
paths = 20
steps = 100
horizon = 2
seed = 12345

model = HestonModel(process)

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

time = res[0, :]
simulations = res[1:, :].T
pl.plot(time, simulations)
pl.xlabel('Time')
pl.ylabel('Stock Price')
pl.title('Heston Process Simulation')
pl.show()
コード例 #6
0
ファイル: HestonSimulation-2.py プロジェクト: jojogh/pyql
# The simulation
# --------------
# 
# The *simulate* function is not part of Quantlib. It has been added to the pyQL interface (see folder quantlib/sim). This illustrates how to crerate extensions to Quantlib and expose them to python.

# <codecell>

import pylab as pl
from quantlib.sim.simulate import simulateHeston

# simulate and plot Heston paths
paths = 2
steps = 100
horizon = 2
seed = 12345

model = HestonModel(process)

res = simulateHeston(model, paths, steps, horizon,
                     seed, antithetic=True)

time = res[0,:]
simulations = res[1:, :].T
pl.plot(time, simulations)
pl.xlabel('Time')
pl.ylabel('Stock Price')
pl.title('Heston Process Simulation')
pl.show()


コード例 #7
0
# <markdowncell>

# The simulation
# --------------
#
# The *simulate* function is not part of Quantlib. It has been added to the pyQL interface (see folder quantlib/sim). This illustrates how to crerate extensions to Quantlib and expose them to python.

# <codecell>

import pylab as pl
from quantlib.sim.simulate import simulateHeston

# simulate and plot Heston paths
paths = 2
steps = 100
horizon = 2
seed = 12345

model = HestonModel(process)

res = simulateHeston(model, paths, steps, horizon, seed, antithetic=True)

time = res[0, :]
simulations = res[1:, :].T
pl.plot(time, simulations)
pl.xlabel('Time')
pl.ylabel('Stock Price')
pl.title('Heston Process Simulation')
show()