#!/usr/bin/env python import sys sys.path.append('../') from ore_examples_helper import OreExample oreex = OreExample(sys.argv[1] if len(sys.argv) > 1 else False) # oreex.print_headline("Run ORE to produce NPV cube and exposures") oreex.run("Input/ore.xml") oreex.get_times("Output/log.txt") oreex.print_headline("Run ORE again to price CDS Options") oreex.run("Input/ore_cds_option.xml") # oreex.print_headline("Plot results: Simulated exposures vs analytical cds option prices") oreex.setup_plot("cds options") oreex.plot("exposure_trade_CDS.csv", 2, 3, 'b', "CDS EPE") oreex.plot("exposure_trade_CDS.csv", 2, 4, 'r', "CDS ENE") oreex.plot("cds_option_npv.csv", 3, 4, 'g', "NPV CDS Ooptions", marker='s') oreex.decorate_plot( title="Example 35 - Simulated exposures vs analytical cds option prices") oreex.save_plot_to_file()
#!/usr/bin/env python import sys sys.path.append('../') from ore_examples_helper import OreExample oreex = OreExample(sys.argv[1] if len(sys.argv) > 1 else False) oreex.print_headline("Run ORE to produce NPV cube and exposures") oreex.run("Input/ore.xml") oreex.get_times("Output/log.txt") oreex.print_headline("Plot results: Simulated exposures") oreex.setup_plot("cmsspread") oreex.plot("exposure_trade_CMS_Spread_Swap.csv", 2, 3, 'b', "Swap EPE") oreex.plot("exposure_trade_CMS_Spread_Swap.csv", 2, 4, 'r', "Swap ENE") oreex.decorate_plot( title="Example 28 - Simulated exposures for CMS Spread trades") oreex.save_plot_to_file()
#!/usr/bin/env python import sys sys.path.append('../') from ore_examples_helper import OreExample oreex = OreExample(sys.argv[1] if len(sys.argv) > 1 else False) oreex.print_headline("Run ORE to produce NPV cube and exposures") oreex.run("Input/ore.xml") oreex.get_times("Output/log.txt") oreex.print_headline("Run ORE again to price European Swaptions") oreex.run("Input/ore_swaption.xml") oreex.print_headline( "Plot results: Simulated exposures vs analytical swaption prices") oreex.setup_plot("swaptions") oreex.plot("exposure_trade_Swap_20y.csv", 2, 3, 'b', "Swap EPE") oreex.plot("exposure_trade_Swap_20y.csv", 2, 4, 'r', "Swap ENE") oreex.plot("swaption_npv.csv", 3, 4, 'g', "NPV Swaptions", marker='s') oreex.decorate_plot( title="Example 34 - Simulated exposures vs analytical swaption prices") oreex.save_plot_to_file()
#!/usr/bin/env python import sys sys.path.append('../') from ore_examples_helper import OreExample oreex = OreExample(sys.argv[1] if len(sys.argv) > 1 else False) oreex.print_headline( "Run ORE to produce NPV cube and exposures, without collateral") oreex.run("Input/ore.xml") oreex.get_times("Output/log.txt") oreex.setup_plot("example_swap_cash_physical") oreex.plot("exposure_trade_Swap.csv", 2, 3, 'b', "EPE Swap") oreex.plot("exposure_trade_SwaptionCash.csv", 2, 3, 'r', "EPE Swaption Cash") oreex.plot("exposure_trade_SwaptionPhysical.csv", 2, 3, 'g', "EPE Swaption Physical") oreex.plot("exposure_trade_SwaptionCashPremium.csv", 2, 3, 'c', "EPE Swaption Cash with Premium") #oreex.plot("exposure_trade_SwaptionPhysicalPremium.csv", 2, 3, 'y', "EPE Swaption Physical with Premium") oreex.decorate_plot(title="Example 3") oreex.save_plot_to_file()
#!/usr/bin/env python import sys sys.path.append('../') from ore_examples_helper import OreExample oreex = OreExample(sys.argv[1] if len(sys.argv) > 1 else False) oreex.print_headline( "Run ORE to produce NPV cube and exposures for Cross Currency Swaps") oreex.run("Input/ore.xml") oreex.get_times("Output/log.txt") oreex.print_headline("Plot Cross Currency Swap results") oreex.setup_plot("example_ccswap") oreex.plot("exposure_trade_CCSwap.csv", 2, 3, 'b', "EPE CCSwap") oreex.plot("exposure_trade_CCSwap.csv", 2, 4, 'r', "ENE CCSwap") oreex.decorate_plot(title="Example 8") oreex.save_plot_to_file()
"Run ORE to produce NPV cube and exposures without horizon shift") oreex.run("Input/ore.xml") oreex.get_times("Output/log.txt") oreex.print_headline( "Run ORE to produce NPV cube and exposures with horizon shift") oreex.run("Input/ore2.xml") oreex.print_headline("Run ORE again to price European Swaptions") oreex.run("Input/ore_swaption.xml") oreex.print_headline( "Plot results: Simulated exposures vs analytical swaption prices") oreex.setup_plot("swaptions") oreex.plot("exposure_trade_Swap_50y.csv", 2, 3, 'b', "Swap EPE (no horizon shift)") oreex.plot("exposure_trade_Swap_50y.csv", 2, 4, 'r', "Swap ENE (no horizon shift)") oreex.plot("exposure_trade_Swap_50y_2.csv", 2, 3, 'g', "Swap EPE (shifted horizon)") oreex.plot("exposure_trade_Swap_50y_2.csv", 2, 4, 'y', "Swap ENE (shifted horizon)") oreex.plot("swaption_npv.csv", 3, 4, 'g', "NPV Swaptions", marker='s') oreex.decorate_plot( title="Example 12 - Simulated exposures with and without horizon shift") oreex.save_plot_to_file() oreex.print_headline( "Plot results: Zero rate distribution with and without shift")
"collateral_none", ["log.txt", "xva.csv"] + glob.glob(os.path.join(os.getcwd(), os.path.join("Output", "exposure*")))) # threshhold=mta=0 oreex.print_headline( "Run ORE to postprocess the NPV cube, with collateral (threshold=mta=0)") oreex.run("Input/ore_mpor.xml") oreex.save_output_to_subdir( "collateral_mpor", ["log.txt", "xva.csv"] + glob.glob(os.path.join(os.getcwd(), os.path.join("Output", "exposure*"))) + glob.glob(os.path.join(os.getcwd(), os.path.join("Output", "colva*")))) oreex.print_headline("Plot results") oreex.setup_plot("nocollateral_epe") oreex.plot(os.path.join("collateral_none", "exposure_trade_Swap_1.csv"), 2, 3, 'b', "EPE Swap 1") oreex.plot(os.path.join("collateral_none", "exposure_nettingset_CPTY_A.csv"), 2, 3, 'm', "EPE NettingSet") oreex.decorate_plot(title="Example 10") oreex.save_plot_to_file() oreex.setup_plot("nocollateral_ene") oreex.plot(os.path.join("collateral_none", "exposure_trade_Swap_1.csv"), 2, 4, 'b', "ENE Swap 1") oreex.plot(os.path.join("collateral_none", "exposure_nettingset_CPTY_A.csv"), 2, 4, 'm', "ENE NettingSet") oreex.decorate_plot(title="Example 10") oreex.save_plot_to_file() oreex.setup_plot("mpor_epe") oreex.plot(os.path.join("collateral_none", "exposure_nettingset_CPTY_A.csv"),
import os sys.path.append('../') from ore_examples_helper import OreExample oreex = OreExample(sys.argv[1] if len(sys.argv) > 1 else False) # Portfolio 1 run oreex.print_headline( "Run ORE to produce NPV cube and exposures for portfolio 1") oreex.run("Input/ore_portfolio_1.xml") oreex.get_times("Output/portfolio_1/log.txt") oreex.print_headline("Plot results for portfolio 1") oreex.setup_plot("portfolio_1") oreex.plot(os.path.join("portfolio_1", "exposure_trade_swap_01.csv"), 2, 3, 'b', "EPE Swap") oreex.plot(os.path.join("portfolio_1", "exposure_trade_collar_01.csv"), 2, 4, 'r', "ENE Collar") oreex.plot(os.path.join("portfolio_1", "exposure_nettingset_CPTY_A.csv"), 2, 4, 'g', "ENE Netting") #oreex.plot(os.path.join("portfolio_1", "exposure_nettingset_CPTY_A.csv"), 2, 3, 'g', "EPE Netting") oreex.decorate_plot(title="Example 6, Portfolio 1") oreex.save_plot_to_file(os.path.join("Output", "portfolio_1")) # Portfolio 2 run oreex.print_headline( "Run ORE to produce NPV cube and exposures for portfolio 2") oreex.run("Input/ore_portfolio_2.xml") oreex.get_times("Output/portfolio_2/log.txt") oreex.print_headline("Plot results for portfolio 2")
#!/usr/bin/env python import sys sys.path.append('../') from ore_examples_helper import OreExample oreex = OreExample(sys.argv[1] if len(sys.argv) > 1 else False) oreex.print_headline("Run ORE to produce NPV for equity derivatives") oreex.run("Input/ore.xml") oreex.print_headline( "Plot results: Simulated exposures (Equity call option, forward, swap)") oreex.setup_plot("eq_call") oreex.plot("exposure_trade_EqCall_Luft.csv", 2, 3, 'r', "Call EPE") oreex.plot("exposure_trade_EqForwardTrade_Luft.csv", 2, 3, 'b', "Fwd EPE") oreex.decorate_plot( title="Example 16 - Simulated exposures for Luft call option and fwd trade" ) oreex.save_plot_to_file() #oreex.setup_plot("eq_swap") #oreex.plot("exposure_trade_EquitySwap_1.csv", 2, 3, 'r', "Equity Swap 1 EPE") #oreex.plot("exposure_trade_EquitySwap_2.csv", 2, 4, 'b', "Equity Swap 2 ENE") #oreex.decorate_plot(title="Example 16 - Simulated exposures for Equity Swaps") #oreex.save_plot_to_file()
#!/usr/bin/env python import sys sys.path.append('../') from ore_examples_helper import OreExample oreex = OreExample(sys.argv[1] if len(sys.argv) > 1 else False) oreex.print_headline("Run ORE to produce NPV cube and exposures") oreex.run("Input/ore.xml") oreex.get_times("Output/log.txt") oreex.print_headline("Run ORE again to price European Swaptions") oreex.run("Input/ore_swaption.xml") oreex.print_headline( "Plot results: Simulated exposures vs analytical swaption prices") oreex.setup_plot("swaptions") oreex.plot("exposure_trade_Swap_20y.csv", 2, 3, 'b', "Swap EPE") oreex.plot("exposure_trade_Swap_20y.csv", 2, 4, 'r', "Swap ENE") oreex.plot_npv("swaption_npv.csv", 6, 'g', "NPV Swaptions", marker='s') oreex.decorate_plot( title="Example 1 - Simulated exposures vs analytical swaption prices") oreex.save_plot_to_file()
#!/usr/bin/env python import sys sys.path.append('../') from ore_examples_helper import OreExample oreex = OreExample(sys.argv[1] if len(sys.argv) > 1 else False) oreex.print_headline( "Run ORE to produce NPV cube and exposures for CrossCurrencySwaps") oreex.run("Input/ore.xml") oreex.get_times("Output/log.txt") oreex.print_headline( "Plot results: Cross Currency Swap exposures, with and without FX reset") oreex.setup_plot("example_xccy_reset") oreex.plot("exposure_trade_XCCY_Swap_EUR_USD.csv", 2, 3, 'b', "Swap") oreex.plot("exposure_trade_XCCY_Swap_EUR_USD_RESET.csv", 2, 3, 'r', "Resettable Swap") oreex.decorate_plot(title="Example 9", legend_loc="upper left") oreex.save_plot_to_file()
oreex.print_headline("Run ORE simulation in the FWD measure") oreex.run("Input/ore_fwd.xml") oreex.save_output_to_subdir( "measure_fwd", ["log.txt", "xva.csv"] + glob.glob(os.path.join(os.getcwd(), os.path.join("Output", "exposure*")))) # BA oreex.print_headline("Run ORE simulation in the BA measure") oreex.run("Input/ore_ba.xml") oreex.save_output_to_subdir( "measure_ba", ["log.txt", "xva.csv"] + glob.glob(os.path.join(os.getcwd(), os.path.join("Output", "exposure*")))) oreex.print_headline("Plot results") oreex.setup_plot("exposures_measures") oreex.plot(os.path.join("measure_lgm", "exposure_nettingset_CPTY_A.csv"), 2, 5, 'b', "PFE LGM") oreex.plot(os.path.join("measure_ba", "exposure_nettingset_CPTY_A.csv"), 2, 5, 'g', "PFE BA") oreex.plot(os.path.join("measure_fwd", "exposure_nettingset_CPTY_A.csv"), 2, 5, 'r', "PFE FWD") oreex.plot(os.path.join("measure_lgm", "exposure_nettingset_CPTY_A.csv"), 2, 3, 'b', "EPE LGM") oreex.plot(os.path.join("measure_ba", "exposure_nettingset_CPTY_A.csv"), 2, 3, 'g', "EPE BA") oreex.plot(os.path.join("measure_fwd", "exposure_nettingset_CPTY_A.csv"), 2, 3, 'r', "EPE FWD") oreex.decorate_plot(title="Example 36") oreex.save_plot_to_file()
# threshhold>0 with collateral and dynamic initial margin oreex.print_headline( "Run ORE to postprocess the NPV cube, with collateral (threshold>0) and dynamic initial margin" ) oreex.run("Input/ore_threshold_dim.xml") oreex.save_output_to_subdir( "collateral_threshold_dim", ["log.txt", "xva.csv", "dim_regression.txt", "dim_evolution.txt"] + glob.glob(os.path.join(os.getcwd(), os.path.join("Output", "exposure*"))) + glob.glob(os.path.join(os.getcwd(), os.path.join("Output", "colva*")))) oreex.print_headline("Plot results") oreex.setup_plot("nocollateral_epe") oreex.plot(os.path.join("collateral_none", "exposure_trade_Swap_1.csv"), 2, 3, 'b', "EPE Swap 1") oreex.plot(os.path.join("collateral_none", "exposure_trade_Swap_2.csv"), 2, 3, 'r', "EPE Swap 2") oreex.plot(os.path.join("collateral_none", "exposure_trade_Swap_3.csv"), 2, 3, 'g', "EPE Swap 3") oreex.plot(os.path.join("collateral_none", "exposure_nettingset_CPTY_A.csv"), 2, 3, 'm', "EPE NettingSet") oreex.decorate_plot(title="Example 10") oreex.save_plot_to_file() oreex.setup_plot("nocollateral_ene") oreex.plot(os.path.join("collateral_none", "exposure_trade_Swap_1.csv"), 2, 4, 'b', "ENE Swap 1") oreex.plot(os.path.join("collateral_none", "exposure_trade_Swap_2.csv"), 2, 4, 'r', "ENE Swap 2") oreex.plot(os.path.join("collateral_none", "exposure_trade_Swap_3.csv"), 2, 4,
#!/usr/bin/env python import sys sys.path.append('../') from ore_examples_helper import OreExample oreex = OreExample(sys.argv[1] if len(sys.argv) > 1 else False) oreex.print_headline( "Run ORE to produce NPV cube and exposures, without collateral") oreex.run("Input/ore.xml") oreex.get_times("Output/log.txt") oreex.print_headline("Plot results") oreex.setup_plot("plot_callable_swap") oreex.plot("exposure_trade_Swap.csv", 2, 3, 'b', "EPE Swap") oreex.plot("exposure_trade_Swaption.csv", 2, 4, 'r', "ENE Swaption") oreex.plot("exposure_nettingset_CPTY_A.csv", 2, 3, 'g', "EPE Netting Set") oreex.plot("exposure_trade_ShortSwap.csv", 2, 3, 'm', "EPE Short Swap") oreex.decorate_plot(title="Example 5") oreex.save_plot_to_file()
oreex.get_times("Output/log.txt") npv = open("Output/npv.csv") call = [] put = [] for line in npv.readlines(): if "CALL" in line: line_list = line.split(',') call=([[0,line_list[6]],[line_list[3], line_list[6]]]) if "PUT" in line: line_list = line.split(',') put=([[0, line_list[6]],[line_list[3],line_list[6]]]) oreex.print_headline("Plot results: Simulated exposures vs analytical option prices") oreex.setup_plot("forward") oreex.plot("exposure_trade_FXFWD_EURUSD_10Y.csv", 2, 3, 'b', "EPE") oreex.plot("exposure_trade_FXFWD_EURUSD_10Y.csv", 2, 4, 'r', "ENE") oreex.plot_line([0, call[1][0]], [call[0][1], call[1][1]], color='g', label="Call Price") oreex.plot_line([0, put[1][0]], [put[0][1], put[1][1]], color='m', label="Put Price") oreex.decorate_plot(title="Example 7 - FX Forward") oreex.save_plot_to_file() oreex.setup_plot("option") oreex.plot("exposure_trade_FX_CALL_OPTION_EURUSD_10Y.csv", 2, 3, 'b', "EPE") oreex.plot("exposure_trade_FX_PUT_OPTION_EURUSD_10Y.csv", 2, 3, 'r', "ENE") oreex.plot_line([0, call[1][0]], [call[0][1], call[1][1]], color='g', label="Call Price") oreex.plot_line([0, put[1][0]], [put[0][1], put[1][1]], color='m', label="Put Price") oreex.decorate_plot(title="Example 7 - FX Option") oreex.save_plot_to_file()
#!/usr/bin/env python import sys sys.path.append('../') from ore_examples_helper import OreExample oreex = OreExample(sys.argv[1] if len(sys.argv) > 1 else False) oreex.print_headline("Run ORE to produce NPV") oreex.run("Input/ore.xml") oreex.get_times("Output/log.txt") oreex.print_headline("Plot results: Simulated exposures") oreex.setup_plot("CPI Swap") oreex.plot("exposure_trade_CPI_Swap_1.csv", 2, 3, 'b', "EPE CPI Swap") oreex.decorate_plot(title="Example 17", ylabel="Exposure") oreex.save_plot_to_file() oreex.setup_plot("YoY Swap") oreex.plot("exposure_trade_YearOnYear_Swap.csv", 2, 3, 'b', "EPE YoY Swap") oreex.decorate_plot(title="Example 17", ylabel="Exposure") oreex.save_plot_to_file() oreex.run("Input/ore_capfloor.xml") oreex.get_times("Output/log_capfloor.txt")
oreex.run("Input/ore_A2.xml") oreex.save_output_to_subdir( "case_A_eur_swap", ["log_2.txt", "dim_evolution_2.txt", "dim_regression_2.txt"] ) oreex.print_headline("Run ORE (case A (swap eur), 2nd order (NPV) regression)") oreex.run("Input/ore_A3.xml") oreex.save_output_to_subdir( "case_A_eur_swap", ["log_3.txt", "dim_evolution_3.txt", "dim_regression_3.txt"] ) oreex.print_headline("Plot results") oreex.setup_plot("dim_evolution_A_swap_eur") oreex.plot(os.path.join("case_A_eur_swap", "dim_evolution_1.txt"), 0, 3, 'y', "Zero Order Regression") oreex.plot(os.path.join("case_A_eur_swap", "dim_evolution_1.txt"), 0, 4, 'c', "First Order Regression") oreex.plot(os.path.join("case_A_eur_swap", "dim_evolution_2.txt"), 0, 4, 'm', "Second Order Regression") oreex.plot(os.path.join("case_A_eur_swap", "dim_evolution_3.txt"), 0, 4, 'b', "Second Order NPV Regression") oreex.plot(os.path.join("case_A_eur_swap", "dim_evolution_2.txt"), 0, 6, 'r', "Simple DIM") oreex.decorate_plot(title="Example 13 (A) - DIM Evolution Swap EUR", xlabel="Timestep", ylabel="DIM") oreex.save_plot_to_file() oreex.setup_plot("dim_regression_A_swap_eur") oreex.plot(os.path.join("case_A_eur_swap", "dim_regression_1.txt"), 1, 6, 'k', "Delta NPV", marker='+', linestyle='') oreex.plot(os.path.join("case_A_eur_swap", "dim_regression_1.txt"), 1, 5, 'y', "Zero Order Regression") oreex.plot(os.path.join("case_A_eur_swap", "dim_regression_1.txt"), 1, 2, 'c', "First Order Regression") oreex.plot(os.path.join("case_A_eur_swap", "dim_regression_2.txt"), 1, 2, 'm', "Second Order Regression") oreex.plot(os.path.join("case_A_eur_swap", "dim_regression_2.txt"), 1, 7, 'r', "Simple DIM") oreex.decorate_plot(title="Example 13 (A) - DIM Regression Swap EUR, Timestep 100", xlabel="Regressor", ylabel="DIM") oreex.save_plot_to_file()
oreex.print_headline("Run ORE (case A (swap eur), 1st order regression)") oreex.run("Input/ore_A1.xml") oreex.get_times("Output/log_1.txt") oreex.save_output_to_subdir( "case_A_eur_swap", ["log_1.txt", "dim_evolution_1.txt", "dim_regression_1.txt"]) oreex.print_headline("Run ORE (case A (swap eur), 2nd order regression)") oreex.run("Input/ore_A2.xml") oreex.save_output_to_subdir( "case_A_eur_swap", ["log_2.txt", "dim_evolution_2.txt", "dim_regression_2.txt"]) oreex.print_headline("Plot results") oreex.setup_plot("dim_evolution_A_swap_eur") oreex.plot(os.path.join("case_A_eur_swap", "dim_evolution_1.txt"), 0, 3, 'y', "Zero Order Regression") oreex.plot(os.path.join("case_A_eur_swap", "dim_evolution_1.txt"), 0, 4, 'c', "First Order Regression") oreex.plot(os.path.join("case_A_eur_swap", "dim_evolution_2.txt"), 0, 4, 'm', "Second Order Regression") oreex.decorate_plot(title="Example 13 (A) - DIM Evolution Swap EUR", xlabel="Timestep", ylabel="DIM") oreex.save_plot_to_file() oreex.setup_plot("dim_regression_A_swap_eur") oreex.plotSq(os.path.join("case_A_eur_swap", "dim_regression_1.txt"), 1, 6, 'k', "Delta NPV",