Beispiel #1
0
#!/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 for Sensitivity Analysis (simulating full volatility surfaces)")
oreex.run("Input/ore_fullSurface.xml")
oreex.get_times("Output/log_fullSurface.txt")

oreex.print_headline(
    "Run ORE for Sensitivity Analysis (simulating volatility atm strikes only)"
)
oreex.run("Input/ore_atmOnly.xml")
oreex.get_times("Output/log_atmOnly.txt")
Beispiel #2
0
#!/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")

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")
Beispiel #3
0
#!/usr/bin/env python

import glob
import os
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 normal xva from BANKs view")
oreex.run("Input/ore_Normal.xml")
oreex.get_times("Output/log.txt")
oreex.save_output_to_subdir(
    "NormalXVA", ["log.txt", "xva.csv"] +
    glob.glob(os.path.join(os.getcwd(), os.path.join("Output", "exposure*"))))

oreex.print_headline("Run ORE to produce flipped xva from CPTY_As view")
oreex.run("Input/ore_FlipView.xml")
oreex.get_times("Output/log.txt")
oreex.save_output_to_subdir(
    "FlippedXVA", ["log.txt", "xva.csv"] +
    glob.glob(os.path.join(os.getcwd(), os.path.join("Output", "exposure*"))))

oreex.print_headline(
    "Run ORE to produce normal xva with reversed swap (identical to flipped xva as BANK and CPTY_A have identical Default and fva curves)"
)
oreex.run("Input/ore_ReversedNormal.xml")
oreex.get_times("Output/log.txt")
oreex.save_output_to_subdir(
    "ReversedNormalXVA", ["log.txt", "xva.csv"] +
Beispiel #4
0
#!/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()
Beispiel #5
0
#!/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()
Beispiel #6
0
#!/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()
Beispiel #7
0
#!/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 illustrate use of fixed vs float cross currency swaps")
oreex.run("Input/ore.xml")
Beispiel #8
0
#!/usr/bin/env python

import glob
import os
import sys
sys.path.append('../')
from ore_examples_helper import OreExample

oreex = OreExample(sys.argv[1] if len(sys.argv) > 1 else False)

# whithout collateral
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.save_output_to_subdir(
    "collateral_none", ["log.txt", "xva.csv"] +
    glob.glob(os.path.join(os.getcwd(), os.path.join("Output", "exposure*"))))

# Threshhold>0
oreex.print_headline(
    "Run ORE to postprocess the NPV cube, with collateral (threshold>0)")
oreex.run("Input/ore_threshold.xml")
oreex.save_output_to_subdir(
    "collateral_threshold", ["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*"))))

# mta=0
oreex.print_headline(
    "Run ORE to postprocess the NPV cube, with collateral (threshold=0)")
Beispiel #9
0
#!/usr/bin/env python

import glob
import os
import sys
sys.path.append('../')
from ore_examples_helper import OreExample

oreex = OreExample(sys.argv[1] if len(sys.argv) > 1 else False)

# LGM
oreex.print_headline("Run ORE simulation in the LGM measure")
oreex.run("Input/ore_lgm.xml")
oreex.save_output_to_subdir(
    "measure_lgm", ["log.txt", "xva.csv"] +
    glob.glob(os.path.join(os.getcwd(), os.path.join("Output", "exposure*"))))

# FWD
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*"))))
Beispiel #10
0
#!/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 Digital CMS spread sensitivities")
oreex.run("Input/ore.xml")
oreex.get_times("Output/log.txt")
Beispiel #11
0
#!/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 build USD-Prime curve.")
oreex.run("Input/ore.xml")
oreex.get_times("Output/log.txt")
Beispiel #12
0
#!/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 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',
Beispiel #13
0
#!/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 with flat vols")
oreex.run("Input/ore_flat.xml")

oreex.print_headline("Run ORE with smiles")
oreex.run("Input/ore_smile.xml")
Beispiel #14
0
#!/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 commodity example")
oreex.run("Input/ore.xml")
oreex.get_times("Output/log.txt")
Beispiel #15
0
#!/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()
Beispiel #16
0
#!/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()
Beispiel #17
0
#!/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 illustrate use of discount ratio curve")

oreex.print_headline("Run with USD base currency")
oreex.run("Input/ore_usd_base.xml")

oreex.print_headline("Run with EUR base currency using GBP-IN-EUR discount modified ratio curve")
oreex.run("Input/ore_eur_base.xml")
Beispiel #18
0
#!/usr/bin/env python

import sys
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")
Beispiel #19
0
#!/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 for Sensitivity Analysis")
oreex.run("Input/ore.xml")
oreex.get_times("Output/log.txt")
Beispiel #20
0
#!/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()
Beispiel #21
0
#!/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 for equity swap")
oreex.run("Input/ore.xml")
Beispiel #23
0
#!/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")
Beispiel #24
0
#!/usr/bin/env python

import glob
import os
import sys
sys.path.append('../')
from ore_examples_helper import OreExample

oreex = OreExample(sys.argv[1] if len(sys.argv) > 1 else False)

# whithout collateral
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.save_output_to_subdir(
    "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")
Beispiel #25
0
#!/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 CDS NPV")
oreex.run("Input/ore.xml")
oreex.get_times("Output/log.txt")
Beispiel #26
0
#!/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 T0 Bond")
oreex.run("Input/ore.xml")
oreex.get_times("Output/log.txt")
Beispiel #27
0
#!/usr/bin/env python

import os
import sys
sys.path.append('../')
from ore_examples_helper import OreExample

oreex = OreExample(sys.argv[1] if len(sys.argv)>1 else False)

# Case A
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("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")
Beispiel #28
0
#!/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")
oreex.run("Input/ore.xml")
oreex.get_times("Output/log.txt")