Open Source Risk Engine - QuantLib

3y ago
76 Views
13 Downloads
2.00 MB
67 Pages
Last View : 1m ago
Last Download : 3m ago
Upload by : Oscar Steel
Transcription

Open Source Risk EnginePeter CaspersQuaternion Risk Management9 December 2016

AgendaOpen Source Risk ProjectQuantLib Extension LibraryData LibraryAnalytics Library

AgendaOpen Source Risk ProjectQuantLib Extension LibraryData LibraryAnalytics Library 2017 Quaternion Risk Management Ltd.Peter Caspers3

OverviewThe Open Source Risk Project aims at establishing a transparentpeer-reviewed framework for pricing and risk analysis that canserve asa benchmarking, validation, training, teaching referencean extensible foundation for in-house and vendor solutions 2017 Quaternion Risk Management Ltd.Peter Caspers4

OverviewThe Open Source Risk Projectis sponsored by Quaternion Risk Managementis open source software (Modified BSD License)permits using, modifying and even commercialising the codeis based on QuantLib, the open source source library forquantitative finance.Its main software project is Open Source Risk Engine (ORE). 2017 Quaternion Risk Management Ltd.Peter Caspers5

OverviewORE1provides contemporary risk analytics and pricing2accessible to the end users by providing transparent interfacesfor trade and market data, as well as system configuration3well documented usage, methodology and codebase 2017 Quaternion Risk Management Ltd.Peter Caspers6

Analytics ScopePortfolio pricing and cash flow projectionDerivative portfolio analytics based on a Monte Carlo simulationframeworkCredit exposure evolution with netting and collateral (EE, EPE,EEPE, PFE) supporting regulatory capital charge calculationunder internal model methodsCollateral modeling with Dynamic Initial Margin (DIM)Derivative value adjustments (CVA, DVA, FVA, COLVA, MVA)Market risk measures 2017 Quaternion Risk Management Ltd.Peter Caspers7

Data FlowPortfolio Loading“Curve” BuildingModel Calibrationt0 PricingMarket SimulationForward PricingAggregationCollateral ModelingExposure AnalyticsTrade data (xml)NPV ReportCashflow ReportExposure ReportsXVA ReportsNPV CubeNet NPV CubeMarket dataConfiguration (xml)ProcessingInputOutput 2017 Quaternion Risk Management Ltd.Interactive Visualisation:Evolution of Exposure and NPV distributionsPeter Caspers8

ComponentsBasic%Applica on/Launchers%Risk%Analy nsion%Boost%Libraries% 2017 Quaternion Risk Management Ltd.Peter Caspers9

ProductsORE’s initial product scope comprises Interest Rate and FX productsInterest Rate SwapsCaps/FloorsSwaptionsCross Currency SwapsFX ForwardsFX Options 2017 Quaternion Risk Management Ltd.Peter Caspers10

FeaturesORE comes with extensive tests, examples and documentationComprehensive test suitesVarious examples to demonstrate typical use casesSeveral ways to launch ORE and visualise resultsDetailed user guide on examples and parametrisationComprehensive source code documentation 2017 Quaternion Risk Management Ltd.Peter Caspers11

User InterfacesXML file driven command line applicationJupyter notebook for NPV Cube and Exposure visualisationExcel and LibreOffice Calc spreadsheets to kick off jobs andpresent resultsWeb-based risk dashboard for interactive presentation of OREresults 2017 Quaternion Risk Management Ltd.Peter Caspers12

AudienceORE is suited for users in the industry and academiaEnd Users in Front Office, Risk, Finance and Audit functionsinterested in quickly parameterising and running analytics,Quants and Developers interested in inspecting, modifying andextending the code baseStudents and Academics interested in practical examples toenhance their course work 2017 Quaternion Risk Management Ltd.Peter Caspers13

MethodsModels and methods applied in ORE are based onModern Derivatives Pricing and Credit Exposure Analysis, PalgraveMacMillan 2015 2017 Quaternion Risk Management Ltd.Peter Caspers14

