Giter Site home page Giter Site logo

simm-lib's Introduction

Simm-Lib

Simm-Lib is an implementation of version 2.5 and all previous versions of the value at risk Standard Initial Margin Model (SIMM™ 2.5) developed by ISDA, see here for methodology specifications. For all future versions of SIMM, visit Open-Source Risk Engine.

ORE is the same analytics library that powers Acadia’s hosted daily UMR Risk Suite supporting the latest version ISDA SIMM v2.5A as well as all previous versions, and contains much broader pricing and integrated market/credit risk functionality for derivatives, structured products, and other traded instruments.

Users of Simm-Lib who wish to deploy it for commercial purposes will need to obtain a license from ISDA to use ISDA SIMM™ to calculate initial margin for their or their clients’ non-cleared derivatives transactions. Please contact [email protected] for more information on licensing the ISDA SIMM™.

Updates: 2022-09-12

  • SIMM v2.5 - full recalibration and industry backtesting of the methodology
  • Passing one-day benchmarks for version 2.5 including optional tests under Simmple module, checking acorss multiple applicable regulations, as well as Segregated and Unsegregated modes
  • Passing ten-day benchmarks for version 2.5 including optional tests under Simmple module, checking acorss multiple applicable regulations, as well as Segregated and Unsegregated modes

Getting Started

Simm-Lib is built with Apache Maven, so one must get Maven installed on their machine.

Ubuntu users need only run in a terminal:

$ sudo apt-get install maven

Similarly, Mac users who have Homebrew installed can run:

$ brew install maven

All others can go to the Maven homepage for specific instructions on how to download and install Maven with any operating system.

To confirm that Maven has been successfully downloaded, check the Maven version on your machine by running:

$ mvn -version

If Maven has been successfully installed, this command should return something like:

Apache Maven 3.5.0 (ff4wa5hff; 2017-04-03T15:39:06-04:00)
Maven home: --MavenHomeDirectory--
Java version: 1.8.0_91, vendor: Oracle Corporation
Java home: --JavaHomeDirectory--
Default locale: en_US, platform encoding: UTF-8
OS name: "mac os x", version: "10.11.6", arch: "x86_64", family: "mac"

Installing

Simm-Lib's sources have to be moved onto a local machine. This can be accomplished by either downloading them as a zip file from GitHub, or by running in a terminal:

$ git clone <repo> simm-lib

Next, the code's artifacts need to be built. As Simm-Lib is a Maven project, this process is simplified to running:

$ mvn compile

After this, Simm-Lib should be fully ready to run in a local environment.

Testing

To run all of Simm-Lib's tests, simply run:

$ mvn test

If one wants to run individual tests, or an individual test module, the easiest way is to open Simm-Lib in some IDE and run the tests from that.

Testing Breakdown

While there are simple tests to check the functionality of the individual methods of Simm-Lib, the main focus of the test suite is to confirm that the outputs of SIMM and Simm-Lib match. To accomplish this, the tests take in sensitivities and then run Simm-Lib's calculation, checking the result against SIMM's result:

@Test
public void test() {
    Sensitivity IR1 = new DefaultSensitivity("RatesFX", "Risk_IRCurve", "GBP", "1", "6m", "OIS", new BigDecimal("200000000"));
    Assert.assertEquals(new BigDecimal("13400000000"), Simm.calculateStandard(Arrays.asList(IR1)).setScale(0, RoundingMode.HALF_UP));
}

With the addition of the Schedule and Simmple classes the CRIF formatted objects have expanded beyond the Sensitivity object however the format of the testing is still generally the same as this is the main use case of the model.

Simm Class

This section focuses on the tests for the top level functionality of the Simm class, as the methods of this class directly consume CRIF formatted data in the form of the Sensitivity object and return the calculated IM of those inputs. There are six methods in the Simm class: calculateStanard(), calculateAdditional(), calculateTotal(), calculateTreeStandard(), calculateTreeAdditional(), and calculateTreeTotal(). The first method returns the IM of the input sensitivities, the second returns the Additional IM generated by regulatory restrictions (this includes additional value created from product class multipliers), while the third is the sum of the previous two methods. The "Tree" methods of similar names do the exact same calculation, except the intermediate exposures at key points are saved in a tree structure to give a more thorough view of how the exposure was calculated. All methods return the calculated value in US Dollars, so users of Simm-Lib working in other currencies should be sure to include the "amountCurrency", and "amountUSD" columns in their CRIF files.

The inputs to these methods are CRIF formatted data-types where all amounts are stored as BigDecimal and all other values as String:

AddOnNotionalFactor(product, factor)
ProductMultiplier(productClass, multiplier)
AddOnFixedAmount(amount, amountCurrency, amountUSD)
AddOnNotional(product, notional, notionalCurrency, notionalUSD)
Sensitivity(productClass, riskType, qualifier, bucket, label1, label2, amount, amountCurrency, amountUsd)

