diff options
Diffstat (limited to 'python')
| -rw-r--r-- | python/calibrate_tranches_BC.py | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/python/calibrate_tranches_BC.py b/python/calibrate_tranches_BC.py index d4ee1f64..23251ab4 100644 --- a/python/calibrate_tranches_BC.py +++ b/python/calibrate_tranches_BC.py @@ -42,6 +42,8 @@ if __name__ == "__main__": parser.add_argument("--tenor", default="5yr", help="Tenor we want to run [default '5yr']") parser.add_argument("--until", default=pd.Timestamp.now()-BDay(), type=lambda s: pd.Timestamp(s)) + parser.add_argument("--start_from", default=None, + type=lambda s: pd.Timestamp(s)) parser.add_argument("-d", "--debug", action="store_true", help="more verbose logging") args = parser.parse_args() logger.setLevel(logging.DEBUG if args.debug else logging.INFO) @@ -89,10 +91,13 @@ if __name__ == "__main__": config = load(fh) for index, tenor in config['runs']: + begin_date = None index, series = index[:2].upper(), int(index[2:]) + if args.start_from is not None: + begin_date = args.start_from if args.update: begin_date = get_lastdate(serenitas_conn, index, series, tenor) - if not args.update or begin_date is None: + if not args.update and begin_date is None: try: begin_date = start_dates[f"{index.lower()}{series}"] except KeyError: @@ -125,11 +130,15 @@ if __name__ == "__main__": continue df = pd.concat([tranche_index.tranche_deltas(), - tranche_index.tranche_thetas(method="TLP"), tranche_index.tranche_fwd_deltas(), tranche_index.tranche_durations(), tranche_index.tranche_EL(), tranche_index.tranche_spreads()], axis=1) + try: + df['theta'] = tranche_index.tranche_thetas(method="TLP") + except ValueError: + df['theta'] = None + df['index_duration'], df['index_expected_loss'], df['index_price'] = \ tranche_index.index_pv() df['index_expected_loss'] *= -1 |
