コード例 #1
0
ファイル: Curve_Keeper.py プロジェクト: Karagul/Basic-Pricing
 def gen_instruments_test_data( self, 
                                file_name,
                                curve_name ):
     # Generate instruments by test data
     instruments = BS_BT.get_rates_instrument_test( file_name,
                                                    curve_name)
     return instruments
コード例 #2
0
ファイル: FX_Pricer.py プロジェクト: Karagul/Basic-Pricing
 def gen_zero_curve(self, value_date, ccy, instrument, Day_Counter):
     """ Wrapper function:
         Generate swap curve depends on
         disc_cv_details is either
         XCS or LIBOR
     """
     curve = B_S.boot_strapping_Zero_ccy(value_date, ccy, instrument,
                                         Day_Counter)
     return curve
コード例 #3
0
ファイル: Curve_Keeper.py プロジェクト: Karagul/Basic-Pricing
 def get_yields_curve( self,
                       LIBOR_ins, 
                       OIS_ins,
                       FX_ins,
                       sdate,
                       currency, 
                       shock_year, 
                       BPS, 
                       spread,
                       Day_Counter ):
     """ Bootstrapping calculation of yields curve
         shock_year = -1 means does not shock 
         shock_year = 0 means paralell shock
     """
     units    = 100
     BPS      = BPS/units
     OIS_ans  = [0]
     ans_book = {
                 "cash":[0,LIBOR_ins["cash"][1]],
                 "future":[0,LIBOR_ins["future"][1]],
                 "swap" :[0,LIBOR_ins["swap"][1]],
                 }
     fx_book = {
                 "cash":[0,FX_ins["cash"][1]],
                 "future":[0,FX_ins["future"][1]],
                 "swap" :[0,FX_ins["swap"][1]],
                 }
     
     ans_book["cash"][0]   = BS_TF.shock_inputs_curve( sdate,
                                                       LIBOR_ins["cash"][0],
                                                       "CASH",
                                                       shock_year,
                                                       BPS,
                                                       spread )
     ans_book["future"][0] = BS_TF.shock_inputs_curve( sdate,
                                                       LIBOR_ins["future"][0],
                                                       "FUTURE",
                                                       shock_year,
                                                       BPS,
                                                       spread )
     ans_book["swap"][0]   = BS_TF.shock_inputs_curve( sdate,
                                                       LIBOR_ins["swap"][0],
                                                       "SWAP",
                                                       shock_year,
                                                       BPS,
                                                       spread )
     fx_book["cash"][0]   = BS_TF.shock_inputs_curve(  sdate,
                                                       FX_ins["cash"][0],
                                                       "CASH",
                                                       shock_year,
                                                       BPS,
                                                       spread )
     fx_book["future"][0] = BS_TF.shock_inputs_curve(  sdate,
                                                       FX_ins["future"][0],
                                                       "FUTURE",
                                                       shock_year,
                                                       BPS,
                                                       spread )
     fx_book["swap"][0]   = BS_TF.shock_inputs_curve(  sdate,
                                                       FX_ins["swap"][0],
                                                       "SWAP",
                                                       shock_year,
                                                       BPS,
                                                       spread )
     OIS_ans               = BS_TF.shock_inputs_curve( sdate,
                                                       OIS_ins,
                                                       "OIS",
                                                       shock_year,
                                                       BPS,
                                                       spread )
     
     """ Since we are shocking the inputs instruments
         We have to rebootstrapping every time
     """
     if currency != "BRL":
         LIBOR_curve = BS_BT.boot_strapping_LIBOR_ccy( sdate,
                                                       currency, 
                                                       ans_book, 
                                                       Day_Counter )
         FX_curve = BS_BT.boot_strapping_LIBOR_ccy( sdate,
                                                    currency, 
                                                    fx_book, 
                                                    Day_Counter )
     else:
         LIBOR_curve = BS_BT.boot_strapping_Zero_ccy( sdate,
                                                      currency, 
                                                      ans_book, 
                                                      Day_Counter )
         FX_curve = BS_BT.boot_strapping_Zero_ccy( sdate,
                                                   currency, 
                                                   fx_book, 
                                                   Day_Counter )
     
     OIS_Curve   = BS_BT.boot_strapping_OIS_ccy( sdate,
                                                 currency, 
                                                 OIS_ans, 
                                                 Day_Counter )
     LIBOR_curve = [(ele[0],ele[1]) for ele in LIBOR_curve]
     FX_curve    = [(ele[0],ele[1]) for ele in FX_curve]
     OIS_Curve   = [(ele[0],ele[1]) for ele in OIS_Curve]
     
     return LIBOR_curve, OIS_Curve, FX_curve