Skip to main content

2023 | Buch

Computational Finance with R

insite
SUCHEN

Über dieses Buch

This book prepares students to execute the quantitative and computational needs of the finance industry. The quantitative methods are explained in detail with examples from real financial problems like option pricing, risk management, portfolio selection, etc. Codes are provided in R programming language to execute the methods. Tables and figures, often with real data, illustrate the codes. References to related work are intended to aid the reader to pursue areas of specific interest in further detail. The comprehensive background with economic, statistical, mathematical, and computational theory strengthens the understanding. The coverage is broad, and linkages between different sections are explained. The primary audience is graduate students, while it should also be accessible to advanced undergraduates. Practitioners working in the finance industry will also benefit.

Inhaltsverzeichnis

Frontmatter

Numerical Methods

Frontmatter
Chapter 1. Preliminaries
Abstract
We start with some preliminaries in computation to introduce the reader to the basic concepts and ideas. The first distinction between theoretical derivations and computation is that in the latter we are seeking a specific numerical solution as opposed to proof of existence. For that purpose we need to have a set of clear instructions that can be followed step by step to arrive at a solution, often an approximate one. Such a set of instructions is called algorithm. The following is an example of an algorithm. Suppose we want to find the median of a set of n numbers, we use the following algorithm. Sort the numbers in order of magnitude. Check if n is odd or even. If n is odd, median is the value at the \((n+1)/2\)-th position. If n is even, median is the average of the values at the n/2-th and \(n/2+1\)-th positions.
Rituparna Sen, Sourish Das
Chapter 2. Vectors and Matrices
Abstract
In financial analysis we are often dealing with multiple securities, like stocks, bonds, options, etc. There are also multiple market scenarios to consider like recession, boom, growth, stable state, etc. Corresponding to each of these, there are different prices that we need to consider. Relations between these quantities can be explored conveniently using vectors, matrices, and linear algebra. So we recall some linear algebra in this chapter and discuss the associated numerical methods. The first thing that we shall consider is the space spanned by k vectors \(\{u_1,\ldots ,u_k\}\) in E. This space is the collection of all linear combinations \(\sum _{i=1}^ka_iu_i\) where \(a_i\in \mathbb {R}\). We are interested in the dimension of this vector space, that is the maximum number of linearly independent vectors in the collection \(\{u_1,\ldots ,u_k\}\).
Rituparna Sen, Sourish Das
Chapter 3. Solving Nonlinear Equations
Abstract
Calibration of financial models corresponds to the problem of finding the roots of a function. These might appear directly, as in the example of finding implied volatility in Sect. 3.1 or indirectly. Some examples of indirect problems are maximizing the likelihood (see Sect. 13.1) or minimizing a loss function, as in method of least squares in Chap. 17. Nonlinear equation solving is a central component in many numerical procedures. Suppose the price of one share of a particular stock at time t is denoted by \(P_t\). Then the ratio \(P_t/P_{s}\), for \(s<t\) is the return over the period (st). One of the central problems of mathematical finance is to find the volatility, since it is not an observed quantity and has to be inferred from observed market prices of stocks or derivatives. Volatility is a measure of dispersion of prices of a particular asset over a time period. Assuming that the distribution of returns does not change with time, volatility is the standard deviation of log returns for unit time. The estimate of volatility that is derived from the option price is called implied volatility.
Rituparna Sen, Sourish Das
Chapter 4. Numerical Integration
Abstract
Integration is a very common requirement in quantitative finance. In some cases integrals can be evaluated analytically, or at least in terms of standard functions whose values are known. For example in the case of option pricing under the Black–Scholes model, the integral can be expressed in terms of the normal distribution function. However, very often we encounter problems where the integral cannot be evaluated analytically. In such cases we need numerical techniques that we shall explore in this chapter. For one-dimensional integrals, these deterministic methods work quite well. For evaluating integrals in higher dimensional spaces, it may be more advantageous to use random sampling. We shall see these in the Chap. 8 as Monte Carlo methods. Integrals frequently arise as expectations. For example, in economics one needs to evaluate the expected utility. Option pricing requires computing the expected value of the payoff under the risk-neutral measure. For a random variable X with density \(f_X(x)\), the expected value of a function h(.) is given by \(\int _{-\infty }^{\infty }h(x)f_X(x) {\text {d}}x\), which is really an integral.
Rituparna Sen, Sourish Das
Chapter 5. Numerical Differentiation
Abstract
Derivatives arise in finance in several situations. In option pricing, the hedge ratios are related to the derivatives, also known as Greeks. We have seen the need for one such Greek, namely vega, in Sect. 3.​3. Another important application is sensitivity analysis. The general idea is to understand how a target variable, like stock price, is affected by an input variable like book value of the company. A particular sensitivity is bond duration, where the input variable is interest rate and the target variable is bond price. Given any differentiable function, we can find its derivative analytically. However, in many situations, we might need or prefer to obtain a numerical approximation. Here are some examples: The exact formula, even if available in closed analytical form, may entail evaluation of complicated functions. In such cases numerical approximations might be simpler and quicker to obtain. It is often the case that the form of the underlying function is unknown, but given any argument, it can be evaluated. In such cases, even though there is an underlying differentiable function, we cannot find the analytical derivative.
Rituparna Sen, Sourish Das
Chapter 6. Numerical Methods for PDE
Abstract
The time evolution of prices of different financial quantities is often represented as a partial differential equation (PDE) with independent variables being time and prices of some other, often underlying, assets. Let \(V(S_t, t)\) be the price of an option at time t when the share price of the underlying stock is \(S_t\). See Appendix A.1 for background on mathematical finance that is used in what follows. Under the Black–Scholes set-up, we have a risk-less asset bond \(B_t\) and a risky asset stock \(S_t\). They evolve as where r is the interest rate, \(\mu \) is the drift, \(\sigma \) is the volatility and W is a standard Brownian motion(BM). We apply Ito’s formula to the option price to get Consider the discounted option price \(B_t^{-1}V(S_t,t)\). By the Fundamental Theorem of Arbitrage Pricing (see Appendix), the discounted option price must be a martingale under the risk-neutral measure . Also, under the risk-neutral measure \(\mu =r\). We have, from the above, For a martingale, the coefficient of the dt term has to be zero, otherwise there is a systematic drift.
Rituparna Sen, Sourish Das
Chapter 7. Optimization
Abstract
Optimization refers to the minimization (or maximization) of a given objective function of several decision variables that satisfy functional constraints.
Rituparna Sen, Sourish Das

