
OpenRedukti Documentation Dibyendu Majumdar Apr 30, 2019 Contents: 1 Introduction 1 1.1 Main Features..............................................1 1.2 Background................................................1 1.3 Ackowledgements............................................2 2 OpenRedukti C++ API 3 2.1 Basics...................................................3 2.2 Namespace................................................3 2.3 About this document...........................................3 2.4 Common Enums.............................................3 2.5 Date type.................................................4 2.6 Holiday Calendars............................................8 2.7 Day Count Fractions........................................... 10 2.8 Index Types................................................ 11 2.9 Useful Conversions............................................ 14 2.10 Automatic Differentiation........................................ 15 2.11 Calculation Schedules.......................................... 17 2.12 Memory Allocators............................................ 18 2.13 Interpolators............................................... 21 2.14 Interest Rate Curves........................................... 23 2.15 Time Series / Fixings........................................... 27 2.16 Cashflows................................................. 28 2.17 Cashflow Pricing............................................. 31 2.18 Curve Building.............................................. 32 2.19 Valuation Service............................................. 34 3 OpenRedukti Scripting With Ravi 39 3.1 Date Types................................................ 39 3.2 Holiday Calendars............................................ 40 3.3 Day Count Fractions........................................... 40 3.4 Indices.................................................. 41 3.5 Automatic Differentiation........................................ 41 3.6 Calculation Schedules.......................................... 43 3.7 Interpolators............................................... 45 3.8 Interest Rate Curves........................................... 46 3.9 Time Series / Fixings........................................... 47 3.10 Cashflows................................................. 47 i 3.11 Utility for Loading Data......................................... 49 3.12 Building Curves............................................. 50 3.13 Cashflow Pricing............................................. 51 4 Building OpenRedukti 55 4.1 Dependencies............................................... 55 4.2 Pre-Requisites.............................................. 55 4.3 Build OpenRedukti............................................ 55 4.4 Setup OpenBLAS and LAPACK..................................... 56 4.5 Obtain Protocol Buffers via vcpkg.................................... 56 4.6 Build OpenRedukti............................................ 56 5 Indices and tables 59 ii CHAPTER 1 Introduction OpenRedukti is a C++ library for working with Interest Rate Derivative products such as Interest Rate Swaps, and FRAs. It allows you to build Interest Rate curves with different interpolation methods, and then use these curves to compute present value and sensitivities of Interest Rate Derivatives. OpenRedukti is Free Software, licensed under the GNU General Public License, v3. If you wish to use OpenRedukti under a non-GPL license, you can raise an issue on GitHub repository. A liberal license will be granted to your company at zero cost, provided you agree to allow your company to be listed as a user of OpenRedukti. 1.1 Main Features • Small library with minimal external dependencies (only external dependencies are BLAS, LAPACK and Google Protocol Buffers) • Ability to express an interest rate product as a set of cashflows • Bootstrap continuously compounded zero coupon interest rate curves using Linear, CubicSpline, and Mono- toneConvex interpolators • Interpolate curves in the discount factor space using LogLinear and LogCubicSpline interpolators • Compute present value of cashflows • Compute first and second order derivatives using Automatic/algorithmic Differentiation. • Script using Ravi - a derivative of Lua programming language 1.2 Background OpenRedukti is part of the MyCCP product that was being developed by REDUKTI LIMITED. The development of MyCPP was halted in June 2017 due to lack of funding. A decision was taken then to Open Source parts of the MyCCP product, leading to the release of OpenRedukti. The main differences between the Open Source release and the proprietary version used in MyCCP are: 1 OpenRedukti Documentation • Only the core C++ pricing library has been released • The functionality for generating cashflows from FpML trades has not been released as this is fine tuned for the needs of MyCCP • The Limit Checker and VaR Calculator have not been released • The MyCCP front-end and middle tier components, written in C#, have not been released as these are very specific to requirements of a CCP. For further details of the full scope of the MyCCP product, please visit Redukti.Com. 1.3 Ackowledgements OpenRedukti gratefully acknowledges ideas and code it is using from other projects. • My good friend Christer Rydberg for showing me how to implement Automatic Differentiation and for help and advice over the years. • Jeffrey Fike’s work on automatic differentiation using hyperdual vectors. • QuantLib which has provided the basis for some of the key components such as interpolators. • The monotone convex interpolation method is based on papers and VB code from Financial Modeling Agency. • The C/C++ Minpack library provides the Levenberg-Marquardt solver used in curve building. 2 Chapter 1. Introduction CHAPTER 2 OpenRedukti C++ API This document described the C++ API that is available to programmers. 2.1 Basics The OpenRedukti C++ API is designed to be fairly simple to use. While OpenRedukti uses C++ templates internally, these are not exposed at a user level. The API is presented as a simple set of virtual classes and functions. OpenRedukti uses a bunch of data types defined using Google Protocol Buffers. These reduce the need to manually maintain data types and greatly improve the ability to make rapid changes to the codebase. 2.2 Namespace All components live in the namespace redukti. 2.3 About this document The description of the C++ classes below focuses on the API - hence all other aspects have been removed. 2.4 Common Enums #include <enums.pb.h> For reasons of efficiency all internal data structures use integer codes rather than strings for values. Most of the enums used are defined in the protocol buffers definition file enums.proto. redukti::Currency Defines currency codes 3 OpenRedukti Documentation redukti::IsdaIndex Defines commonly used ISDA Index names redukti::IndexFamily Defines families of indices redukti::DayCountFraction Defines supported ISDA Day Count Fractions redukti::CompoundingMethod Defines compounding methods; compatible with FpML. redukti::BusinessCenter Defines commonly used ISDA codes for business centers. These are used to derive holiday calendars. redukti::BusinessDayConvention Defines ISDA specified business day conventions. redukti::Tenor Defines a tenor period such as 1M or 1Y. The codes are designed so that larger terms have higher codes. redukti::PeriodUnit Defines the unit in which a period is measured, e.g. Days or Months, etc. redukti::RollConvention Defines ISDA specified roll conventions for calculating periods for interest rate streams. redukti::JointCalendarRule Defines how multiple business centers are to be combined for the purposes of comput- ing holidays. redukti::InterpolatorType Defines the supported interpolation methods. redukti::CurveGroup Defines curve group ids for the purposes of grouping curves used in pricing. redukti::IRRateType Defines the type of value being used in a curve definition. redukti::PricingCurveType Defines the usage of a curve in a pricing scenario. redukti::MarketDataQualifier Defines the type of Market Data being used. redukti::MaturityGenerationRule Defines the rule name for generating maturities of instruments in a curve. 2.5 Date type #include <date.h> Dates are used extensively in OpenRedukti. To make it efficient to manipulate dates an integer representation of a Date is chosen. The date library is based upon: • Date Algorithms by Howard Hinnant. • The date implementation in QuantLib. The following key types are defined: // This class provides a Period (length + TimeUnit) class // and implements a limited algebra. // Must be standard layout for C compatibility class Period { public: // Construct a period from length and unit Period(int n, PeriodUnit unit) noexcept; // Default constructor : 0D period Period() noexcept; int length() const noexcept; PeriodUnit units() const noexcept; (continues on next page) 4 Chapter 2. OpenRedukti C++ API OpenRedukti Documentation (continued from previous page) bool operator==(const Period&p) const noexcept; // Normalisation converts weeks to days and // years to months Period normalised() const noexcept; // Converts a tenor to period representation // Must be updated if definition of Tenor changes. static Period tenor_to_period(Tenor tenor); }; enum Weekday { Sunday=0, Monday=1, Tuesday=2, Wednesday=3, Thursday=4, Friday=5, Saturday=6, Sun=0, Mon=1, Tue=2, Wed=3, Thu=4, Fri=5, Sat=6 }; // Month names enum Month { January=1, February=2, March=3, April=4, May=5, June=6, July=7, August=8, September=9, October= 10, November= 11, December= 12, Jan=1,
Details
-
File Typepdf
-
Upload Time-
-
Content LanguagesEnglish
-
Upload UserAnonymous/Not logged-in
-
File Pages63 Page
-
File Size-