예제 #1
0
파일: bootstrap.py 프로젝트: ANB2/FBox
 def test_simple(self):
     t0 = datetime(2014,4,1)
     
     cash = [ 
         fixed_income.cash(t0,t0+dates.relativedelta(days=t),1.0,r,'A/360')
         for t,r in ((30,0.005),(90,0.007),(180,0.010))
     ]
     
     swaps = [
         fixed_income.simple_swap(dates.schedule(t0,t0+dates.relativedelta(years=t),6,False,'A/360'),1.0,r)
         for t,r in ((1,0.012),(3,0.02),(5,0.020)) 
     ]
     
     inst = cash + swaps
     
     func = __fmin__(t0,inst,'linear',True)
     func( ones(len(inst)) )
     
     yc = bootstrap(t0,inst)
     print '>>> Discounts:',[yc(i.maturity_date) for i in inst]
     
     
     for i in inst:
         self.assertAlmostEqual(i.par_rate(yc),i.rate,3) 
         self.assertAlmostEqual(i.value(yc),0.0,3) 
예제 #2
0
    def test_simple(self):
        t0 = datetime(2014, 4, 1)

        cash = [
            fixed_income.cash(t0, t0 + dates.relativedelta(days=t), 1.0, r,
                              'A/360')
            for t, r in ((30, 0.005), (90, 0.007), (180, 0.010))
        ]

        swaps = [
            fixed_income.simple_swap(
                dates.schedule(t0, t0 + dates.relativedelta(years=t), 6, False,
                               'A/360'), 1.0, r)
            for t, r in ((1, 0.012), (3, 0.02), (5, 0.020))
        ]

        inst = cash + swaps

        func = __fmin__(t0, inst, 'linear', True)
        func(ones(len(inst)))

        yc = bootstrap(t0, inst)
        print '>>> Discounts:', [yc(i.maturity_date) for i in inst]

        for i in inst:
            self.assertAlmostEqual(i.par_rate(yc), i.rate, 3)
            self.assertAlmostEqual(i.value(yc), 0.0, 3)
예제 #3
0
파일: fixed_income.py 프로젝트: ANB2/FBox
    def test_swap(self):
        yc = testyc()
        t0 = datetime(2014,4,1)

        s = simple_swap(dates.schedule(t0,t0+dates.relativedelta(years=3),6,False,'A/360'),1.0,0.1)
        r = s.par_rate(yc)
        s.rate = r
        v = s.value(yc)

        self.assertAlmostEqual(v,0.0,3) 
예제 #4
0
파일: fixed_income.py 프로젝트: ANB2/FBox
    def test_swap(self):
        yc = testyc()
        t0 = datetime(2014, 4, 1)

        s = simple_swap(
            dates.schedule(t0, t0 + dates.relativedelta(years=3), 6, False,
                           'A/360'), 1.0, 0.1)
        r = s.par_rate(yc)
        s.rate = r
        v = s.value(yc)

        self.assertAlmostEqual(v, 0.0, 3)