Domain Specific Language for Specifying Operations of a Central Counterparty 1 Chamin Nalinda, 2 Chamath Keppitiyagama University of Colombo School of Computing Colombo, Sri Lanka 1 chmk90@gmail.com 2 chamath@ucsc.cmb.ac.lk Abstract Domain Specific Language (DSL) approach empow- ers effectve financial contract management through fixed and precisely defined set of combinators and observables. Haskell Contract Combinator Library (HCCL) follows DSL approach and it offers a flexible mechanism in composing Financial Contracts(FCs). Financial institutes such as banks, use FCs. Central Counterparty(CCP) is one such financial institute and this institute is highly regulated one. Out of all operations, “Margin Calculation”(MC) operation in CCP, consider to be most significant operation. The process of MC involves series of rules to follow. For example, a rule could specify, transfer of money if certain condition met by a given date. All these rule specify a form of probable future cash flow. In the research literature, the DSL approach has not explored in the context of CCP rules. In our research, we analyzed a contract that goes through CCP operations and we modeled series of FCs using HCCL clearly showing the steps and cash flow semantics. In our research, we defined two new data types Instrument and Trade that embodies and preserve the properties of FCs. Through our research we proved the hypothesis that, HCCL could be use in defining CCP rules and as a result we could use HCCL in the process of MC. We introduced a ”seed” contract to simulate the contract behaviour in our design methodology. We further explored the HCCL defined CCP rules in the context of financial contract management. KeywordsFinancial Contracts, Central Counterparty, Func- tional Programming, Haskell, Haskell Contract Combinator Library, Domain Specific Language I. Introduction Financial Markets(FMs) are a key governing segment in todays world economy. FMs operations have mushroomed in diversifid ways at a swift pace. Earlier days, there operations were limited to very primitive operations, mainly in money withdrawals/deposits and clearance of checks. With the hap- hazard growth and the intense dynamic nature in economy, dif- ferent interested parties, who known as stakeholders, entered in to FMs. Stakeholders have different expectations from FMs. Vide variety of financial institutes are exists in FMs to surve these diversified interests of stakeholders. Stock Exchanges, Banks, Clearning Houses are such different financial intitutes that exists in FMs that serves different interests of stakehold- ers. Different types of FCs are traded in these financial institutes. Each contract has its unique contract definition and has unique rights and obligations that inherent to the contract. For exam- ple, Option contract definition and its rights and obligations are different from Futures contract definition and its rights and obligations. New FCs are continually emerging to meet the needs of FMs. For example, Credit Default Swap(CDS) and Power Reverse Dual Currency Swap(PRDC) two FCs that came very recently to the market. As this number grew, the necessity for having FM specific language in defining FCs was arosed. The objective was to effectively manage different types of FCs. This necessity was addressed through DSL approach. DSL uses a series of fixed and precisely defined set of combinators and observables in defining and valuating FCs. A. Motivation ”FCs can characterized by describing their cash flows” is the fundamental motive in researches to propell in fiding a DSL for finance sector. Today, from simple contract valuation to complex backend operations in FCs are carrying out using DSL. Simon Payton Jones is the pioneer researcher who introduced the DSL to FCs. In his research, he introduced fixed set of precisely defined combinators and obervables (Haskell Contract Combinator Library (HCCL), that can use in defining FCs and valueing FCs. Fig. 1: Motivation for DSL approach[3]. 1) Define Zero Coupon Bond (ZCB) contract using HCCL: (please refer the Table I and Table II to find the definitions for the given combinators of HCCL Contract Representation in HCCL ZCB(C1) to receive $100 on date t1 C1 = scaleK 100 (get ( truncate t1 ( one USD) ))) ZCB(C2) to transfer 200 on date t2 C2 = scaleK 200 (give ( truncate t2 ( one GBP) ))) Representation of ZCB in HCCL An important characteristic of HCCL is compositional nature of combinators and observables. The defined C1 and C2 can use in totally new contract, which is C3 as follows: