A Structural and Ecient Method for Calculating Gradient and Hessian with CVaR Portfolio Optimization Application

Calculating or approximating the derivatives for large-scale multi-dimensional functions is an active research area in modern mathematics. The rationale behind this popularity is its wide applications in statistics, financial mathematics and portfolio optimization. For example, in statistics, maximum likelihood estimation seeks the value of parameter vector that maximize the likelihood function, which requires to find the points where derivative of likelihood function is zero; in finance, taking derivatives can be applied to sensitivity analysis for equity valuation, with respect to single or multiple variables; numerical optimization problems calculate the derivatives at each iteration, such as trust-region method. The most straightforward way to calculate a derivative is hand-coding, but it is only applicable to sufficiently simple functions, and it’s error-prone. Finite-difference method is easy to implement with a programming language, but the accuracy depends on the choice of discretization steps, and hence can not be guaranteed. Throughout this essay, we study the methodology of automatic differentiation (AD), and introduce a structural automatic differentiation method (Structural-AD) for calculating gradient and hessian. The implementation of Structural-AD uses the software ADMAT 2.0 installed on MATLAB by Cayuga Research Associates [2009]. Structura-AD exploits the ‘natural structure’ of some functions and it makes use of the regular reverse mode of AD to achieve more efficient computing time and less memory usage requirement. In the paper by Xu and Coleman [2013], they applied structural-AD to two extreme cases, generalized partially separable problem and dynamic system computations. They showed that computing time and memory requirement using Structural-AD is significantly reduced compared to the regular reverse mode. We also applied structural-AD on a Conditional Value-at-Risk (CVaR) optimization problem, specifically with the underlying function describing the loss function of a stock portfolio.