.NET interface to the ISDA CDS model

We license a .NET interface to the ISDA Standard CDS model library (current version 1.8.3). This interface allows safe and convenient use of the pricing library from any .NET language, including C# and Visual Basic. The interface and library can be used both on Windows-based and Linux-based platforms. Our interface library has been production use at well known participants in the CDS market for over 13 years (since 2009)!

The interface is available now for licensing under terms which are very convenient for companies working in the financial sector and at a competitive pricing point. If you are interested, please contact us at webs@bnikolic.co.uk. Using an established wrapping rather than making your own has the following advantages:

  • Leverages a decade of our experience in writing wrappers for "C"-language code
  • Reduces likelihood of difficult to diagnose memory leaks and memory access violations
  • A system that is already used in the production environment
  • We can exactly reproduce Excel plug-in pricing

As an illustration of how the interface functions, below is a C-sharp translation of the original "C"-language example provided with the ISDA standard library:

// Copyright (C) 2009 International Swaps and Derivatives Association, Inc.
// Copyright (C) 2009, 2010 Bojan Nikolic <bojan@bnikolic.co.uk>
// LICENSE TERMS: for on-screen viewing only
//
// Example program using the .NET standard ISDA CDS library wrap
// For information please contact Bojan Nikolic
// <bojan@bnikolic.co.uk> / BN Algorithms Ltd
//
// This program closesly follows the example "C"-language program
// supplied with the ISDA library

using System;
using System.Collections;

public class JPMCDSExample
{
  /// Crate and return the zero curve object
  static public TCurve BuildExampleZeroCurve()
  {
    string[] expiries= new string[14] {"1M", "2M", "3M", "6M", "9M", "1Y",
                                   "2Y", "3Y", "4Y", "5Y", "6Y", "7Y",
                                   "8Y", "9Y"};
    double[] rates =  new double[14] { 1e-9, 1e-9, 1e-9, 1e-9, 1e-9, 1e-9, 1e-9,
                                   1e-9, 1e-9, 1e-9, 1e-9, 1e-9, 1e-9, 1e-9};
    char badDayConv = 'M';
    string holidays = "None";

    string routine="BuildExampleZeroCurve";
    int baseDate = netcds.JpmcdsDate(2008, 1, 3);
    int mmDCC=netcds.JpmcdsStringToDayCountConv("Act/360");
    int dcc=netcds.JpmcdsStringToDayCountConv("30/360");

    TDateInterval ivl=netcds.JpmcdsStringToDateInterval("6M", routine);

    double freq=netcds.JpmcdsDateIntervalToFreq(ivl);

    string types="MMMMMSSSSSSSSS";
    int n=types.Length;

    long[] dates=new long[n];
    for(int i=0; i<n; i++)
    {
      TDateInterval tmp=
    netcds.JpmcdsStringToDateInterval(expiries[i], routine);

      int cdate=netcds.JpmcdsDateFwdThenAdjust(baseDate,
                                           tmp,
                                           netcds.JPMCDS_BAD_DAY_NONE,
                                           "None");
      dates[i]=cdate;

    }

    TCurve zc = netcds.JpmcdsBuildIRZeroCurve(baseDate,
                                          types,
                                          dates,
                                          rates,
                                          n,
                                          mmDCC,
                                          (int)freq,
                                          (int)freq,
                                          dcc,
                                          dcc,
                                          badDayConv,
                                          holidays);
    return zc;
  }

  // Calculate the upfront charge
  static public double CalcUpfrontCharge(TCurve curve,
                                     double couponRate)
  {
    string routine="CalcUpfrontCharge";
    int    payAccOnDefault = 1;
    double notional = 1e7;
    int    isPriceClean = 0;
    double recoveryRate = 0.4;
    double parSpread = 3600;

    int today          = netcds.JpmcdsDate(2008, 2, 1);
    int valueDate      = netcds.JpmcdsDate(2008, 2, 1);
    int benchmarkStart = netcds.JpmcdsDate(2008, 2, 2);
    int startDate      = netcds.JpmcdsDate(2008, 2, 8);
    int endDate        = netcds.JpmcdsDate(2008, 2, 12);
    int stepinDate     = netcds.JpmcdsDate(2008, 2, 9);

    int dcc=netcds.JpmcdsStringToDayCountConv("Act/360");

    TDateInterval ivl=netcds.JpmcdsStringToDateInterval("1S",
                                                    routine);
    TStubMethod stub=netcds.JpmcdsStringToStubMethod("f/s");

    double result=
      netcds.JpmcdsCdsoneUpfrontCharge(today,
                                   valueDate,
                                   benchmarkStart,
                                   stepinDate,
                                   startDate,
                                   endDate,
                                   couponRate / 10000.0,
                                   payAccOnDefault,
                                   ivl,
                                   stub,
                                   dcc,
                                   'F',
                                   "None",
                                   curve,
                                   parSpread / 10000.0,
                                   recoveryRate,
                                   isPriceClean);
    return result * notional;

  }


  static public void Main()
  {
    Console.WriteLine("Original example from the ISDA distribution, translated to C# ");
    Console.WriteLine(netcds.JpmcdsVersionString());

    TCurve zerocurve=BuildExampleZeroCurve();

    Console.WriteLine
      (String.Format("Discount factor on 3rd Jan 08 = {0}",
                 netcds.JpmcdsZeroPrice(zerocurve,
                                        netcds.JpmcdsDate(2008,1,3))));
    Console.WriteLine
      (String.Format("Discount factor on 3rd Jan 09 = {0}",
                 netcds.JpmcdsZeroPrice(zerocurve,
                                        netcds.JpmcdsDate(2009,1,3))));
    Console.WriteLine
      (String.Format("Discount factor on 3rd Jan 17 = {0}",
                 netcds.JpmcdsZeroPrice(zerocurve,
                                        netcds.JpmcdsDate(2017,1,3))));

    Console.WriteLine("\n");
    Console.WriteLine(String.Format("Upfront charge @ cpn = 0bps    =  {0}",
                                CalcUpfrontCharge(zerocurve,
                                                  0)));
    Console.WriteLine(String.Format("Upfront charge @ cpn = 36000bps=  {0}",
                                CalcUpfrontCharge(zerocurve,
                                                  3600)));
    Console.WriteLine(String.Format("Upfront charge @ cpn = 72000bps=  {0}",
                                CalcUpfrontCharge(zerocurve,
                                                  7200)));

  }
}