Options and Derivatives Programming in C Algorithms and Programming Techniques For The Financial Industry 1st Edition Carlos Oliveira (Auth.)
Options and Derivatives Programming in C Algorithms and Programming Techniques For The Financial Industry 1st Edition Carlos Oliveira (Auth.)
com
OR CLICK BUTTON
DOWNLOAD NOW
https://textbookfull.com/product/options-futures-and-other-
derivatives-eleventh-edition-rental-john-c-hull/
textboxfull.com
https://textbookfull.com/product/trading-and-pricing-financial-
derivatives-a-guide-to-futures-options-and-swaps-patrick-boyle/
textboxfull.com
Algorithms For Competitive Programming 1st Edition David
Esparza Alba
https://textbookfull.com/product/algorithms-for-competitive-
programming-1st-edition-david-esparza-alba/
textboxfull.com
https://textbookfull.com/product/problem-solving-in-data-structures-
algorithms-using-c-programming-interview-guide-1st-edition-hemant-
jain/
textboxfull.com
https://textbookfull.com/product/options-futures-and-other-
derivatives-tenth-edition-basu/
textboxfull.com
https://textbookfull.com/product/intermediate-c-programming-for-the-
pic-microcontroller-simplifying-embedded-programming-hubert-henry-
ward/
textboxfull.com
Options and
Derivatives
Programming
in C++
Algorithms and Programming
Techniques for the Financial Industry
—
Carlos Oliveira
Options and Derivatives
Programming in C++
Algorithms and Programming Techniques
for the Financial Industry
Carlos Oliveira
Options and Derivatives Programming in C++
Carlos Oliveira
Monmouth Junction, New Jersey
USA
ISBN-13 (pbk): 978-1-4842-1813-6 ISBN-13 (electronic): 978-1-4842-1814-3
DOI 10.1007/978-1-4842-1814-3
Library of Congress Control Number: 2016954432
Copyright © 2016 by Carlos Oliveira
This work is subject to copyright. All rights are reserved by the Publisher, whether the whole or part of the
material is concerned, specifically the rights of translation, reprinting, reuse of illustrations, recitation,
broadcasting, reproduction on microfilms or in any other physical way, and transmission or information
storage and retrieval, electronic adaptation, computer software, or by similar or dissimilar methodology now
known or hereafter developed.
Trademarked names, logos, and images may appear in this book. Rather than use a trademark symbol with
every occurrence of a trademarked name, logo, or image we use the names, logos, and images only in an
editorial fashion and to the benefit of the trademark owner, with no intention of infringement of the trademark.
The use in this publication of trade names, trademarks, service marks, and similar terms, even if they are
not identified as such, is not to be taken as an expression of opinion as to whether or not they are subject to
proprietary rights.
While the advice and information in this book are believed to be true and accurate at the date of publication,
neither the authors nor the editors nor the publisher can accept any legal responsibility for any errors or
omissions that may be made. The publisher makes no warranty, express or implied, with respect to the
material contained herein.
Managing Director: Welmoed Spahr
Lead Editor: Jonathan Gennick
Technical Reviewer: Don Reamey
Editorial Board: Steve Anglin, Pramila Balan, Laura Berendson, Aaron Black, Louise Corrigan,
Jonathan Gennick, Todd Green, Robert Hutchinson, Celestin Suresh John, Nikhil Karkal,
James Markham, Susan McDermott, Matthew Moodie, Natalie Pao, Gwenan Spearing
Coordinating Editor: Jill Balzano
Copy Editor: Kezia Endsley
Compositor: SPi Global
Indexer: SPi Global
Artist: SPi Global
Cover Designer: Anna Ishchenko
Distributed to the book trade worldwide by Springer Science+Business Media New York, 233 Spring Street,
6th Floor, New York, NY 10013. Phone 1-800-SPRINGER, fax (201) 348-4505, e-mail [email protected],
or visit www.springer.com. Apress Media, LLC is a California LLC and the sole member (owner) is Springer
Science + Business Media Finance Inc (SSBM Finance Inc). SSBM Finance Inc is a Delaware corporation.
For information on translations, please e-mail [email protected], or visit www.apress.com.
Apress and friends of ED books may be purchased in bulk for academic, corporate, or promotional use.
eBook versions and licenses are also available for most titles. For more information, reference our Special
Bulk Sales–eBook Licensing web page at www.apress.com/bulk-sales.
Any source code or other supplementary material referenced by the author in this text is available to readers
at www.apress.com. For detailed information about how to locate your book’s source code, go to
www.apress.com/source-code/.
Printed on acid-free paper
To my family, my real source of inspiration.
Contents at a Glance
v
Contents
Further References......................................................................................................... 18
Conclusion ...................................................................................................................... 18
■Chapter 2: Financial Derivatives.......................................................................... 19
Models for Derivative Pricing ......................................................................................... 19
Credit Default Swaps ............................................................................................................................ 21
Collateralized Debt Obligations............................................................................................................. 22
vii
■ CONTENTS
FX Derivatives ....................................................................................................................................... 23
Derivative Modeling Equations ............................................................................................................. 23
Numerical Models................................................................................................................................. 24
Binomial Trees ...................................................................................................................................... 24
Simulation Models ................................................................................................................................ 25
Using the STL ................................................................................................................. 26
Generating a Random Walk .................................................................................................................. 27
Complete Listing ................................................................................................................................... 29
Building and Testing ............................................................................................................................. 32
Further References......................................................................................................... 33
Conclusion ...................................................................................................................... 34
■Chapter 3: Basic Algorithms................................................................................ 35
Date and Time Handling ................................................................................................. 35
Date Operations .................................................................................................................................... 36
Complete Listings ................................................................................................................................. 39
A Compact Date Representation .................................................................................... 48
Complete Listings ................................................................................................................................. 49
Building and Testing ............................................................................................................................. 53
Conclusion ...................................................................................................................... 66
■Chapter 4: Object-Oriented Techniques ............................................................... 67
OO Programming Concepts ............................................................................................ 67
Encapsulation ....................................................................................................................................... 69
Inheritance............................................................................................................................................ 72
Polymorphism ....................................................................................................................................... 72
Polymorphism and Virtual Tables.......................................................................................................... 75
viii
■ CONTENTS
ix
■ CONTENTS
x
■ CONTENTS
xi
■ CONTENTS
xii
About the Author
Carlos Oliveira works in the area of quantitative finance, with more than
10 years of experience in creating scientific and financial models in C++.
During his career, Carlos has developed several large-scale applications for
financial companies such as Bloomberg L.P. and Incapital LLC. Oliveira
obtained a PhD in Operations Research and Systems Engineering from the
University of Florida, an MSc in Computer Science from UFC (Brazil), and
a BSc in Computer Science from UECE (Brazil). He has also performs
academic research in the field of combinatorial optimization, with
applications in diverse areas such as finance, telecommunications,
computational biology, and logistics. Oliveira has written more than
30 academic papers on optimization and authored three books, including
Practical C++ Financial Programming (Apress, 2015).
xiii
About the Technical Reviewer
xv
Introduction
On Wall Street, the use of algorithmic trading and other computational techniques has skyrocketed in the
last few years, as can be seen from the public interest in automated trading as well as the profits generated
by these strategies. This growing trend demonstrates the importance of using software to analyze and trade
markets in diverse areas of finance. One particular area that has been growing in importance during the last
decade is options and derivatives trading.
Initially used only as a niche investment strategy, derivatives have become one of the most common
instruments for investors in all areas. Likewise, the interest in automated trading and analysis of such
instruments has also increased considerably.
Along with scientists and economists, software engineers have also greatly contributed to the
development of advanced computational techniques using financial derivatives. Such techniques have been
used at banks, hedge funds, pension funds, and other financial institutions. In fact, every day new systems
are developed to give a trading advantage to the players in this industry.
This books attempts to provide the basic programming knowledge needed by C++ programmers
working with options and derivatives in the financial industry. This is a hands-on book for programmers
who want to learn how C++ is used to develop solutions for options and derivatives trading. In the book’s
chapters, you’ll explore the main algorithms and programming techniques used in the implementation of
systems and solutions for trading options and other derivatives.
Because of stringent performance characteristics, most of these trading systems are developed using
C++ as the main implementation language. This makes the topic of this book relevant to everyone interested
in programming skills used in the financial industry in general.
In Options and Derivatives Programming in C++, I cover the features of the language that are more
frequently used to write financial software for options and derivatives. These features include the STL,
templates, functional programming, and support for numerical libraries. New features introduced in the latest
updates of the C++ standard are also covered, including additional functional techniques such as lambda
functions, automatic type detection, custom literals, and improved initialization strategies for C++ objects.
I also provide how-to examples that cover the major tools and concepts used to build working solutions
for quantitative finance. The book teaches you how to employ advanced C++ concepts as well as the basic
building libraries used by modern C++ developers, such as the STL, Boost, and QuantLib. It also discusses
how to create correct and efficient applications, leveraging knowledge of object-oriented and template-
based programming. I assume only a basic knowledge of C and C++ and extensively use concepts already
mastered by developers who are fluent in these languages.
In the process of writing this book, I was also concerned with providing value for readers who are trying
to use their current programming knowledge in order to become proficient at the style of programming used
in large banks, hedge funds, and other investment institutions. Therefore, the topics covered in the book
are introduced in a logical and structured way. Even novice programmers will be able to absorb the most
important topics and competencies necessary to develop C++ for the problems occurring on the analysis of
options and other financial derivatives.
xvii
■ INTRODUCTION
Audience
This book is intended for readers who already have a working knowledge of programing in C, C++, or
another mainstream language. These are usually professionals or advanced students in computer science,
engineering, and mathematics, who have interest in learning about options and derivatives programming
using the C++ language, for personal or for professional reasons. The book is also directed at practitioners of
C++ programming in financial institutions, who would use the book as a ready-to-use reference of software
development algorithms and best practices for this important area of finance.
Many readers are interested in a book that would describe how modern C++ techniques are used to
solve practical problems arising when considering options on financial instruments and other derivatives.
Being a multi-paradigm language, C++ usage may be slightly different in each area, so the skills that are
useful for developing desktop applications, for example, are not necessarily the same ones used to write
high-performance software.
A large part of high-performance financial applications are written in C++, which means that
programmers who want to enter this lucrative market need to acquire a working knowledge of specific parts
of the language. This book attempts to give developers who want to develop their knowledge effectively this
choice, while learning one of the most sought-after and marketable skillsets for modern financial application
and high-performance software development.
This book is also targeted at students and new developers who have some experience with the C++
language and want to leverage that knowledge into financial software development. This book is written with
the goal of reaching readers who need a concise, algorithms-based strategy, providing basic information
through well-targeted examples and ready-to-use solutions. Readers will be able to directly apply the
concepts and sample code to some of the most common problems faced regarding the analysis of options
and derivative contracts.
xviii
■ INTRODUCTION
Book Contents
Here is a quick overview of the major topics covered in each chapter.
• Chapter 1: “Options Concepts.” An option is a standard financial contract that
derives its value from an underlying asset such as a stock. Options can be used to
pursue multiple economic objectives, such as hedging against variations on the
underlying asset, or speculating on the future price of a stock. Chapter 1 presents the
basic concepts of options, including their advantages and challenges. It also explains
how options can be modeled using C++. The main topics covered in this chapter are
as follows:
• Basic definitions of options
• An introduction to options strategies
• Describing options with Greeks
• Sample code for options handling
• Chapter 2: “Financial Derivatives.” A derivative is a general term for a contract
whose price is based on an underlying asset. In the previous decades, the financial
industry created and popularized a large number of derivatives. Pricing and trading
these derivatives is a large part of the work performed by trading desks throughout
the world. Derivatives have been created based on diverse assets such as foreign
currency, mortgage contracts, and credit default swaps. This chapter explores this
type of financial instrument and presents a few C++ techniques to model specific
derivatives. The main topics covered in this chapter are as follows:
• Credit default swaps
• Forex derivatives
• Interest rate derivatives
• Exotic derivatives
xix
■ INTRODUCTION
xx
■ INTRODUCTION
xxi
■ INTRODUCTION
• Chapter 10: “Algorithms for Numerical Analysis.” Equations are some of the building
blocks of financial algorithms for options and financial derivatives, and it is important
to be able to efficiently calculate the solution for such mathematical models. In
this chapter, you will see programming recipes for different methods of calculating
equation roots and integrating functions, along with explanations of how they work
and when they should be used. I also discuss numerical error and stability issues that
present a challenge for developers in the area of quantitative financial programming.
• Basic numerical algorithms
• Root-finding algorithms
• Integration algorithms
• Reducing errors in numeric algorithms
• Chapter 11: “Models Based on Differential Equations.” Differential equations are at
the heart of many techniques using in the analysis of derivatives. There are several
processes for solving and analyzing PDEs that can be implemented in C++. This
chapter presents programming recipes that cover aspects of PDE-based option
modeling and application in C++. Topics covered include the following:
• Basic techniques for differential equations
• Ordinary differential equations
• Partial difference equations
• Numerical algorithms for differential equations
• Chapter 12: “Basic Models for Options Pricing.” Options pricing is the task of
determining the fair value of a particular option, given a set of parameters that
exactly determine the option type. This chapter discusses some of the most popular
models for options pricing. They include tree-based methods, such as binomial
and trinomial trees. It also discusses the famous Black-Scholes model, which is
frequently used as the basis for the analysis of most options and derivative contracts.
• Binomial trees
• Trinomial trees
• Black-Scholes model
• Implementation strategies
• Chapter 13: “Monte Carlo Methods.” Among other programming techniques for equity
markets, Monte Carlo simulation has a special place due to its wide applicability and
easy implementation. These methods can be used to forecast prices or to validate
options buying strategies, for example. In This chapter provides programming recipes
that can be used as part of simulation-based algorithms applied to options pricing.
• Probability distributions
• Random number generation
• Stochastic models for options
• Random walks
• Improving performance
xxii
■ INTRODUCTION
• Chapter 14: “Using C++ Libraries for Finance.” Writing good financial code is not an
individual task. You frequently have to use libraries created by other developers and
integrate them into your own work. In the world of quantitative finance, a number of
C++ libraries have been used with great success. This chapter reviews some of these
libraries and explains how they can be integrated into your own derivative-based
applications. Some of the topics covered include the following:
• Standard library tools
• QuantLib
• Boost math
• Boost lambda
• Chapter 15: “Credit Derivatives.” Credit derivatives are an increasingly popular
type of financial derivative that aims at reducing credit risk—that is, the risk of
default posed by contracts established with a counterparty. Credit derivatives can
be modeled using some of the tools already discussed for options, although credit
derivative have their own peculiarities. This chapter describes how to create the C++
code needed to quantitatively analyze such financial contracts. Here are some of the
topics discussed:
• General concepts of credit derivatives
• Modeling the problem
• C++ algorithms for derivative pricing
• Improving algorithm efficiency
Example Code
The examples given in this book have all been tested on MacOS X using the Xcode 7 IDE. The code uses only
standard C++ techniques, so you should be able to build the given examples using any standards-compliant
C++ compiler that implements the C++11 standard. For example, gcc is available on most platforms, and
Microsoft Visual Studio will also work on Windows.
If you use MacOS X and don’t have Xcode installed in your computer yet, you can download it for free
from Apple’s developer web site at http://developer.apple.com.
If you instead prefer to use MinGW on Windows, you can download the MinGW distribution from the
web site http://www.mingw.org.
Once MinGW is installed, start the command prompt from the MinGW program group in the Start
menu. Then, you can type gcc to check that the compiler is properly installed.
To download the source code for all examples in this book, visit the web page of the author at
http://coliveira.net.
xxiii
CHAPTER 1
Options Concepts
In the last few decades, software development has become an integral part of the investment industry.
Advances in trading infrastructure, as well as the need for increased volume and liquidity, has caused
financial institutions to adopt computational techniques in their day-to-day operations. This means
that there are many opportunities for computer scientists specializing in the design and development of
automated strategies for trading and analyzing options and other financial derivatives.
Options are among the several investment vehicles that are currently traded using automated methods,
as you will learn in the following chapters. Given the mathematical structure of options and related
derivatives, it is possible to explore their features in a controlled way, which is ideal for the application of
computational algorithms. In this book, I present many of the computational techniques used to develop
strategies in order to trade options and other derivatives.
An option is a standard financial contract that derives its value from an underlying asset such as
common stock or commodities. Options can be used to pursue multiple economic objectives, such as
hedging against large variations on the underlying asset, or speculating on the future price of a stock. This
chapter presents the basic concepts of options, along with supporting definitions. I also give an overview of
the use of C++ in the financial industry, and how options can be modeled using C++.
The following concepts are explored in the next sections:
• Basic definitions: You will learn fundamental definitions about options contracts and
how they are used in the investment industry.
• Fundamental option strategies: Due to their flexibility, options can be combined in
a surprising large number of investment strategies. You will learn about some of the
most common option strategies, and how to model them using C++.
• Option Greeks: One of the advantages of options investing is that it promotes a very
analytical view of financial decisions. Each option is defined by a set of variables
called Greeks, which reflect the properties of an option contract at each moment in
time.
• Delta hedging: One of the ways to use options is to create a hedge for some other
underlying asset positions. This is called delta hedging, and it is widely used in the
financial industry. You will see how this investment technique works and how it can
be modeled using C++.
Basic Definitions
Let’s start with an overview of concepts and programming problems presented by options in the financial
industry. Options are specialized trading instruments, and therefore require their users to be familiar
with a number of details about their operation. In this section, I introduce some basic definitions about
options and their associated ideas. Before starting, take a quick look at Table 1-1 for a summary of the most
commonly used concepts. These concepts are defined in more detail in the remaining parts of this section.
Concept Definition
Call An option contract that gives its owner the right to buy the underlying asset for a
predetermined price.
Put An option contract that gives its owner the right to sell the underlying asset for a
predetermined price.
Underlying Asset whose price is used as the base of the options contract.
Strike price The price at which option owners can buy or sell the underlying asset under the
options contract.
Expiration The last date of the options contract.
Settlement The act of exercising the options contract at the expiration date.
Intrinsic value Amount of option value that is directly derived from the underlying price.
Break-even price The price at which an investor will start to make a profit in the option.
Exercise The act of buying of selling the option underlying under the price determined by the
option contract.
American option An option style where option owners can exercise the option at any moment between
option purchase and option expiration.
European option An option style where option owners can exercise the option only at expiration time.
ATM (At The Money): Refers to options that have a strike price close to the current price
for the underlying.
OTM (Out of The Money): Refers to options that have a strike price above (for calls) or
below (for puts) the current price of the underlying asset. These options have no
intrinsic value.
ITM (In The Money): Refers to options that have a strike price below (for calls) or above
(for puts) the current price of the underlying asset. These options have an intrinsic
value.
Options can be classified according to several criteria. The features of the options determine every
aspect of how they can be used, such as the quantity of underlying assets, the strike price, and the expiration,
among others. There are two main types of Options processing: calls and puts. A call is a standard contract
that gives its owner the right (but not the obligation) to buy an underlying instrument at a particular
price. Similarly, a put is standard contract that gives its owner the right (but not the obligation) to sell an
underlying instrument at a predetermined price.
2
CHAPTER 1 ■ OPTIONS CONCEPTS
The strike price is the price at which the option can be exercised. For example, a call for IBM stock with
strike $100 gives its owner the right to buy IBM stock at the price of $100. If the current price of IBM is greater
than $100, the owner of such an option has the right to buy the stock at a price that is lower than the current
price, which means that the call has a higher value as the value of IBM stock increases. This situation is
exemplified in Figure 1-1. If the current price is lower than $100 at expiration, the value of the option is zero,
since there is no profit in exercising the contract.
As you have seen in this example, if you buy an option, you have an unlimited gain and your losses are
limited to the value paid originally. This is advantageous when you’re trying to limit losses in a particular
investment scenario. As long as you are okay with losing a limited amount of money paid for the option,
you can profit from the unlimited upside potential of a call (if the underlying grows in price). Put options
don’t have unlimited profit potential since the maximum gain happens when the underlying price is zero.
However, they still benefit from the well-defined, limited loss versus the possible large gains.
Expiration: The expiration is the moment when the option contract ends its validity and a final value
exchange can be performed. Each option will have a particular, predefined expiration. For example, certain
index-based options expire in the morning of the third Friday of the month. Most stock-based options expire
in practice at the end of the third Friday of the month (although they will list the Saturday as the formal
expiration day). More recently, several weekly-based option contracts have been made available for some
of the most traded stocks and indices. Each options contract makes it clear when expiration is due, and
investors need to plan accordingly on what to do before the expiration date.
3
CHAPTER 1 ■ OPTIONS CONCEPTS
Settlement: The settlement is the agreed-on result of the option transaction at the specific time when
the option contract expires. The particular details of the settlement depend on the type of underlying asset.
For example, options on common stock settle at expiration day, when the owner of the option needs to
decide to sell (for puts) or buy (for calls) a certain quantity of stock. For index-based options, the settlement
is normally performed directly in cash, determined as the cash equivalent for a certain number of units of
the index. Some options on futures may require the settlement on the underlying commodity, such as grain,
oil, or sugar. Investors need to be aware of the requirement settlement for different option contracts. Trading
brokerages will typically let investors know about the steps required to settle the options they’re currently
holding.
Selling Options: An investor can buy or sell a call option. When doing so, it is important to understand
the difference between these two situations. For option buyers, the goal is to profit from the possible increase
(in the case of calls) or the decrease (in the case of puts) in value for the underlying. For option sellers, on
the other hand, the goal is to profit from the lack of movement (increase for calls or decrease for puts). So, for
example, if you sell calls against a stock, the intent is to profit in the case that the stock decreases in price or
stays at the same price until expiration. If you sell a put option, the goal is to profit when the stock increases
in price or stays at the same price until expiration.
Option exercise: An option contract can be used to buy or sell the underlying asset as dictated by
the contract specification. This process of using the option to trade the underlying asset is called option
exercising. If the option is a call, you can exercise it and buy the underlying asset at the specified price. If the
option is a put, you can use the option to sell the underlying asset at the previously specified price. The price
at which the option is exercised is defined by the contract. For example, a call option for AAPL stock with a
$100 strike allows its owner to buy the stock for the strike price, independent of the current price of AAPL.
Exercise style: Options contracts can have different exercise styles based on when exercising is allowed.
There are two main types:
• American options: Can be exercised at any time until expiration. That is, the owner
of the option can decide to exercise it at any moment, as long as the option has not
expired.
• European options: Can be exercised only upon expiration date. This style is more
common for contracts that are settled directly on cash, such as index-based options.
An option is defined as a derivative of an underlying instrument. The underlying instrument is the asset
whose price is used as the basic value for an option contract. There is no fixed restriction on the type of
asset used and the underlying asset for an option contract, but in practice options tend to be defined based
on openly traded securities. Examples of securities that can be used as the underlying asset for commonly
traded option contracts include the following:
• Common stock: Probably the most common way to use options is to trade call or
put options on common stock. In this way, you can profit largely from small price
changes in stocks of public companies.
• Indices: An index, such as the Dow Industrials or the NASDAQ 100, can be used as
the underlying for an options contract. Options based on indices are traditionally
settled on cash (as explained below), and each unit of value corresponds to multiples
of the current index value.
• Currencies: A currency, usually traded using Forex platforms, can also be used as the
underlying for option contracts. Common currencies such as the U.S. Dollar, Euro,
Japanese Yen, and Swiss Franc are traded 24 hours a day. The related options are
traded on lots of currencies, which are defined according to the relative prices of the
target currencies. Expiration varies similarly to stock options.
4
CHAPTER 1 ■ OPTIONS CONCEPTS
5
CHAPTER 1 ■ OPTIONS CONCEPTS
The break-even price is the price of the underlying at which the owner of an option will start to make a
profit. The break-even price has to include not only the potential profit derived from the intrinsic value, but
also the cost paid for the option. Therefore, for an investor to make a profit on a call option, the price of the
underlying asset has to rise above the strike plus any cost paid for the option (and similarly it has to drop
below the strike minus the option cost for put options). For example, if an $100 MSFT call option has a cost
of $1, then the investor will have a net profit only when the price of MSFT rises above $101 (and this without
considering transaction costs).
As part of the larger picture of investing, options have assumed an important role due to their flexibility
and their profit potential. As a result, new programming problems introduced by the use of options have
come to the forefront of the investment industry, including banks, hedge funds, and other financial
institutions. As you will see in the next section, C++ is the ideal language to create efficient and elegant
solutions to the programming problems occurring with options investing.
Option Greeks
One of the characteristics of derivatives is the determination of quantitative measures that can be essential
in the analysis and pricing of the derivative product. In the case of options, the quantitative measures are
called Greeks, because most of these measures are named after Greek letters. Many of these Greek quantities
correspond to the variation of the price with respect to one or more variables, such as time, strike, or
underlying price.
The most well known option Greek is delta. The delta of an option is defined as the amount of change in
the price of an option when the underlying changes by one unit. Therefore, delta represents a rate of change
of the option in relation to the change in the underlying, and it is essential to understand price variation in
options. Consider, for example, an option for IBM stock that expires in 30 days. The strike price is $100, and
the stock is currently trading at $100. Suppose that the price of the stock increases by $1. It is interesting to
calculate the expected change in the option price. It turns out that when the underlying price is close to the
strike price, the delta of an option is close to 0.5. Expressing this in terms of probabilities, it means the value
of the stock is equality probable to go up or down. Therefore, it makes sense that the change per unit of price
will be just half of the change in the underlying asset.
The value of delta increases as the option becomes more and more in the money. In that case, the delta
gets close to one, since each dollar of change will have a larger impact in the intrinsic value of the option.
Conversely, the value of delta decreases as the option becomes more and more out of the money. In that
case, delta gets closer to zero, since each dollar of change will have less impact on the value of an option that
is out of the money.
The second option Greek that is related to delta is gamma. The gamma of an option is described as
the rate of change of delta with a unit change in price of the underlying. As you have seen, delta changes in
different ways when the option is in the money, out of the money, or at the money. But the rate of change
of delta will also vary depending on other factors. For example, delta will change more quickly if the option
is close to expiration, because there is so little time for a movement to happen. To see why this happen,
consider an option delta 30 days before expiration and one that is one day before expiration. Delta is also
dependent on time, because an option close to expiration has less probability of change. As a result, the
delta will move from zero to one slowly if there are 30 days to go, because there is still plenty of time left
for other changes. But an option with only one day left will quickly move from close to zero delta to near
one, since there is no time left for future changes. This is described by saying that the first option has lower
gamma than the second option. Other factors such as volatility can also change an option gamma. Figure 1-2
illustrates the value of gamma for a particular option at different times before expiration.
6
CHAPTER 1 ■ OPTIONS CONCEPTS
Another option Greek that is closely related to time is theta. The theta of an option is proportional to the
time left to expiration, and its value decays when it gets closer to the expiration date. You can think of theta
as a measure of time potential for the option. For option buyers, higher theta is a desirable feature, since
buyers want more probability of changes for their options. On the other hand, option sellers benefit from
decreased theta, so short-term options are ideal for sellers due to the lower theta.
Finally, we have an option Greek that is not really named after a Greek letter: vega. The vega of an
option measures the amount of volatility of the underlying asset that is priced into an option. The higher the
volatility, the more expensive an option has to be in order to account for the increased possibility of pricing
changes. The differential equations that define the price of an option (as you will see in future chapters)
take into account this volatility. Vega can be used to determine how much relative volatility is embedded in
the option price, and an important use of this measure is to help option buyers and sellers determine if this
implied volatility is consistent with their expectations for the future of the underlying prices.
There are other option Greeks that have been used in the academic community and in some financial
application; however, they are not as widespread as the ones mentioned here. You can see a summary of the
most commonly used option Greeks in Table 1-2.
7
CHAPTER 1 ■ OPTIONS CONCEPTS
Greek Meaning
Delta The rate of change of the option value with respect to the price of the underlying asset.
Gamma The rate of change of delta with respect to the price of the underlying asset.
Rho The change of the price of the option with respect to changes in interest rates.
Theta The rate of change in the option value with respect to time left to expiration.
Vega The rate of change of the option value with respect to the volatility of the underlying asset.
Lambda The rate of change in the option value with respect to percent changes in the price of the
underlying asset.
Availability
When looking for a programming language to implement investment software, one of the first concerns
you need to address is the ability to run the code in a variety of computational environments. Targets for
such investment software can range from small and mobile processors to large-scale parallel systems
and supercomputers. Moreover, it is not uncommon to have to interact with different operating systems,
including the common software platforms based on Linux, Windows, and MacOS X.
Because modern computer systems are so heterogeneous, it makes economic sense to use languages
that can be employed in a large variety of hardware and software configurations with little or no source
code modifications. Financial programmers also work on different platforms, which makes it even more
interesting to use software that can run in different computers and operating systems with little or no
changes.
A strong characteristic of C++ is its wide availability over different platforms. Due to its early success
as a multi-paradigm language, C++ has been ported to nearly any imaginable software and hardware
combination. While other mainstream languages such as Java require the implementation of a complex
runtime environment for proper operation, C++ was designed from the beginning with simplicity and
portability in mind. The language does not require a runtime system, and only a minimal support system,
provided by the C++ standard library, needs to work in order to support a new target. Therefore, it is
relatively easy to port C++ compilers and build systems to new platforms with minimal changes.
Another advantage is the availability of multiple compilers provided by commercial vendors as well as
free software. Given the importance of C++ software, it is possible to find compilers with both free and under
commercial licenses, so that you can use the scheme that best suits your objectives. Open source developers
can use state-of-the-art free compilers such as gcc and LLVM cc. Commercial groups, on the other hand, can
take advantage of compilers licensed by companies such as Intel and IBM.
8
CHAPTER 1 ■ OPTIONS CONCEPTS
Performance
It is fact that programmers using C++ benefit from the high performance provided by the language. Because
C++ was explicitly designed to require a minimum amount of overhead in most platforms, typical C++
programs run very efficiently, even without further optimization steps. Programs naturally coded in C++ will
frequently outperform code created in other languages, even when this software has been heavily optimized.
Part of the performance advantage provided by C++ is a result of mature compilers and other building
tools. Since C++ is such a well-established language, major companies as well as well-known open source
projects have created optimized compilers for the language. Common examples include gcc, Visual C++,
LLVM cc, and Intel cc. Such compilers provide huge speed improvements in typical running time, frequently
beating non-optimized (and even optimized) code that is produced by other languages.
When considering performance, C++ shares the same philosophy of the C programming language.
The general idea is to provide high-level features, while avoiding whenever possible any overhead on the
implementation of such features on common processors. This means that the features provided by C++
generally match very closely with low-level processor instructions.
Other solutions for improved performance in C++ include the use of templates in addition to runtime
polymorphism. With templates, the compiler can generate code that matches the types used in a particular
algorithm exactly. In this way, programs can avoid the large overhead of polymorphic code, which need to
made different runtime decisions depending on the particular type. Programmers can control algorithms in
a much finer grained scale when using templates, while still retaining the ability to use high-level types.
Last but not least, C++ simplifies the use of memory and other resources with the help of smart pointers
and other techniques based on RAII (Resource Acquisition Is Initialization). These techniques allow C++
programs to control memory usage without having to rely on a runtime GC (garbage collection) system. By
using such strategies, C++ programmers can considerably reduce the overhead of frequently used dynamic
algorithms, without the need to resort to manual bookkeeping of memory and other resources.
Standardization
Another great advantage of C++ is that it’s based on an international standard, which is recognized
by practically every software vendor. Unlike some languages that are practically defined by an actual
implementation or controlled by a powerful company, C++ has for decades being defined as the result of the
C++ committee, with representatives from major companies and organizations that have an interest in the
future development of the language.
In fact, some of the big financial companies also have representatives in the C++ committee. This
means that the future of C++ is not controlled by a single institution, such as what happens with Java
(controlled by Oracle), C# (controlled by Microsoft), or Objective-C and Swift (controlled by Apple). The fact
that the standards committee has members from several organizations protects its users from commercial
manipulation that would benefit a single company, to the detriment of the larger community of users.
The C++ standards committee has been effective in improving the language in ways that address many
of the modern needs of programmers. For example, the last two version of the language standard (C++11
and C++14) introduced many changes that simplify common aspects of programming, such as simpler
initialization methods, more advanced type detection, and generalized control structures.
The standard library has also been the target of many improvements over the last few years. A main
focus has been the introduction of containers and smart pointers, which can be used to simplify a large part
of modern applications. The standard library also has been augmented to support parallel and multithreaded
algorithms, using primitives that can be reused on different operating systems and architectures.
It is necessary to remember that the standardization process has a few drawbacks too. One of the issues
is the time it takes to introduce new features. Since the standardization process requires a lot of organization
and formal meetings, it takes several years before a new version of the standard is approved. Also, there
is the risk of including features that go against the previous design of the language. In this case, however,
the committee has been very careful in introducing only features that have been thoroughly tested and
considered to improve the language according to its philosophy.
9
Another Random Scribd Document
with Unrelated Content
ils eurent recours aux prières, et obtinrent encore la paix. Constance
retourna à Milan; et Julien après une campagne qui donna de
l'expérience à ce prince, du courage à ses troupes, et de grandes
espérances aux Gaulois, alla passer l'hiver à Sens [Senones].
[86] Ces peuples sont encore nommés par les auteurs latins
Vithungi.—S.-M.
[87] On voit, par les lois du Code Théodosien, que Constance
était à Milan le 11 avril et le 29 octobre 356; c'est donc dans cet
intervalle de temps qu'il fit la guerre aux Allemans.—S.-M.
[88] Le récit d'Ammien Marcellin, montre qu'il passa par la ville de
Trèves (Treviri), pour faire cette expédition.—S.-M.
Ce ne fut pas pour lui un temps de repos. Il n'avait
pas affaire à des ennemis rassemblés en un corps, An 357.
qui fixassent toutes ses vues sur un seul objet.
C'étaient des essaims de Barbares, tantôt séparés,
tantôt réunis, qu'il était difficile de vaincre, difficile xxii.
même d'atteindre, les uns en-deçà du Rhin, les
autres au-delà, mais toujours prêts à franchir cette Julien assiégé à
Sens.
barrière, et qui partageaient son esprit en autant de
soins, qu'ils occupaient de territoires, et que le Rhin Amm. l. 16, c. 3,
offrait de passages. Il s'agissait d'écarter tous ces 4.
nuages, de ramener dans les postes exposés les Jul. ad Ath. p.
garnisons que la terreur avait dispersées, de 278, ed. Spanh.
pourvoir dans des pays ruinés aux subsistances
d'une armée toujours en mouvement, et dont les marches ne
pouvaient être réglées que sur les courses imprévues des ennemis.
Il venait d'être associé pour la seconde fois à Constance dans le
consulat. Pendant qu'il prenait des mesures pour la campagne
prochaine, une multitude de Barbares vint l'assiéger dans la ville de
Sens. Ils se flattaient d'autant plus de réussir, qu'ils savaient que le
manque de vivres l'avait obligé de séparer une partie de ses
meilleurs corps, et de les distribuer en divers quartiers. Julien fit
fortifier les endroits faibles de la ville; toujours la cuirasse sur le dos,
il se montrait jour et nuit sur les remparts; il brûlait d'impatience d'en
venir aux mains, mais il était retenu par la considération du petit
nombre de ses troupes. Enfin après trente jours de siége, les
Barbares aussi peu constants dans l'exécution que prompts à
entreprendre, perdirent courage et se retirèrent.
Marcellus, quoiqu'il ne fût pas éloigné de Julien, ne
s'était pas mis en peine de le secourir dans un péril xxiii. Disgrace
si pressant. Il avait cru sans doute suivre les de Marcellus.
intentions de Constance. Mais il est dangereux de se
[Julian. ad
prêter aux vues de l'injustice: comme elle dégrade Athen. p. 278,
ceux qui la servent, elle en prend droit de les ed. Spanh.]
mépriser; et souvent pour se disculper, elle se fait Amm. l. 16, c. 4,
honneur de les punir. D'ailleurs Constance voulait 7, et 8.
tenir Julien dans l'abaissement, mais il ne voulait pas
le perdre. La conduite du général excitait les
murmures; l'empereur le sacrifia sans regret à la haine publique: il lui
ôta le commandement, et lui donna ordre de se retirer sur ses terres.
Marcellus prit cependant le parti de venir à la cour, dans l'espérance
de se justifier en chargeant Julien: il comptait sur la faveur que la
calomnie trouvait auprès du prince. Mais le César se doutant de son
dessein, fit partir en même temps son chambellan Euthérius, et lui
confia le soin de le défendre. Marcellus qui ne savait rien de cette
précaution, arrive à Milan, et se plaint hautement de sa disgrace: il
était impétueux et fanfaron. Il se fait introduire au conseil; il déclame
contre Julien avec beaucoup de chaleur: c'était, disait-il, un jeune
téméraire, un ambitieux qui prenait l'essor au point de ne plus
reconnaitre de supérieur. Après une invective fort animée à laquelle
il n'attendait pas de réponse, il est surpris de voir paraître Euthérius,
qui de sang-froid et d'un ton modeste réfute en peu de mots tous ses
mensonges, développe ses indignes manœuvres, rend un compte
exact de ce qui s'est passé au siége de Sens, et répond sur sa tête
de la fidélité inviolable de son maître. Marcellus confondu se retira à
Sardique sa patrie. Le vertueux Euthérius soutenait à la cour de
Julien le rôle qu'il avait fait inutilement dans celle de Constant.
Sobre, uniforme dans sa conduite, à l'épreuve de tout intérêt, fidèle
et d'un secret impénétrable, il ne profitait de sa faveur que pour
inspirer les mêmes vertus au jeune prince. Il s'efforçait de corriger
par ses sages conseils ce que l'éducation asiatique avait laissé de
léger et de frivole dans le caractère de Julien. Aussi ce rare
courtisan eut-il un bonheur presque inconnu aux favoris: sa
considération survécut à son maître; il ne fut pas obligé dans sa
vieillesse d'aller cacher dans une retraite voluptueuse des richesses
odieuses et injustement acquises. Il passa ses dernières années à
Rome, jouissant du repos d'une bonne conscience, chéri et honoré
de tous les ordres de l'état.
La Gaule commençait à respirer; mais les défiances
perpétuelles de Constance rendaient sa cour un xxiv. Etat de la
séjour moins assuré que la Gaule. Les délateurs, cour de
plus dangereux que les Barbares, étaient Constance.
secrètement excités par les favoris qui profitaient Amm. l. 13, c. 6
des confiscations. Rufin préfet du prétoire, Arbétion et 8.
général de la cavalerie, l'eunuque Eusèbe et Cod. Th. lib. 9,
plusieurs autres s'enrichissaient de condamnations. tit. 16, leg. 4, 5,
Tout était crime de lèse-majesté: la sottise même et 6.
la superstition devenaient un attentat contre le
prince; et s'il en faut croire Ammien, ce fut moins par zèle pour la
religion chrétienne, que par l'effet d'une crainte pusillanime, que
Constance fit en ce temps là plusieurs lois qui condamnaient à mort
et les devins et ceux qui les consultaient. Un autre Rufin, ce chef des
officiers de la préfecture, qui avait gagné les bonnes graces du
prince en accusant Africanus, ayant corrompu la femme d'un certain
Danus, habitant de la Dalmatie, l'engagea à prendre la voie la moins
périlleuse pour se défaire de son mari: c'était de l'accuser d'une
conspiration contre l'empereur. Selon les instructions de ce fourbe,
elle supposa que Danus aidé de plusieurs complices avait dérobé le
manteau de pourpre renfermé dans le tombeau de Dioclétien. Rufin
accourt à Milan pour déférer ce forfait à l'empereur. Heureusement
pour l'innocence, Constance chargea cette fois de l'information deux
hommes incorruptibles; c'étaient Lollianus[89] préfet du prétoire
d'Italie, et Ursulus surintendant des finances[90]. Ils se transportent
sur les lieux; l'affaire est traitée à la rigueur; on met à la question les
accusés. Leur constance à nier le crime embarrassait les
commissaires; enfin la vérité éclata: la femme pressée elle-même
par les tourments avoua son intrigue avec Rufin; ils furent tous deux
condamnés à mort, comme ils ne l'avaient que trop méritée. Mais
Constance, irrité d'avoir perdu dans Rufin un zélé serviteur, envoie
en diligence à Ursulus une lettre menaçante, avec ordre de se
rendre à la cour. Ursulus, malgré ses amis qui tremblaient pour lui,
vient hardiment, se présente au conseil, rend compte de sa conduite
et de celle de Lollianus avec tant de fermeté, qu'il impose silence
aux flatteurs, et force l'empereur d'étouffer son injuste ressentiment.
Les innocents ne furent pas tous aussi heureux que Danus. Une
maison fort riche fut ruinée dans l'Aquitaine, parce qu'un délateur
invité à un repas, ayant aperçu sur la table et sur les lits qui
l'environnaient quelques morceaux de pourpre, prétendit qu'ils
faisaient partie d'une robe impériale; il s'en saisit, les alla présenter
aux juges, qui ordonnèrent une recherche exacte pour découvrir où
pouvait être le reste de la robe. On ne trouva rien, mais la maison fut
pillée. Il y avait en Espagne une coutume singulière dans les festins:
au déclin du jour, quand les valets apportaient les lumières, ils
disaient à haute voix aux convives: Vivons, il faut mourir. Un agent
du prince qui avait assisté à un de ces repas, fit un crime de ce qui
n'était qu'un usage; il sut si bien envenimer ces paroles, qu'il y
trouva de quoi perdre une honnête famille. Arbétion, l'un des
principaux auteurs de ces calomnies, se vit lui-même sur le point de
succomber. On employa contre lui ses propres artifices. Le comte
Vérissimus l'accusa de porter ses vues jusqu'à l'empire, et de s'être
fait faire d'avance les ornements impériaux. Dorus, dont nous avons
déja parlé, se mit de la partie. On commença l'instruction du procès;
on s'assura des amis d'Arbétion: le public attendait avec impatience
la conviction de ce personnage odieux. Mais la sollicitation des
chambellans du prince arrêta tout à coup la procédure; on mit en
liberté ceux qui étaient détenus pour cette affaire: Dorus disparut, et
Vérissimus demeura muet, comme s'il eût oublié son rôle.
[89] Cet officier est appelé Mavortius par Ammien Marcellin, l. 16,
c. 8. Il portait indifféremment ces deux noms. En l'an 352, il avait
été consul avec Arbétion; et en 355, il avait exercé la charge de
préfet de Rome.—S.-M.
[90] Comes largitionum.—S.-M.
L'impératrice Eusébia avait fait un voyage à Rome
l'année précédente, pendant l'expédition de xxv. Constance
Constance en Rhétie. Elle y avait été reçue avec vient à Rome.
magnificence; le sénat était sorti au-devant d'elle. La Jul. or. 3, p.
princesse avait de son côté récompensé par de 129.
grandes largesses l'empressement des habitants. Amm. l. 16, c.
Constance voulut aller à son tour recevoir les 10.
hommages de l'ancienne capitale de l'empire. Son Idat. chron.
dessein était d'y entrer en triomphe pour la victoire Till. not. 39.
qu'il avait remportée sur Magnence. Cette vanité
n'avait point d'exemple chez les anciens Romains,
qui ne voyaient dans les guerres civiles qu'un sujet de larmes, et non
pas une matière de triomphe. Après avoir ordonné tout l'appareil
capable d'éblouir les yeux par la pompe la plus brillante, il prit la
route d'Ocricoli [Ocriculum], escorté de toutes les troupes de sa
maison qui marchaient en ordre de bataille; repaissant de sa gloire
les regards de ceux qui accouraient sur son passage, et se
repaissant lui-même de leurs applaudissements. A son approche de
Rome[91], le sénat étant allé à sa rencontre, le prince enivré de
pompeuses idées s'imaginait voir ces anciens sénateurs supérieurs
aux rois, mais dont ceux-ci n'étaient plus que l'ombre; et cette
immense multitude qui sortait à grands flots des portes de Rome,
semblait lui annoncer tout l'univers rassemblé pour l'admirer.
Précédé d'une partie de sa maison et des enseignes de pourpre qui
flottaient au gré des vents, il entra assis seul sur un char rayonnant
d'or et de pierreries: à droite et à gauche marchaient plusieurs files
de soldats, couverts d'armes éclatantes; chaque bande était séparée
par des escadrons de cavaliers tout revêtus de lames d'un acier poli
et luisant. L'empereur, au milieu des cris de joie qui se mêlaient au
son des trompettes, gardait une contenance roide et immobile; il ne
tournait la tête d'aucun côté; on remarqua seulement qu'il la baissait
au passage des portes, quoiqu'elles fussent fort élevées, et qu'il fût
de fort petite taille: d'ailleurs il n'avait d'autre mouvement que celui
de son char. C'était une gravité de maintien qu'il affecta toute sa vie.
Jaloux de sa dignité, il l'attachait toute entière à la fierté de
l'extérieur: jamais il ne fit monter personne avec lui dans son char;
jamais il ne partagea l'honneur du consulat avec aucun particulier. Il
fut reçu dans le palais des empereurs au bruit des acclamations d'un
peuple innombrable; et sa vanité ne fut jamais plus agréablement
flattée.
[91] Constance entra dans Rome le 28 avril 357.—S.-M.
Pendant un mois qu'il resta dans cette ville fameuse,
elle fut pour lui un spectacle toujours ravissant. xxvi. Il en
Chaque objet ne lui laissait rien attendre de plus admire les
beau, et son admiration ne s'épuisa jamais. Il vit édifices.
cette place digne par sa magnificence d'avoir servi Amm. l. 16, c.
de lieu d'assemblée à un peuple, juge souverain des 10.
rois et des empires; le temple de Jupiter Capitolin, le
plus superbe séjour de l'idolâtrie; ces thermes, qui semblaient autant
de vastes palais; l'amphithéâtre de Vespasien, d'une élévation
surprenante, et dont la solidité promettait encore un grand nombre
de siècles; le Panthéon; les colonnes qui portaient les statues
colossales de ses prédécesseurs; le théâtre de Pompée; l'Odéon; le
grand cirque, et les autres monuments de cette ville qu'on appelait la
ville éternelle. Mais quand on l'eut conduit à la place de Trajan, et
qu'il se vit environné de tout ce que l'architecture avait pu imaginer
de plus noble et de plus sublime, ce fut alors que, confondu et
comme anéanti au milieu de tant de grandeur, il avoua qu'il ne
pouvait se flatter de faire jamais rien de pareil: Mais je pourrais bien,
ajouta-t-il, faire exécuter une statue équestre semblable à celle de
Trajan, et j'ai dessein de le tenter. Sur quoi Hormisdas[92], qui se
trouvait à ses côtés, lui dit: Prince, pour loger un cheval tel que celui-
là, songez auparavant à lui bâtir une aussi belle écurie. Comme on
demandait au même Hormisdas ce qu'il pensait de Rome: Il n'y a,
dit-il, qu'une chose qui m'en déplaise[93]; c'est que j'ai ouï dire qu'on
y meurt comme dans le moindre village.
[92] Frère du roi de Perse Sapor, qui s'était retiré chez les
Romains. Voyez ce qui a été dit à son sujet, l. iv, § 1, 2 et 3.—S.-
M.
[93] On trouve dans le texte d'Ammien Marcellin, Id tantum sibi
placuisse aiebat, quod didicisset ibi quoque homines mori. Au lieu
de placuisse, une note placée à la marge du manuscrit porte
displicuisse.—S.-M.
Our website is not just a platform for buying books, but a bridge
connecting readers to the timeless values of culture and wisdom. With
an elegant, user-friendly interface and an intelligent search system,
we are committed to providing a quick and convenient shopping
experience. Additionally, our special promotions and home delivery
services ensure that you save time and fully enjoy the joy of reading.
textbookfull.com