コード例 #1
0
ファイル: run.py プロジェクト: 189569400/ORE-Engine
#!/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")
コード例 #2
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")
コード例 #3
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()
コード例 #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 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()
コード例 #5
0
ファイル: run.py プロジェクト: 189569400/ORE-Engine
#!/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")
コード例 #6
0
ファイル: run.py プロジェクト: 189569400/ORE-Engine
#!/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")
コード例 #7
0
ファイル: run.py プロジェクト: 189569400/ORE-Engine
#!/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")
コード例 #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=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")
コード例 #9
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")
コード例 #10
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*"))))
コード例 #11
0
ファイル: run.py プロジェクト: 189569400/ORE-Engine
#!/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)")
コード例 #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 with flat vols")
oreex.run("Input/ore_flat.xml")

oreex.print_headline("Run ORE with smiles")
oreex.run("Input/ore_smile.xml")
コード例 #13
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"] +