
1 2 OBJECT-ORIENTED IMPLEMENTATION OF OPTION PRICING VIA MATLAB: MONTE CARLO APPROACH A THESIS SUBMITTED TO THE GRADUATE SCHOOL OF APPLIED MATHEMATICS OF MIDDLE EAST TECHNICAL UNIVERSITY BY OZGE¨ TEKIN˙ IN PARTIAL FULFILLMENT OF THE REQUIREMENTS FOR THE DEGREE OF MASTER OF SCIENCE IN FINANCIAL MATHEMATICS JULY 2015 Approval of the thesis: OBJECT-ORIENTED IMPLEMENTATION OF OPTION PRICING VIA MATLAB: MONTE CARLO APPROACH submitted by OZGE¨ TEKIN˙ in partial fulfillment of the requirements for the de- gree of Master of Science in Department of Financial Mathematics, Middle East Technical University by, Prof. Dr. Bulent¨ Karasozen¨ Director, Graduate School of Applied Mathematics Assoc. Prof. Dr. Ali Devin Sezer Head of Department, Financial Mathematics Assoc. Prof. Dr. Om¨ ur¨ Ugur˘ Supervisor, Scientific Computing Assoc. Prof. Dr. Yeliz Yolcu Okur Co-supervisor, Financial Mathematics Examining Committee Members: Assoc. Prof. Dr. Om¨ ur¨ Ugur˘ Scientific Computing, METU Prof. Dr. Gerhard Wilhelm Weber Scientific Computing, METU Assoc. Prof. Dr. Umit¨ Aksoy Department of Mathematics, Atılım University Date: I hereby declare that all information in this document has been obtained and presented in accordance with academic rules and ethical conduct. I also declare that, as required by these rules and conduct, I have fully cited and referenced all material and results that are not original to this work. Name, Last Name: OZGE¨ TEKIN˙ Signature : v vi ABSTRACT OBJECT-ORIENTED IMPLEMENTATION OF OPTION PRICING VIA MATLAB: MONTE CARLO APPROACH Tekin, Ozge¨ M.S., Department of Financial Mathematics Supervisor : Assoc. Prof. Dr. Om¨ ur¨ Ugur˘ Co-Supervisor : Assoc. Prof. Dr. Yeliz Yolcu Okur July 2015, 69 pages There are many applications in finance and investment that require the use of methods, which involve time-consuming and laborious iterative calculations. Although closed- form solutions are available for some specific instruments, the valuation methods used in financial engineering in many other situations require analytical methods, which compute approximate solutions on computing environments. Option pricing is one of the most important and active topics in financial engineer- ing, and there are many fundamental methods for numerous different type options in literature as well as in the derivative market. Close investigation of options shows, be- sides the underlying parameters, significant relation and similarities, even inheritance, such as options on options. On the other hand, investigation of the valuation methods reveals the use of similar fundamental algorithms, such as Monte Carlo technique or solving the corresponding partial differential equation. Therefore, a software environment for pricing financial derivatives should be as flexible as possible to modify and extend the options as well as methods for pricing them. Object-oriented principles and modeling techniques, which contains analysis, design and implementation, have to be utilized for such a goal. After having analyzed options and pricing methods, the classes and subclasses to design a hierarchy that forms the structure of those options and methods are to be organized. As the relation between classes is so tight that each individual unit, objects, must be qualified to sending or vii receiving information to other objects while being responsible for their own work. Many modern object-oriented programming languages are transferable from one to another. Hence, MATLAB R is preferred in this study as it provides numerous built-in functions and is a very suitable platform to develop OOP based softwares. Keywords : Object-Oriented Programming, Monte Carlo Methods, Option Pricing viii OZ¨ OPSIYON˙ FIYATLANDIRMASININ˙ NESNE YONEL¨ IML˙ I˙ MATLAB UYGULAMASI: MONTE CARLO YONTEM¨ I˙ Tekin, Ozge¨ Yuksek¨ Lisans, Finansal Matematik Bol¨ um¨ u¨ Tez Yoneticisi¨ : Doc¸. Dr. Om¨ ur¨ Ugur˘ Ortak Tez Yoneticisi¨ : Doc¸. Dr. Yeliz Yolcu Okur Temmuz 2015, 69 sayfa Finans ve yatırım alanlarında zaman alan ve zorlu yinelemeli hesaplar ic¸eren yontem-¨ lerin kullanımını gerektiren birc¸ok uygulama vardır. Finans muhendisli¨ ginde˘ belirli turev¨ ur¨ unler¨ ic¸in kapalı-form c¸oz¨ umler¨ olmasına ragmen,˘ birc¸ok durumda hesaplama yontemleri¨ yaklas¸ık c¸oz¨ umleri¨ bilgisayar ortamında hesaplayan analitik yontemler¨ ge- rekmektedir. Opsiyon fiyatlama, finans muhendisli¨ gindeki˘ en onemli¨ ve aktif konulardan birisidir ve literaturde¨ c¸es¸itli opsiyonları fiyatlandırmak ic¸in birc¸ok temel yontem¨ bulunmak- tadır. Opsiyonlar ve baglı˘ oldukları parametreler yakından incelendiginde,˘ opsiyonlar uzerine¨ yazılan opsiyonlar gibi, oldukc¸a onemli¨ bagıntı˘ ve benzerlikler, hatta kalıtım ilis¸kisi gozlemlenir.¨ Bununla birlikte, fiyatlama yontemleri¨ incelendiginde˘ Monte Carlo teknigi˘ ve kars¸ılık gelen kısmi diferansiyel denklem c¸oz¨ um¨ u¨ gibi benzer temel algorit- maların kullanıldıgı˘ gor¨ ulm¨ us¸t¨ ur.¨ Bu sebeple, finansal turev¨ arac¸ları fiyatlandırmak ic¸in olus¸turulan yazılım ortamı, op- siyonları ve fiyatlama tekniklerini yeniden duzenlemek¨ ve genis¸letmek ic¸in mumk¨ un¨ oldugunca˘ esnek olmalıdır. Analiz, tasarım ve uygulama basamaklarını ic¸eren nesne yonelimli¨ ilkeler ve modelleme teknikleri bu amac¸ic¸in kullanılmaktadır. Opsiyon ve fiyatlama tekniklerini analiz ettikten sonra bu opsiyonların yapısını olus¸turan hiyerar- s¸iyi tasarlamak ic¸in sınıflar ve alt sınıflar organize edilmis¸tir. Sınıflar arasındaki ilis¸ki oldukc¸a sıkıdır ve her bagımsız˘ birim yani nesne kendi is¸leyis¸inden sorumluyken diger˘ ix nesnelerle bilgi alıs¸veris¸ini gerc¸ekles¸tirir. Birc¸ok nesne yonelimli¨ programlama dili birbirine don¨ us¸t¨ ur¨ ulebilir.¨ Sagladı˘ gı˘ hazır fonksiyonlar ve nesne yonelimli¨ program- lama ic¸in uygun olması sebebiyle bu c¸alıs¸mada MATLAB R programlama dili tercih edilmis¸tir. Anahtar Kelimeler : Nesne Yonelimli¨ Programlama, Monte Carlo Yontemi,¨ Opsiyon Fiyatlama x To my parents and my love Ulas¸ xi xii ACKNOWLEDGMENTS First of all, I would like to express my very great appreciation to my thesis supervisor Assoc. Prof. Dr. Om¨ ur¨ Ugur˘ and co-supervisor Assoc. Prof. Dr Yeliz Yolcu Okur for their patient guidance, encouragement and invaluable advices not only throughout the development and preparation of this thesis but also my graduate education so far. I would like to thank the members of my thesis committee, Prof. Dr. Gerhard Wilhelm Weber and Assoc. Prof. Dr. Umit¨ Aksoy for their valuable comments and insight. I deeply thank all members of the Institute of Applied Mathematics (IAM) for provid- ing a helpful and sincere environment. Additionally, my special thank goes to mem- bers of room S206, Cansu Evcin, Sinem Kozpınar, Nes¸e Oztop,¨ Ays¸e Sarıaydın, Ahmet Sınak, Meral S¸ims¸ek and Bus¸ra¨ Temoc¸in for their kindness, friendship and support. Finally, none of my studies would have been possible without the support of my beloved ones. I would like to express my gratefulness to my parents for their con- tinuous support, encouragement, endless love and understanding in all aspects of my life. Also, I would like to thank my significant other, Ulas¸, for his full support, encour- agement, patience and love. I have been extremely lucky to have them. xiii xiv TABLE OF CONTENTS ABSTRACT . vii OZ.........................................¨ ix ACKNOWLEDGMENTS . xiii TABLE OF CONTENTS . xv LIST OF FIGURES . xix LIST OF TABLES . xxi LIST OF ABBREVIATIONS . xxiii CHAPTERS 1 INTRODUCTION . .1 1.1 Aim of the Thesis . .1 1.2 Literature Review . .1 1.3 Structure of the Thesis . .3 2 PRELIMINARIES . .5 2.1 Options . .5 2.1.1 Plain-Vanilla Options . .6 2.1.2 Barrier Options . .7 2.2 Option Strategies . .9 2.3 Stochastic Differential Equations with Jumps . 10 xv 2.3.1 Stochastic Differential Equations and Itoˆ Process . 11 2.3.2 Black Scholes Framework . 13 2.3.3 Pure Jump Processes . 17 2.3.3.1 Poisson Process . 17 2.3.3.2 Compound Poisson Process . 18 2.3.3.3 Compensated Poisson and Compensated Compound Poisson Processes . 19 2.3.4 Jump Diffusion Models . 21 2.4 Monte Carlo Approach . 23 2.4.1 Crude Monte Carlo Approach . 23 2.4.2 Implementation of Monte Carlo Approach to Euro- pean Option Pricing . 24 2.4.2.1 Numerical Solution . 25 3 OBJECT-ORIENTED PROGRAMMING . 27 3.1 What is the OOP? . 27 3.1.1 Class and Object . 28 3.2 Concepts of the OOP . 29 3.2.1 Abstraction . 29 3.2.2 Encapsulation . 29 3.2.3 Inheritance . 30 3.2.4 Polymorphism . 31 3.3 The Unified Modeling Language (UML) . 32 4 DESIGN AND IMPLEMENTATION OF OOMCOP . 37 4.1 OOP in MATLAB R ...................... 37 xvi 4.2 Structure of the Program . 39 4.2.1 Payoff Class . 40 4.2.2 PureJumpProcess Class . 46 4.2.3 Asset Class . 48 4.2.4 Derivative and Option Classes . 50 4.2.5 Pricer Class . 53 4.2.6 Relation Between Classes . 54 4.3 Graphical User Interface (GUI) . 54 5 CONCLUSION AND FUTURE WORK . 57 REFERENCES . 59 APPENDICES A UML Diagram of the Software . 63 B Test Scripts . 65 C Possible Extension to the Software . 69 xvii xviii LIST OF FIGURES Figure 2.1 Payoff diagrams for call and put options . .7 Figure 2.2 Simulation results of asset paths for down-and-out call option . .9 Figure 2.3 Payoff diagrams of straddle, strangle and butterfly spread . 10 Figure 2.4 Paths of Wiener process . 12 Figure 2.5 Paths of Poisson process with intensity λ = 1 ............ 18 Figure 2.6 Paths of compound Poisson process with intensity λ = 1;Yi ∼ N(1; 2) 19 Figure 2.7 Paths of compensated Poisson process with intensity λ = 1 .... 20 Figure 2.8 Paths of compensated compound Poisson process with intensity λ = 1;Yi ∼ N(1; 2) ............................... 21 Figure 2.9 Paths of Merton jump diffusion process . 23 Figure 2.10 Simulation results of GBM . 26 Figure 3.1 Languages, paradigms and concepts [52] . 27 Figure 3.2 Financial derivatives class and its subclasses . 29 Figure 3.3 Encapsulation concept in MATLAB R ................ 30 Figure 3.4 Single, multilevel and multiple inheritance . 31 Figure 3.5 UML diagrams overview . 33 Figure 3.6 An example of UML class diagram .
Details
-
File Typepdf
-
Upload Time-
-
Content LanguagesEnglish
-
Upload UserAnonymous/Not logged-in
-
File Pages95 Page
-
File Size-