source = inputs["source"] """ Choose Pricing Source """ fx_name = "FX_Rate" s_name = "Rate_History" s_fx_name = "FX_Curve_History" s_opt_name = "Vol_Surface" sheet_name = "Pricer" opt_source = "LIVE" db_name = "Yield_Curve" # Spot FX market fx_spot = reader.read_FX_rates(fx_name) # Libor rate market cv_instrument = reader.read_instruments(s_name, 8) # FX rate market cv_fx_instrument = reader.read_instruments(s_fx_name, 8) """ Start Pricing and Setting up pricing objects """ disc_cv_details = {"type": "LIBOR", "spread": 0} reader.close() # Reslease workbook Pricer = Pricer.FXer(cv_instrument, cv_fx_instrument, fx_spot, "") inst = Pricer.gen_fx_instruments(inputs) NPV = Pricer.get_ans(inst, val_date, npv_date) """ Start pricing and output to Pricer sheet """ # Writting to excel
} convention = { instruemtns convention } Day_Counter = function of year fraction """ from IO import Reader as reader from curve import Day_Counter_func as Day_Counter from curve import Boot_Strapping as B_S from curve import Boot_Strap_Tools_Func as BS_TF import pandas as pd """ Get raw data """ f_name = "Raw_Inputs.xlsx" s_name = "Data" c_num, f_num, s_num = 5,7,100 reader = reader.excel_reader(f_name) ccy, date, Cash, Future, Swap = reader.read_instruments(s_name) instrument = {} instrument["cash"] = [ Cash, c_num ] instrument["future"] = [ Future, f_num ] instrument["swap"] = [ Swap, s_num ] """ Set up valuation date and currency then generate the cure by bootstrapping """ value_date = date currency = ccy convention = convention_book[currency] Day_Counter = Day_Counter.Day_Counter(convention["LIBOR_day_count"]) curve = B_S.boot_strapping_LIBOR( value_date, convention, instrument, Day_Counter)
s_name = "Vol_Surface" sdate = "2019-03-25" schema_name = "Yield_Curve" tb_opt = "vcub" opt_source = "LIVE" num = 4 Reader = Reader.excel_reader(f_name) data = Reader.read_vol( s_name, num ) vol_s = Vol.Val_Surface( sdate, schema_name, tb_opt ) vol_s.get_raw_data( opt_source, data ) # Step two load option/swaption balance schedule balance_name = "Schedule" Reader.read( balance_name ) name, raw_data = Reader.get_raw_data() cv_instrument = Reader.read_instruments("Rate_Live", 8) disc_cv_details = { "type" : "LIBOR", "spread" : 0 } # Step three option/swaption pricing OPT = OPT.OPTer( cv_instrument, vol_s ) for nn in name: if raw_data[nn]["itype"] in ("Floor","Cap"): OPT.add( nn, raw_data[nn], disc_cv_details ) print(OPT.price_opt( nn, sdate ))