コード例 #1
0
    def test_create_libor_index(self):

        settings = Settings.instance()

        # Market information
        calendar = UnitedStates(LiborImpact)

        # must be a business day
        eval_date = calendar.adjust(today())
        settings.evaluation_date = eval_date

        settlement_days = 2
        settlement_date = calendar.advance(eval_date, settlement_days, Days)
        # must be a business day
        settlement_date = calendar.adjust(settlement_date)

        term_structure = YieldTermStructure(relinkable=True)
        term_structure.link_to(
            FlatForward(settlement_date, 0.05, Actual365Fixed()))

        index = Libor('USDLibor', Period(6, Months), settlement_days,
                      USDCurrency(), calendar, Actual360(), term_structure)
        default_libor = USDLibor(Period(6, Months))
        for attribute in [
                "business_day_convention", "end_of_month", "fixing_calendar",
                "joint_calendar", "tenor", "fixing_days", "day_counter",
                "family_name", "name"
        ]:
            self.assertEqual(getattr(index, attribute),
                             getattr(default_libor, attribute))
コード例 #2
0
    def setUp(self):
        Settings.instance().evaluation_date = Date(26, 5, 2021)

        self.basis_point = 1.0e-4
        self.settlement_days = 2
        self.business_day_convention = Following
        self.calendar = TARGET()
        self.day_count = Actual365Fixed()
        self.end_of_month = False
        base_ccy_idx_handle = flat_rate(0.007)
        quoted_ccy_idx_handle = flat_rate(0.015)
        self.base_ccy_idx = Euribor3M(base_ccy_idx_handle)
        self.quote_ccy_idx = USDLibor(
            Period(3, Months), quoted_ccy_idx_handle)
        self.collateral_ccy_handle = flat_rate(0.009)
        # Cross currency basis swaps data source:
        #   N. Moreni, A. Pallavicini (2015)
        #   FX Modelling in Collateralized Markets: foreign measures, basis curves
        #   and pricing formulae.
        #   section 4.2.1, Table 2.
        self.cross_currency_basis_quotes = ((Period(1, Years), -14.5),
                                            (Period(18, Months), -18.5),
                                            (Period(2, Years), -20.5),
                                            (Period(3, Years), -23.75),
                                            (Period(4, Years), -25.5),
                                            (Period(5, Years), -26.5),
                                            (Period(7, Years), -26.75),
                                            (Period(10, Years), -26.25),
                                            (Period(15, Years), -24.75),
                                            (Period(20, Years), -23.25),
                                            (Period(30, Years), -20.50))
コード例 #3
0
    def test_creation(self):

        settlement_date = Date(1, January, 2014)
        term_structure = YieldTermStructure()
        term_structure.link_to(
            FlatForward(settlement_date, 0.05, Actual365Fixed()))
        index = USDLibor(Period(3, Months), term_structure)

        self.assertEqual(index.name, 'USDLibor3M Actual/360')
コード例 #4
0
 def setUp(self):
     self.mean_reversion = SimpleQuote(0.03)
     self.volatility = SimpleQuote(0.00714)
     self.index = USDLibor(Period(3, Months))
     self.quote = SimpleQuote(99.375)
     Settings().evaluation_date = Date(13, 10, 2021)
     self.fut_quote = FuturesConvAdjustmentQuote(self.index, "Z2",
                                                 self.quote,
                                                 self.volatility,
                                                 self.mean_reversion)
コード例 #5
0
class IndexManagerTestCase(unittest.TestCase):
    settlement_date = Date(1, January, 2014)
    term_structure = YieldTermStructure()
    term_structure.link_to(FlatForward(settlement_date, 0.05,
                                       Actual365Fixed()))
    index = USDLibor(Period(3, Months), term_structure)
    index.add_fixing(Date(5, 2, 2018), 1.79345)
    index.add_fixing(Date(2, 2, 2018), 1.78902)

    def test_index_manager_methods(self):
        self.assertIn(self.index.name.upper(), IndexManager.histories())
        ts = IndexManager.get_history(self.index.name.upper())
        self.assertEqual(ts[Date(5, 2, 2018)], 1.79345)
        self.assertEqual(ts[Date(2, 2, 2018)], 1.78902)
        IndexManager.clear_histories()
        self.assertFalse(IndexManager.get_history(self.index.name.upper()))
コード例 #6
0
    def test_create_swap_index(self):

        term_structure = YieldTermStructure()
        term_structure.link_to(
            FlatForward(forward=0.05,
                        daycounter=Actual365Fixed(),
                        settlement_days=2,
                        calendar=UnitedStates()))

        ibor_index = USDLibor(Period(3, Months), term_structure)

        index = SwapIndex('UsdLiborSwapIsdaFixAm', Period(10, Years), 2,
                          USDCurrency(), UnitedStates(GovernmentBond),
                          Period(6, Months), ModifiedFollowing, Thirty360(),
                          ibor_index)
        index2 = UsdLiborSwapIsdaFixAm(Period(10, Years), term_structure)
        for attr in [
                'name', 'family_name', 'fixing_calendar', 'tenor',
                'day_counter', 'currency'
        ]:
            self.assertEqual(getattr(index, attr), getattr(index2, attr))
コード例 #7
0
    def test_empty_constructor(self):

        usdlibor_6m_index = USDLibor(Period(6, Months))
        self.assertEqual(usdlibor_6m_index.name, 'USDLibor6M Actual/360')