示例#1
0
    def test_mc_ir_shortrate_model(self):
        model_list = [xen_s.hw1f('hw1f'), xen_s.bk1f('bk1f')]

        for model in model_list:
            mc_shortrate(model)

        self.assertTrue(True)
示例#2
0
# scenario set
set_name = 'set1'
scenSet = xen.ScenarioSet(set_name=set_name)

# scenario
scen_id = 'scen1'
result_id = 'res1'
scen1 = xen.Scenario(scen_id=scen_id, result_id=result_id)

# generation setting
scen1.general.scenario_num = 100
scen1.general.maxyear = 10

# model add
scen1.add_model(xen_s.gbm('kospi200'))
scen1.add_model(xen_s.gbmconst('kospi'))
scen1.add_model(xen_s.hw1f('irskrw'))

scenSet.add_scenario(scen1)
scenSet.generate()

# get result from current repository
res = xen_r.ResultObj(set_name, scen_id, result_id)

# export csv
for i, model in enumerate(scen1.models):
    filename = model + '_' + str(i) + '.csv'
    res.get_resultModel_by_index(i).export_csv(filename)

# export npz
res.export_npz(scenSet.set_name + '.npz')
示例#3
0
# SIGMA_3Y     0.005581
# SIGMA_5Y     0.006134
# SIGMA_7Y     0.006243
# SIGMA_10Y    0.006762
# AVG_ERROR    0.075877

# average 방식
# ALPHA_36M    0.100000
# SIGMA_1Y     0.004611
# SIGMA_2Y     0.005654
# SIGMA_3Y     0.004925
# SIGMA_5Y     0.005431
# SIGMA_7Y     0.004114
# SIGMA_10Y    0.004747
# AVG_ERROR    0.075878
hw1f_test = xen_s.hw1f(model_name='hw1f_test')
hw1f_test.set_cali_parameter_fix(alpha=True, sigma=False)

# 데이터가 있어야지
# swaption = xen_cali.make_swaption(option_maturity='1Y')
# swaptions = xen_cali.make_swaptions(option_maturities=['1Y'])

swaptions = xen_cali.make_swaptions_from_matrix(
    swap_maturities=swap_maturity,
    option_maturities=option_maturity,
    values_matrix=swaption_data)

# swaptions = xen_cali.make_swaptions_from_cube(row_option_maturities=['1Y'])

# cap = xen_cali.make_cap(maturity='1Y')
# caps = xen_cali.make_cap(maturity=['1Y'])
示例#4
0
# scenario set
set_name = 'set1'
scenSet = xen.ScenarioSet(set_name=set_name)

# scenario
scen_id = 'scen1'
result_id = 'res1'
scen1 = xen.Scenario(scen_id=scen_id, result_id=result_id)

# generation setting
scen1.general.scenario_num = 100
scen1.general.maxyear = 10

# model add
hw1f = xen_s.hw1f('irskrw')
scen1.add_model(hw1f)

scenSet.add_scenario(scen1)
scenSet.generate()

# get result from current repository
res = xen_r.ResultObj(set_name, scen_id, result_id)

# timegrid iter is pandas namedtuple
for t in res.timegrid:
    print(t)

# select using scen_count
multipath = res.get_multipath(scen_count=15)
print(multipath)
示例#5
0
# coding=utf-8
import xenarix as xen
import xenarix.test.calculation as xen_ct
import xenarix.sample as xen_s

xen.set_repository('c:\\xenarix')

hw1f = xen_s.hw1f('test_hw1')
xen_ct.shortrate(hw1f,
                 scenario_num=200,
                 maxyear=5,
                 moment_match=False,
                 frequency=xen.TimeGridFrequency.Month)