For Sensitivity, AddOnFixedAmount, and AddOnNotional the "currency", and "amountUSD" can be omitted; however, the currency in this case will be assumed to be US Dollars.

Schedule Class

This section focuses on the Schedule class. As the Schdule model is focued on trade level data, unlike the SIMM model which uses sensitivities, new trade-level CRIF formatted objects have been added to the module to store this data. The ScheduleNotional object stores the notional amount of the trade (Note: the notional can be set to be positive or negative, and if multiple notionals exist for the same trade they will be netted, the absolute value of the netted notional is then used in the calculation itself). The SchedulePv is the Net Present Value of the trade (similarly, the PVs will be netted by trade, and the netted value will be used).

ScheduleNotional(tradeId, schduleProductClass, valuationDate, endDate, amount, amountCurrency, amountUsd)
SchedulePv(tradeId, schduleProductClass, valuationDate, endDate, amount, amountCurrency, amountUsd)

The schdule module provides overloaded calculate() and calculateTree() methods to handle both calculating the net gross rate from the input net present values, and using an input NGR instead. All exposure amounts are returned in US Dollars.

Simmple

This section focuses on the Simmple class. The inputs to Simmple have been stream-lined at least from a CRIF object perspective. Simmple takes in Crif objects which are a super-set of all of the other CRIF formatted objects used by either the simm or schedule modules. The intent of the Crif object is to be able to directly translate a standard CRIF file into a List<Crif>.

Crif(tradeId, valuationDate, endDate, notional, notionalCurrency, imModel, productClass, riskType, qualifier, bucket, label1, label2, amount, amountCurrency, amountUsd, postRegulation, collectRegulation)

