Three Problems Solved With Algorithms in Finance
December 29, 2020

3 Problems Solved With Numerical Algorithms in Finance

Algorithms & Functions

The financial industry includes consumer and commercial banking, life and casualty insurance, retail, investment banking, and much more. Organizations in these different areas of finance are long-time users of mathematical and statistical methods to analyze, understand, and make optimal decisions based on data.

In this blog we review three classic applications for numerical algorithms in finance:

We also identify some of the algorithms that are used to address these specific problems and many others in the finance industry.

Portfolio Selection

In portfolio selection the problem is to determine the combination of assets (stocks, bonds, or derivatives) so that a portfolio has the highest expected return for a given level of risk. The problem may also be to determine the lowest risk portfolio for a given expected rate of return.

Portfolio selection is a classic optimization problem and may be formulated in various ways depending on the selection of the objective function, the definition of the decision variables, and the constraints underlying the specific situation. Many different optimization techniques (e.g., linear, nonlinear, quadratic programming) have been used in practice.

In applications, one difficulty is capturing the correlation structure among the different prices of the assets. Do they tend to increase together or opposite to one another, and how strong is the relationship? Simplifying assumptions that help to keep the modeling tractable are not necessarily true in real life. In some cases, this can lead to severely underestimating the risk levels. This is an active area of research in portfolio optimization.

 Portfolio Selection - Algorithms in Finance
Figure 1 - Portfolio selection: the optimal allocation of stocks is given in a pie-chart. The efficient frontier shows the boundary of portfolios that yield the highest possible return given a risk value. The IMSL Libraries help asset managers and quantitative analysts develop versatile portfolio optimization applications.

 

Option Pricing

When an investor buys an option (a call option or a put option), they are buying the right to either buy or sell a stock (or derivative) at a specified price (the strike price) by a specified date (the expiration date). The holder of an option has the right but not the obligation to exercise the option; naturally, they will only exercise the option when the stock price is above the strike price in the case of a call option, or below the strike price in the case of a put option.

A brokerage who sells options to the market must determine how to value the option. What should an investor pay for the right to buy or sell the stock given the stock price at the time the option contract begins, the strike price, and the expiration date? The pricing of options has been extensively studied and many models have been applied, the most well-known and widely-used being the Black–Scholes option pricing model.

Figure 2 shows the value of a small portfolio of American style options and how the value changes depending on the spot price and time to expiration. American style options can be exercised any time between the date of purchase up to the expiration date. (A European style option may only be exercised on the expiration date.) In this instance the portfolio contains the purchase of 1 call option, 1 put option, and the sale of 1 put option, all at slightly different strike prices. Negative values in the plot indicate a net loss in the portfolio.

Option Pricing - Algorithms in Finance
Figure 2 - The value of a portfolio of American style options. This application shows how much a small portfolio of American style options is worth for different spot prices and at different times relative to the expiration date.

Computing the current value of an American call option requires solving the Black-Scholes partial differential equation. Because the asset may be exercised at any time before its expiration date, the numerical computation involves solving a free boundary problem. Based on a non-negative constrained least-squares (NNLS) algorithm, efficient techniques have been developed for solving a related quadratic programming problem. The technical report, Integrating Feynman-Kac Equations Using Hermite Quintic Finite Elements, describes the new generalized version of the Feynman-Kac partial differential equation and Feynman-Kac algorithm in detail and provides many Black-Scholes examples.

Risk Management

Risk management represents a broad application area of financial optimization. For example, risk models are applied to choose portfolios with specified exposure to different risks. Common risks portfolios are exposed to include:

  • Interest rate risk: the impact of increasing or decreasing interest rates on the values of loans and bonds.
  • Liquidity risk: the impact on a portfolio when debt obligations cannot be paid at certain times.
  • Credit risk: the impact on the value of a portfolio due to loan defaults or prepayments.
  • Volatility risk: the impact on the value of a portfolio due to wide swings in prices of the underlying assets.

IMSL offers several algorithm classes to address risk management, including:

  • Monte Carlo techniques to simulate complex systems, do “what-if” analysis and model the effects of volatility. The IMSL Libraries provide more than 30 random number generators as well as numerous cumulative distributions and variance/covariance functions.
  • Time series algorithms for cross-correlation and multi-channel cross-correlation to discover relationships between variables, and model and predict multiple interrelated time-series values.
  • Specific time series techniques include ARMA, GARCH and Kalman Filters.
  • Many data mining algorithms to help users manage the large volumes of financial data being created and stored today. Classification, data conditioning, association, clustering, modeling, and prediction algorithms can all help users identify and hypothesize relationships within data sets.
Risk Management - Algorithms in Finance
Figure 3 - Monte Carlo simulations are used for modeling uncertainty to help manage business risk and work by replacing uncertain quantities in a model with simulated numbers and then seeing how that uncertainty affects results. The IMSL Numerical Libraries can calculate information about the range of outcomes such as best – and worst-case, the chances of reaching target goals, and the most likely outcomes.

Popular Algorithms in Finance

Solving these three classic problems, as well as many others, requires a broad set of tools and a heavy reliance on numerical algorithms. We list some of the most widely used numerical algorithms in the table below.

Differential Equations:Feynman-Kac for Solving Black-Scholes Problems
Quadrature:Univariate and multivariate numerical integration techniques
Optimization:Linear, Nonlinear, and Quadratic Programming Genetic Algorithm
Regression:Linear, Nonlinear, Selection, Stepwise
Curve Fitting:Cubic Splines, B-splines, Nonlinear Least Squares, TCB Spline
Simulations:Probability distributions (pdf, cdf, inverse cdf) and Random Number Generators for Probability Distributions
Classification:Naïve Bayes, Neural Network, Decision Trees
Forecasting:ARMA, Auto_ARIMA, GARCH, Neural Network
Pricing Functions:Bond Pricing, Interest Rate Calculations, Future Value

 

Tools for Quantitative Finance

IMSL Libraries provide the building blocks to address the analysis requirements and challenges for applications in quantitative finance and ensure:

  • Faster time to market. 
  • Positive ROI. 
  • Maintaining a competitive edge. 
  • Multi-platform and multi-language support. 

Want to see how IMSL numerical algorithms can work with your financial application?

Try Free