Risk Factor EvolutionIR/FX: Cross Currency Linear Gauss Markov model (i.e.Gaussian single factor interest rate models for each currency,Geometric Brownian Motion for each FX component)Inflation: Dodgson-Kainth, Jarrow-YildirimCredit: Gaussian, Cox-Ingersoll-Ross, Black-Karasinski,Peng-KouEquity: GBM, HestonCommodity: GBM, 2-factor Gabillon 2017 Quaternion Risk Management Ltd.Peter Caspers15

IR/FX Model: Cross Currency LGMdz0 α0 dW0zdzi γi dt αi dWiz ,dxi µi dt σi dWix ,xii 0i 0zzγi αi2 Hi ρzxii σi αi ρi0 αi α0 H0µi r0 ri ρzx0i α0 H0 σiri fi (0, t) zi (t) Hi0 (t) ζi (t) Hi (t) Hi0 (t),Zζi (t) tαi2 (s) ds0Numeraire and zero bond: 11N(t) exp Ht zt Ht2 ζtP(0, t)2 P(0, T)1P(t, T, zt ) exp (HT Ht ) zt HT2 Ht2 ζt .P(0, t)2 2017 Quaternion Risk Management Ltd.Peter Caspers16

Exposure MeasuresIn ORE we use the following exposure definitions N (NPV(t) C(t))EE(t) EPE(t) EN(t) N ( NPV(t) C(t))ENE(t) EN(t)where NPV(t) stands for the netting set NPV and C is the postedcollateral. 2017 Quaternion Risk Management Ltd.Peter Caspers17

Basel III ExposuresExpected ExposureEEB (t) E[max(NPV(t) C(t), 0)] : EE(t)P(0, t)Expected Positive ExposureEPEB (T) 1XEEB (t) · tT t TT min(1, maturity)Effective Expected ExposureEEEB (t) max(EEEB (t t), EEB (t))Effective Expected Positive ExposureEEPEB (T) 1XEEEB (t) · tT t T 2017 Quaternion Risk Management Ltd.Peter Caspers18

CVA and DVAUnilateral discretised CVA and DVAXCVA PD(ti 1 , ti ) LGD EPE(ti )iDVA XPDBank (ti 1 , ti ) LGDBank ENE(ti )iwithEPE(t) expected exposureENE(t) expected negative exposurePD(ti , tj ) counterparty probability of default in [ti , tj ]PDBank (ti , tj ) our probability of default in [ti , tj ]LGD counterparty loss given defaultLGDBank our loss given default 2017 Quaternion Risk Management Ltd.Peter Caspers19

FCA and FBAFVA nX fb (ti 1 , ti ) δi EN SC (ti 1 ) SB (ti 1 ) (NPV(ti )) D(ti )i 1 nX{zFunding Benefit Adjustment (FBA)} fl (ti 1 , ti ) δi EN SC (ti 1 ) SB (ti 1 ) ( NPV(ti )) D(ti )i 1 {zFunding Cost Adjustment (FCA)}D(ti ) stochastic discount factor, 1/N(ti ) in LGMNPV(ti ) portfolio value after potential collateralizationSC (tj ) survival probability of the counterpartySB (tj ) survival probability of the bankfb (tj ) borrowing spread for the bank rel. to the coll. comp. ratefl (tj ) lending spread for the bank rel. to the coll. comp. rate 2017 Quaternion Risk Management Ltd.Peter Caspers20

COLVAWhen the CSA defines a collateral compounding rate that deviatesfrom the overnight rate, this gives rise to another value adjustmentlabeled COLVA. In the simplest case the deviation is just given by aconstant spread :NCOLVA E"X#C(ti ) · · δi · D(ti 1 )iwhere C(t) is the collateral posted and D(t) is the stochastic discountfactor 1/N(t) in LGM. Both C(t) and N(t) are computed in ORE’sMonte Carlo framework, and the expectation yields the desiredadjustment. 2017 Quaternion Risk Management Ltd.Peter Caspers21