Simulation Methods

Frontmatter
Chapter 8. Monte Carlo Methods
Abstract
In Chap. 4, we have discussed the need for evaluating integrals and described methods for doing this numerically.
Rituparna Sen, Sourish Das
Chapter 9. Lattice Models
Abstract
It is common to model the stock price movement with a stochastic process that has continuous path, for example a geometric Brownian motion. Computationally one can only evaluate the path at discrete points of time, however dense.
Rituparna Sen, Sourish Das
Chapter 10. Simulating Brownian Motion
Abstract
Brownian motion and geometric Brownian motion are the most common models encountered in financial problems. In certain cases, it is possible to obtain analytical expressions for objects of interest from the model. Examples include pricing of vanilla options under the Black–Scholes model.
Rituparna Sen, Sourish Das
Chapter 11. Variance Reduction
Abstract
The Monte Carlo methods described in the previous chapters are subject to variation due to the randomness inherent in sample generation. Ideally we would like this variation to be as small as possible so that in repeated implementations of the same procedure we obtain results that are close to each other. There are several methods to achieve this, and we discuss those in this chapter.
Rituparna Sen, Sourish Das

Statistical Methods

Frontmatter
Chapter 12. Descriptive Statistics
Abstract
So far we have studied mathematical models of market returns, volatility, interest rates, option prices, and other such financial quantities. These models involve unknown distributions and parameters which need to be calibrated to the prices observed in the market. We would also like to have a measure of reliability of the model and the parameters. Once the models are trained with data, we need to rate their performance. For all these purposes, statistical tools are necessary. We devote the rest of the book to these methods.
Rituparna Sen, Sourish Das
Chapter 13. Inferential Statistics
Abstract
The setup of inferential statistics is as follows. There is a population which is a set of all individuals or objects that we are interested in, but is too large to study in its entirety. Instead we obtain a random sample which is a subset of the population and use the information available in the subset to generalize to the population. Usually we specify a model for the probability distribution for the population. This is a probability density function (pdf) for continuous or probability mass function (pmf) for discrete distributions. Although the form of the distribution can be specified depending on the background information on the population, certain numerical characters may be unknown. These unknown but fixed numerical characteristics are associated with the model and are called parameters. A sample statistic is a numerical measure of a sample that can be calculated from the observations. The sample statistics are used to draw inference about population parameters.
Rituparna Sen, Sourish Das
Chapter 14. Bayesian Computation
Abstract
Suppose \(Y \sim p(y|\theta )\) and \(p(\theta )\) is the prior distribution over \(\theta \). Our objective is to make the Bayesian statistical inference about \(\theta \). The posterior distribution of \(\theta \).
Rituparna Sen, Sourish Das
Chapter 15. Resampling
Abstract
In the previous chapters we have considered model-based statistical inference. In many cases, it is difficult to decide on an appropriate model. We are still interested in drawing inference from the data. In such cases, resampling techniques come in handy. Resampling methods require fewer assumptions regarding the underlying data generating mechanism and are, therefore, widely applicable.
Rituparna Sen, Sourish Das
Chapter 16. Statistical Risk Analysis
Abstract
Risk is an inherent quantity in financial markets and is of utmost importance to investors and policymakers. Many methods have been proposed to measure, monitor, and control the risks. There are different kinds of risks. Market risk is the risk to the portfolio from a decline in the market price of instruments in the portfolio. Liquidity risk is the risk that the holder of an instrument will find that a position is illiquid and will incur extra costs in unwinding the position resulting in a less favorable price for the instrument. Credit risk involves the risk that promised payments on a loan or bond will not be made, or that a convertible instrument will not be converted in a timely manner or at all. Other types of risk include interest rate and foreign exchange risks that can also randomly change over time and are of relevance to an investment portfolio. Tools have evolved to measure all these different components of risk. Processes must be put into place to monitor the changing risks in a portfolio and to control the magnitude of risks. For an extensive treatment of these topics, see Litterman et al. (1998). In this chapter we shall discuss only market risks, see Dowd (2007).
Rituparna Sen, Sourish Das
Chapter 17. Supervised Learning
Abstract
Machine learning is going to play an ever-increasing role in the landscape of computational finance. The increasing market share of the ‘Algorithmic Trading’ is an example of the growing use of machine learning in finance. However, ‘Algorithmic Trading’ is one application of machine learning. There are several applications of machine learning in quantitative finance.
Rituparna Sen, Sourish Das
Chapter 18. Linear Systems
Abstract
Many problems  of computational finance, such as pricing of an asset, can be formulated as a system of linear equations. Hence, solving the system of linear equations is important in computational finance. An investor would like to assess if the price of a stock is less than its expected level. If the investor sees the stock is already overpriced, then the chance that it will appreciate further will be less and the investor would like to sell the stock. Other investors would also like to sell the stock as they also have the same public information. The stock will fall back to its expected level. On the contrary, if the stock is underpriced, then many investors would like to buy the stock with the assumption that the price will rise to its expected level.
Rituparna Sen, Sourish Das
Chapter 19. Time Series
Abstract
Time series refers to any group of statistical information accumulated at regular intervals. It is a quantitative method used to determine patterns in data collected over time. When these patterns are projected to arrive at an estimate for the future, it is called forecasting. The quality of the forecasting is strongly related to the information that can be extracted and used from past data. In Fig. 19.1 we present a time series plot of the closing prices of IBM stock from daily data for the period 2001–2012.
Rituparna Sen, Sourish Das
Chapter 20. High-Frequency Data
Abstract
Intra-day financial transactions and quotes data have become available since 1990’s. These have sparked research on the micro-structure of markets. The two main financial markets that provide high-frequency data are the FOREX and the US equity markets. The latter is contained in the TAQ (Trade And Quote) database which contains all trades (including quantity traded) and quotes for all listed stocks since the early 1990s. Contrary to this centralized market, the FOREX market is decentralized and there are only observations for quote of many currency pairs but no transaction data. An interesting issue of the FOREX market is that it is always open and geographically disperse since the trading day starts in Tokyo, which is followed by the opening of the London market, and finally by New York.
Rituparna Sen, Sourish Das
Chapter 21. Unsupervised Learning
Abstract
Unsupervised learning is a class of algorithms; where a machine looks for patterns in a dataset with no labels (or target variables to predict). This is in distinction to supervised learning procedures, such as classification or regression, where a model is given training data of inputs and target variables; and learns to map from the inputs to the target. In unsupervised learning, only the inputs are available, and an algorithm looks for interesting patterns in the data. Unsupervised learning is aka., knowledge discovery.
Rituparna Sen, Sourish Das
Backmatter
Metadaten
Titel
Computational Finance with R
verfasst von
Rituparna Sen
Sourish Das
Copyright-Jahr
2023
Verlag
Springer Nature Singapore
Electronic ISBN
978-981-19-2008-0
Print ISBN
978-981-19-2007-3
DOI
https://doi.org/10.1007/978-981-19-2008-0