You'll notice that some fields added to the Crif object are not in any of the other CRIF formatted objects. The imModel field is simply a String which indicates which model (SIMM or Schedule) that line of data should be input into. The current allowed model strings are "SIMM", "SIMM-P", "Schedule". The notional and notionalCurrency fields are for convenience when running a schedule calcualtion. If a trade only has SchedulePv inputs but the notional field is set for at least one of those PVs, a ScheduleNotional will be constructed using the notional value. The productClass is overloaded to be either the SIMM or Schedule product classes depending on the specified model. The postRegulation and collectRegulation fields are used for Pledgor and Secured regulation respecitively. There are three different modes of specifying regulation:

  • If all regulators are left blank for both post and collect, all Crif objects in the input list will be included in the calculation. A blank regulator string is considered to be the empty string "", any number of spaces with no other characters, or an empty set of brackets "[]" which may also conatin any number of spaces.
  • If some regulators are set "include" and all others are left blank, then all Crif objects which have "include" as one of its regulators will be included in the calcualtion.
  • Otherwise, the regualtors may be set to a single name ("CFTC" or "[SEC]) or a comma seperated list of names ("CFTC,SEC" or "[CFTC,SEC]"). When calculating the exposure of a particular regulator, only Crif whose regulators are associated with the role you are running the calculation for will be included. An example of this would be if a Crif had its postRegulation set to "CFTC" and its collectRegulation set to "SEC". If you are running a calculation for the regulator "SEC" and the role is set to Pledgor, the example Crif would not be included in the calculation, but if the role was set to Secured the example Crif would be included. For simplicities sake, we call the regulator with the highest calculated exposure to be the 'winning' regulator of a 'Worst-Of' calcualtion. The output of every fucntion in the Simmple class is a ImTreeResult which contains the winning regulator, an ImTree breakdown of the exposure associated with the winning regulator, and finally the currency of all of the margins in the ImTree. The method names of the Simmple class should be fairly self-explanatory: calculateSimmWorstOf() returns the winning regulator calculating using only SIMM model Crif, calculateScheduleWorstOf() returns the winning regulator calculating using only Schedule model Crif, and calculateWorstOf() returns the winning regulator calculating over the Crif in both models.

simm-lib's People

Contributors

akommareddi avatar alec-stewart avatar dependabot[bot] avatar joe-peterson-acadiasoft avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

simm-lib's Issues

Default Test Broken

The following default test are broken:

  • testRisk1:
    Expected :73500000
    Actual :131106740
  • testIRV4:
    Expected :224633128
    Actual :647806952
  • testIRV5:
    Expected :73500000
    Actual :131106740
  • testIRV7:
    Expected :410307997
    Actual :834388517
  • testIRV8:
    Expected :492798022
    Actual :777441687
    I am running on IntelliJ IDEA 2017.2.5. SDK 1.8 on Windows

Vega Calculation for Equities

Hi all,

I am currently trying to calculate Vega risk for equities (RiskType: RiskEquityVol) using the Simmple.calculateSimmWorstOf function.

It runs through fine if using ImRole rolePledgor = ImRole.PLEDGOR; but when using
ImRole roleSecured = ImRole.SECURED; I run into the following exception:

Exception in thread "main" java.lang.IllegalStateException: The currency was either null or not a three character code as was required.

Where this is my function call

SimmpleResult res = Simmple.calculateSimmWorstOf(ldc, "USD", fx, "USD", roleSecured, typeTotal);

and ldc is my list of DefaultCrif objects.

Any idea why this would be the case?
Thanks

ISDA SIMM version 2.5A

I noticed that a new version 2.5A of the ISDA SIMM™ Methodology has been published on 2023-05-05, effective 2023-07-15. Is there an update planned for simm-lib?

ISDA has published the ISDA SIMM™ Methodology, version 2.5A, with an effective date of July 15, 2023.

This version of SIMM includes updates based on the off-cycle recalibration of only the main interest rate delta risk weights and testing of the methodology as part of industry quarterly monitoring exercise. The SIMM methodology remains a central part of the SIMM Governance Framework that SIMM users are expected to adhere to

Update ISDA SIMM 2.4

I just noticed that a new version 2.4 of the ISDA SIMM® Methodology has been published on 2021-09-09. Now I wonder if an update to simm-lib is planned?

September 9, 2021

ISDA has published the ISDA SIMM® Methodology, version 2.4, with an effective date of December 4, 2021.

The effective date of December 4, 2021 means that SIMM users should use SIMM version 2.4 to calculate the initial margin for their portfolios for close of business on Friday, December 3, 2021 onwards. This means that the first day for the exchange of initial margin calculated using SIMM 2.4 would be on Monday, December 6, 2021.

This version of SIMM includes updates based on the full recalibration and industry backtesting of the methodology.

From https://www.isda.org/2021/09/09/isda-publishes-isda-simm-v2-4/

Tenor For Risk_Equity

Dear all,

thanks again for answering my previous question. During testing we encountered the following issue while calculating Delta Margin values of Risk_Equity type:

As stated in the CRIF file description from ISDA in chapter 2.5, it is stated that Label1 (Tenor) should not have an effect on the outcome for the initial Delta margin (Label1: Unused, blank).

Using the following examples, we noticed that this is not the case in the implementation.

ProductClass RiskType Qualifier Bucket Label1 Label2 Amount
Equity Risk_Equity TESTQUALIFIER 11 3y TESTCPTY 10
Equity Risk_Equity TESTQUALIFIER 11 10y TESTCPTY 10

results in a Delta margin of 284.46, while

ProductClass RiskType Qualifier Bucket Label1 Label2 Amount
Equity Risk_Equity TESTQUALIFIER 11 3y TESTCPTY 10
Equity Risk_Equity TESTQUALIFIER 11 3y TESTCPTY 10

results in a Delta margin of 340.0.

I am using the following function call, where ldc is a list of CRIF objects of the above data.

 NoConversionFxRate fx = new NoConversionFxRate();
        ImRole rolePledgor = ImRole.PLEDGOR;
        ImRole roleSecured = ImRole.SECURED;
        SimmCalculationType typeTotal = SimmCalculationType.TOTAL;
        SimmCalculationType typeX = SimmCalculationType.STANDARD;

        // run imp
        SimmpleResult res = Simmple.calculateSimmWorstOf(ldc, "EUR", fx,"EUR", roleSecured, typeX);

Any idea why this would be the case?

Thanks,
Philip

Is simm-lib abandoned?

Commit cefc23b4 reads as if simm-lib is abandoned in favour of ORE (which is a completely different tech stack and API). Could you please confirm if this is the case? Also, it would be good practice to archive the repository in this case and/or put a big DEPRECATION notice on top.

How to run

Hi,
I am currently trying to run your implementation to validate results from our own SIMM scripts as a university project.
Could you please give me advice on how to actually run the application, as in calculating initial margins from a provided crif file.
After the initial compile command (which runs through) i am stuck at getting the application to run.
Thanks!

Bug in FXCorrelation?

I think there is a small bug in the new code from FXCorrelation:

  public BigDecimal getSensitivityCorrelation(WeightingClass si, WeightingClass sk, String calculationCurrency) {
    FXCurrencyVolatility siCurrencyVolatility = FXCurrencyVolatility.get(si.getQualifier());
    FXCurrencyVolatility skCurrencyVolatility = FXCurrencyVolatility.get(si.getQualifier());
    int siBucket = Integer.valueOf(siCurrencyVolatility.getVolatilityType());
    int skBucket = Integer.valueOf(skCurrencyVolatility.getVolatilityType());
    return getBucketCorrelation(calculationCurrency, siBucket, skBucket);
  }

I think the second line should be like this (sk instead of si):

    FXCurrencyVolatility skCurrencyVolatility = FXCurrencyVolatility.get(sk.getQualifier());

SEC Jurisdiction ISDA tests not implemented

It looks like the test suite is missing JS1 and JS2 tests - these appear to use a new 'CalculationMode' column in the ISDA unit test spec, that has values [Segregated, Unsegregated, Total]

Release needed

Lib release is needed. We need this lib in maven central.

Version in pom.xml hasn't changed

Hi
The version in the pom hasn't changed as part of this update, it's still 2.2.1 . Would you not expect to increment this to 2.3 ?
thanks

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.