CSA Floor"NΠFloor, E#X C(ti ) · ((r(ti ) ) (r(ti ) )) · δi · D(ti 1 )iSimilar to COLVA with stochastic spread,paying off when overnight rates are negativewith stochastic notional given by the amount of posted collateralwith significant correlation between notional and rateSee Burgard-Kjaer, or Lichters/Stamm/Gallagher. 2017 Quaternion Risk Management Ltd.Peter Caspers22

Collateral ModelORE computes the collateral requirement (aka Credit SupportAmount) through time along each Monte Carlo path(max(0, Vset (tm ) IA Thold ), Vset (tm ) IA 0CSA(tm ) min(0, Vset (tm ) IA Thold ), Vset (tm ) IA 0whereVset (tm ) is the value of the netting set as of time tmThold is the threshold exposure below which no collateral isrequired (possibly asymmetric)IA is the sum of all collateral independent amounts attached tothe underlying portfolio of trades (positive amounts imply that thebank has received a net inflow of independent amounts from thecounterparty), assumed here to be cash. 2017 Quaternion Risk Management Ltd.Peter Caspers23

Collateral ModelCollateral account balance: C(tm )Collateral shortfall: CSA(tm ) C(tm )Taking the value M(tm ) of unsettled margin calls into account: (t) CSA(tm ) C(tm ) M(tm )The margin Delivery Amount D(tm ) is calculated as follows:(D(tm ) (t), (t) MTA0, (t) MTAwhere MTA is the minimum transfer amount.D(tm ) is settled with a delay specified by the Margin Period of Risk(MPOR) which leads to residual exposure and XVA even for dailymargining,zero thresholds and minimum transferamounts. 2017 Quaternion Risk Management Ltd.Peter Caspers24

Exposure and XVA Allocation to Trade LevelXVAs and exposures are typically computed at netting set level.For accounting purposes it may be required to allocate XVAs fromnetting set to individual trade level such that the allocated XVAs addup to the netting set XVA.This distribution is not trivial, since due to netting and imperfectcorrelation single trade (stand-alone) XVAs hardly ever add up to thenetting set XVA: XVA is sub-additive similar to VaR.ORE provides an allocation method (labeled marginal allocation inthe following) which slightly generalises a method proposed byPykhtin and Rosen in 2010.Allocation is done path-wise which first leads to allocated expectedexposures and then to allocated CVA/DVA by inserting theseexposures into CVA and DVA equations. 2017 Quaternion Risk Management Ltd.Peter Caspers25

Exposure and XVA Allocation to Trade LevelThe allocation algorithm in ORE is as follows:Consider the netting set’s discounted NPV after taking collateralinto account, on a given path at time t:E(t) D(0, t) (NPV(t) C(t))On each path, compute contributions Ai of the latter to trade i as E(t) NPV i (t)/NPV(t), NPV(t) Ai (t) E(t)/n, NPV(t) with number of trades n in the netting set and trade i’s valueNPV i (t).The EPE fraction allocated to trade i at time t: EPEi (t) E A i (t)PPBy construction, i Ai (t) E(t) and hence i EPEi (t) EPE(t). 2017 Quaternion Risk Management Ltd.Peter Caspers26

Dynamic Initial Margin and MVAPartially covered in ORE, see Roland’s presentation. 2017 Quaternion Risk Management Ltd.Peter Caspers27

TimelineRelease: 7 October 2016Web site, FAQ, Forum:http://www.opensourcerisk.orgCode base:https://github.com/OpenSourceRisk/EngineNext release: Q1 2017 2017 Quaternion Risk Management Ltd.Peter Caspers28

opensourcerisk.org 2017 Quaternion Risk Management Ltd.Peter Caspers29

github.com/OpenSourceRisk/Engine 2017 Quaternion Risk Management Ltd.Peter Caspers30

RoadmapAnalytics:SA-CCR, the new standard for derivatives capitalSensitivity analysis and stress testingParametric VaR and initial margin methodsAsset classes and simulation models:Credit simulation, credit derivatives and loan productsDefault risk modeling and credit portfolio analysisInflation simulation and inflation derivativesEquity simulation, equity derivativesCommodity simulation, commodity derivatives 2017 Quaternion Risk Management Ltd.Peter Caspers31

CommunityUsers and developers are invited to contribute to the project:Discussions, feedback, enhancement proposals atwww.opensourcerisk.org/forumPull requests, seewww.opensourcerisk.org/contributions 2017 Quaternion Risk Management Ltd.Peter Caspers32

SponsorshipQuaternion is committed to sponsor the project in several ways. Inaddition to the initial release, Quaternion provides resources tofurther develop ORE to regularly deliver extensionsanswer community questions in the ORE forumadministrate and consolidate community contributions submittedvia email or pull requestspromote ORE at conferences and through publicationsseek additional sponsors to help promoting ORE and making itwidely known and used 2017 Quaternion Risk Management Ltd.Peter Caspers33

Interest Rate SwapsExample 1 - Simulated exposures vs analytical swaption prices900,000Swap EPESwap ENENPV 00300,000200,000100,00000510Time / Years152025Figure: Vanilla ATM Swap expected exposure in a flat market environment. 2017 Quaternion Risk Management Ltd.Peter Caspers34

Interest Rate SwapsExample 21,400,000EPEENEPayer SwaptionReceiver 0,000200,00000510Time / Years152025Figure: Vanilla ATM Swap expected exposure in a realistic marketenvironment as of 05/02/2016. 2017 Quaternion Risk Management Ltd.Peter Caspers35

Cross Currency SwapsExample 914,000,000SwapResettable 4,000,0002,000,00000246Time / Years81012Figure: Cross Currency Swap exposure evolution with and withoutmark-to-market notional reset. 2017 Quaternion Risk Management Ltd.Peter Caspers36

Netting and CollateralExample 104,000,000EPE Swap 1EPE Swap 2EPE Swap 3EPE ,0001,500,0001,000,000500,00000246Time / Years81012Figure: Three Swaps netting set, no collateral. 2017 Quaternion Risk Management Ltd.Peter Caspers37

Netting and CollateralExample 103,000,000EPE NettingSet, Threshold 1mEPE NettingSet, Threshold 1m, 500,00000246Time / Years81012Figure: Three Swaps netting set, THR 1m EUR, MTA 100k EUR, MPR 2w.The red evolution assumes that the each trade is terminated at the next breakdate. The blue evolution ignores break dates. 2017 Quaternion Risk Management Ltd.Peter Caspers38

Netting and CollateralExample 104,000,000EPE NettingSetEPE NettingSet, MPOR 0,0001,000,000500,00000246Time / Years81012Figure: Three Swaps, THR MTA 0, MPR 2W. 2017 Quaternion Risk Management Ltd.Peter Caspers39

Exposure AllocationExample 102,500,000Allocated EPE Swap 1Allocated EPE Swap 2Allocated EPE Swap 00-1,000,000-1,500,0000246Time / Years81012Figure: Exposure allocation without collateral (Pykhtin/Rosen). 2017 Quaternion Risk Management Ltd.Peter Caspers40

Exposure AllocationExample 1010,000,000Allocated EPE Swap 1Allocated EPE Swap 2Allocated EPE Swap 00246Time / Years81012Figure: Exposure allocation with collateral and threshold 1m EUR(Pykhtin/Rosen). 2017 Quaternion Risk Management Ltd.Peter Caspers41

Long-term SimulationExample 12 - Simulated exposures with and without horizon shiftSwap EPE (no horizon shift)Swap ENE (no horizon shift)Swap EPE (shifted horizon)Swap ENE (shifted horizon)NPV 000102030Time / Years405060Figure: Long term Swap exposure simulation with and without LGM horizonshift to 30y. 2017 Quaternion Risk Management Ltd.Peter Caspers42

Long-term Simulation0.25000.2000Example 12 - 5y zero rate (EUR) distribution with and without horizon shiftNo horizon shift (mean)No horizon shift (mean /- std)Shifted horizon (mean)Shifted horizon (mean /- std)Zero 220372042Time2047205220572062Figure: Long term rate simulation with and without LGM horizon shift to 30y. 2017 Quaternion Risk Management Ltd.Peter Caspers43

AgendaOpen Source Risk ProjectQuantLib Extension LibraryData LibraryAnalytics Library 2017 Quaternion Risk Management Ltd.Peter Caspers44

QuantExt - QuantLib Extension LibraryQuantExt adds supplementary building blocks to QuantLiba cross asset model and associated pricing enginesrate helpers for bootstrapping cross currency and tenor basiscurvesa few instruments like currency swaps, basis swaps and averageOIS swapsadditional currencies and indexes 2017 Quaternion Risk Management Ltd.Peter Caspers45

StructureThe directory structure is like in QuantLibQuantExt / qle/ ntExt / test / 2017 Quaternion Risk Management Ltd.Peter Caspers46

Code aOpenRiskEngineAnalyticsSum 2017 Quaternion Risk Management Ltd.Files 2400 200 160 60 420Lines of Code360k20k20k7k47kPeter CaspersUnit Test Cases6463620217747

CrossAssetModelQuantExt provides an implementation of a cross asset modelmulti-Gaussian IR-FX (-INF-CR-EQ-COM)1exact discretization of the underlying stochastic process for largestep simulationsutilizing Joshi’s Sobol Brownian bridge generator provided inQuantLib’s market model implementationanalytic vanilla option engines for fast calibrationextensible - other models can be plugged in (Heston, multifactorLGM, stochastic basis models, .) 2017 Quaternion Risk Management Ltd.Peter Caspers48

Test SuiteExtensive test suite, e.g. for the model partconsistency with finite difference and Gaussian1D pricingengines in QuantLibrecovery of analytical moments by Euler Monte Carlomartingale property of deflated payoffsrepricing of calibration baskets with Monte Carlo 2017 Quaternion Risk Management Ltd.Peter Caspers49

QuantLib as a Backbone for XVA SimulationsQuantLib 1.8 can be used for efficient XVA simulationsno modifications in QuantLib necessary - this is fantasticbut we use workarounds at some places, which are efficient inpractice, but not cleanin the following we derive proposals for future QuantLibdevelopment from this 2017 Quaternion Risk Management Ltd.Peter Caspers50

Proposal #1 Floating TermstructuresWe make extensive use of evaluation date shifts during simulationprovide floating and fixed reference date term structuresconsistently throughout the libraryexpose TermStructure::moving to make fixed and floatingterm structures distinguishable during run time2add floating lags for NPV and settlement date parameters inpricing engines, for example and notably in theDiscountingSwapEngineprovide fixed and floating bootstrap helpers 2017 Quaternion Risk Management Ltd.Peter Caspers51

Proposal #2 QuotesQuotes are the central tool to apply scenarios to term structuresduring simulationsupport quotes in ExchangeRateManagerprovide quote based constructors in term structures consistently 2017 Quaternion Risk Management Ltd.Peter Caspers52

Proposal #3 ObservabilityObservability is used to propagate quote updates to term structuresand instruments during simulationa naive use yields correct results, but may be slowdeferral of notifications3 does not seem to speed up oursimulation or even slows it down in casesour workarounds aredisable Notifications and manually update term structures andinstrumentsunregister coupons from evaluation date observationgoal: can we tape the notification graph on a small subset ofsimulation paths (or one path) and derive a minimal set ofobjects that needs to be updated from that? 2017 Quaternion Risk Management Ltd.Peter Caspers53

Proposal #4 Simulated FixingsDuring simulation, future fixings have to be generated and publishedrequired fixings are implicitly known from pricing on the originalevaluation date.no global notification of all observers4 necessary when adding asimulated fixingpathwise generation of future fixings and publishing them can beautomated by an extension of Indexno need for changes in pricing engines(almost) zero overhead when simulated fixings mode is disabled 2017 Quaternion Risk Management Ltd.Peter Caspers54

AgendaOpen Source Risk ProjectQuantLib Extension LibraryData LibraryAnalytics Library 2017 Quaternion Risk Management Ltd.Peter Caspers55

Data LibraryOpenRiskEngineData is a C 11 library that manages marketand trade dataConfigured via API or XML (using RapidXML)Flexible curve bootstrap can be configured for Libor, OIS, XOIS,etc leaving the choice to usersCurve configuration defined for all market curves (optionsurfaces/cubes) which maps to QL TermStructuresLightweight portfolio data modelAgain trade XML maps to QL Instruments 2017 Quaternion Risk Management Ltd.Peter Caspers56

XML Example Trade id "123456" TradeType Swap /TradeType ScheduleData Envelope Rules CounterParty CP A /CounterParty StartDate 20120530 /Sta Netti

Credit exposure evolution with netting and collateral (EE, EPE, EEPE, PFE) supporting regulatory capital charge calculation . ORE comes with extensive tests, examples and documentation Comprehensive test suites Various examples to demonstrate typical use cases Several ways to launch ORE and visualise results . ii i i ˆ zz i0 i 0 .

Related Documents:

1.Engine Oil SABA 13 1.Engine Oil 8000 14 1.Engine Oil 6000 15 1.Engine Oil 3000 16 1.Engine Oil Alvand 17 1.Engine Oil Motor Cycle Engine Oil M-150 18 1.Engine Oil M-100 19 1.Engine Oil Gas Engine Oil CNG-BUS 20 1.Engine Oil G.I.C.X.LA 21 1.Engine Oil G.I.C.X. 22 1.Engine Oil Diesel Engine Oil Power 23 1.Engine Oil Top Engine 24

COUNTY Archery Season Firearms Season Muzzleloader Season Lands Open Sept. 13 Sept.20 Sept. 27 Oct. 4 Oct. 11 Oct. 18 Oct. 25 Nov. 1 Nov. 8 Nov. 15 Nov. 22 Jan. 3 Jan. 10 Jan. 17 Jan. 24 Nov. 15 (jJr. Hunt) Nov. 29 Dec. 6 Jan. 10 Dec. 20 Dec. 27 ALLEGANY Open Open Open Open Open Open Open Open Open Open Open Open Open Open Open Open Open Open .

The Aircraft Engine Design Project Fundamentals of Engine Cycles Ken Gould Spring 2009 Phil Weed 1. g GE Aviation Technical History GE Aircraft Engines U.S. jet engine U.S. turboprop engine Vibl tt iVariable stator engine Mach 2 fighter engine Mach 3 bomber engine High bypass engine

the Source 1 power source until the Source 2 power source does appear. Conversely, if connected to the Source 2 power source and the Source 2 power source fails while the Source 1 power source is still unavailable, the ATS remains connected to the Source 2 power source. ATSs automatically perform the transfer function and include three basic .

Risk Matrix 15 Risk Assessment Feature 32 Customize the Risk Matrix 34 Chapter 5: Reference 43 General Reference 44 Family Field Descriptions 60 ii Risk Matrix. Chapter 1: Overview1. Overview of the Risk Matrix Module2. Chapter 2: Risk and Risk Assessment3. About Risk and Risk Assessment4. Specify Risk Values to Determine an Overall Risk Rank5

Open source software Open source software has been a nebulous reference to any software that is free, and is often confused with freeware and shareware. The Open Source Initiative (OSI; www. opensource.org) has therefore become a certification body for open source software under a commonly agreed-upon definition for "open source".

open source: boundless suite 4.9.1 4 open source: geonode 2.8 5 open source: deegree3 3.3.2 (osgeo-live dvd 11.0) 5 open source: geomajas 2.4.0 (osgeo-live dvd 11.0) 5 installation of open source web gis applications 6 visual model: web gis application features grouped by functionality 6 functionality comparison matrix 7 summary 9

of its Animal Nutrition Series. The Food and Drug Administration relies on information in the report to regulate and ensure the safety of pet foods. Other reports in the series address the nutritional needs of horses, dairy cattle, beef cattle, nonhuman primates, swine, poultry, fish, and small ruminants. Scientists who study the nutritional needs of animals use the Animal Nutrition Series to .