Numerical optimisation methods using Excel VBA.

Attribution Non-Commercial (BY-NC)

296 views

Numerical optimisation methods using Excel VBA.

Attribution Non-Commercial (BY-NC)

- VBA
- Newton-Raphson Method in Excel VBA
- VBA_tip and trick
- Intermediate Excel for Real Estate
- Ms Excel Notes
- Split the Rows Into Multiple Worksheets by Rows Count
- Using Reuters Powerplus Pro
- SilkTest and Excel
- Whats New
- Essential Excel 2016 - A Step-By-Step Guide - 1st Edition (2016)_Part3
- 20131129_Optimization Modeling for Logistics_apresentar
- 12 sadf23
- Release Notes Sap 2000 v 1811
- Proposal
- R12 Uploading a Journal Using Web ADI
- AF1 BSLimitations.pdf
- Controller
- Redundancy Citect
- mfe-09-07
- Advanced Excel Training Highlights

You are on page 1of 4

Newtons Algorithm

Newton's algorithm, alternately called the Newton-Raphson method, is a numerical method for solving equations of the type f(x)=0. It has numerous applications in finance, and we will use it to determine the volatility surface for a call option using the Black Scholes VBA function. The method applies when we have a close approximation for a solution to the equation. The method assumes that the tangent to the graph at our approximation intersects the x-axis closer to the solution of the equation, i.e. closer to where the line we are evaluating intersects the x-axis. By solving for where the tangent intersects the xaxis, and repeating the process from that point, we get closer and closer to the actual solution of the equation. Let's say we're at our approximate solution, x0. The value of y-axis at this point is y = f(x0). We know that the tangent has gradient f'(x) - the same gradient as the line, from the definition of a tangent. We also know that a univariate linear function takes the form f(x) = mx + c, where m is the gradient, x is the horizontal displacement from the starting point, and c is the vertical displacement from the starting point. As such, we have y = f'(x0)(x-x0) + f(x0) as the line of the tangent. We solve this for y = 0 in order to get the next guesstimate of the solution to f(x) = 0. The above is the simpler method of interpretation, but the statement f(x) = mx+c is actually derived from the more generalised Taylor's series expansion where a continuous, differentiable function f may be expanded about a point c as follows: f(x) =f(c)+f'(c)(x-c)+f''(c)/2!*(xc)^2+... This is the univariate version of the Taylor expansion, but it will suffice for finding, for example, volatility smiles since we assume that all other variables remain constant. Since the equation is linear, no second order derivatives exist so these fall away, leaving f(x) =f(c)+f'(c)(x-c). In our example, x0=c, giving y = f'(x0)(x-x0) + f(x0) The equation of the intersection of the tangent with the y-axis is given by the following: 0 = f'(x0)(x1-x0) + f(x0) We then solve for x1 x1 = x0 - (f(x0)/f'(x0) From this we can induce (though actual proof is out of scope here), that xn+1 = xn - f(xn)/f'(xn) , which is the formula for Newton's method. The formula for Newton's method works in cases where the function is differentiable, and where the gradient is not equal to zero.

VBA implementation of Newton's algorithm

Here is an implementation of Newton's algorithm for a simple function, f(x) = x2 - 3. For the volatility surface version, func(x_n) will be replaced by the Black Scholes VBA pricing function, and func_dash(x_n) will be replaced by the VBA function for calculating vega, the first derivative of the option price with respect to volatility. Function Newton(Seed As Double, Precision As Double) As Double Dim x_next As Double, x_n As Double, error_val As Double Dim ctr As Integer x_n = Seed ctr = 0 Do x_next = x_n - func(x_n) / func_dash(x_n) error_val = x_next - x_n x_n = x_next ctr = ctr + 1 Loop Until (Abs(error_val) <= Precision Or ctr = 1000) Newton = x_next End Function Function func(x_n) As Double func = x_n ^ 2 - 3 End Function Function func_dash(x_n) As Double func_dash = 2 * x_n End Function

You can get complete Excel apps from VBA Develeoper.net containing the code in this document, customisation, VBA development of any Excel, Access and Outlook apps, as well as C# and C++ add-ins and technical documentation.

How to build a Black Scholes VBA Option Pricer

How to build a Black Scholes C# Option Pricer How to build a Black Scholes VBA Option Pricer for FX Options How to build a Black Scholes VBA Option Pricer for Equity Options How to build a Black Scholes VBA Option Pricer using Monte Carlo Simulation How to build a Black Scholes VBA Option Pricer for Binary Options How to build a Black Scholes VBA Option Pricer for Equity Barrier Options How to build a Black Scholes VBA Option Pricer for Exotic Asian Options How to build a Black Scholes VBA Option Pricer for Exotic Lookback Options How to build an Equity Option Pricer using the Binomial Tree in Excel VBA How to code a Choleskey Decomposition in VBA (Numerical Methods for Excel) 3 ways to sort in VBA How to Code a Multivariate Value at Risk (VaR) VBA Monte Carlo Simulation How To Code the Newton-Raphson Method in Excel VBA How to Model Volatility Smiles, Volatility Term Structure and the Volatility Surface in Excel VBA How To Write Use Cases for a Portfolio Reporting VBA Tool How To Write a User Interface Model For a Portfolio Reporting VBA Tool How To Create a Semantic Object Model For a Portfolio Reporting VBA Tool How To Normalise a Database For VBA Apps How To Create a Database using SQL Scripts for a Portfolio Reporting VBA App How to Write Stored Procedures in SQL/Access/VBA for a Portfolio Reporting VBA App How to Use Cursors in SQL for a Portfolio Reporting VBA Tool How to Move Data from Access to Excel with SQL for a Portfolio Reporting VBA App

Portfolio Reporting VBA Tool: Inserting Data into SQL/Access Databases from Excel Portfolio Reporting VBA Tool: Connecting Excel with SQL & Access Databases How To Design Classes For an Option Pricer in VBA: UML Concepts How To Design Classes for Object Orientated VBA Programming

- VBAUploaded byShahnawazSoomro
- Newton-Raphson Method in Excel VBAUploaded byMagno Felipe Teixeira
- VBA_tip and trickUploaded byLimin Ma
- Intermediate Excel for Real EstateUploaded byda_yt_boi
- Ms Excel NotesUploaded bysmart_faizy4u
- Split the Rows Into Multiple Worksheets by Rows CountUploaded byAhmed Atef
- Using Reuters Powerplus ProUploaded byTurcan Ciprian Sebastian
- SilkTest and ExcelUploaded byapi-3736193
- Whats NewUploaded bysdfgkldsjdksfn
- Essential Excel 2016 - A Step-By-Step Guide - 1st Edition (2016)_Part3Uploaded byKevin Richard
- 20131129_Optimization Modeling for Logistics_apresentarUploaded byAndré Luiz de Mello
- 12 sadf23Uploaded bygagoness ka
- Release Notes Sap 2000 v 1811Uploaded byChiaChing Hsiao
- ProposalUploaded byRobertoTorresTorres
- R12 Uploading a Journal Using Web ADIUploaded bydevender143
- AF1 BSLimitations.pdfUploaded byKryon Cloud
- ControllerUploaded byapi-77570043
- Redundancy CitectUploaded byIvan Marchenko
- mfe-09-07Uploaded byTanadkit Munkonghat
- Advanced Excel Training HighlightsUploaded byVicksmanChidex
- Data Table MethodsUploaded bySeshu Venkat
- Bm Excel VBEUploaded bySivasubramanian.m
- chap5Uploaded bycharles luis
- Clickers How to Start and Finish Test 2010Uploaded byMolly Cragun Kendall
- edt 180 reflection paperUploaded byapi-452644839
- Lab#-4 Introduction to PetrelUploaded byAnonymous qaI31H
- Manual IngUploaded byMuscalu Gheorghe
- Solidworks API_Intro.pptxUploaded byprasad290
- AF1 BSLimitationsUploaded bygarycwk
- If Function - Office SupportUploaded byMoznav

- aipythonUploaded byNaimish Dixit
- Etl Performance 07Uploaded byTwan Manders
- Brief USER GUIDE for SMK St.Columba Official Website.pdfUploaded byBernard Goh
- MCA 5Uploaded byShreyas Khanore
- Information Retrieval Features of Online Search ServicesUploaded byHellenNdegwa
- FIAT-RUNBOOK.pdfUploaded byDenem Orhun
- system conversionUploaded byMOORTHY.KE
- Cisco Small Business Switching Portfolio PosterUploaded byGalatescu Dan
- Shailendra RESUMEUploaded byShailendra Rajput
- Tib Ad Cics Users GuideUploaded byAsk Satwaliya
- Panasonic Panafax DX600 800 Service ManualUploaded bychrisban35
- Digit Vol 15 Issue 05 May 2015Uploaded bySailesh
- Chapter 11Uploaded byro
- Diagnostics Apps CheckUploaded byahmed_sft
- ArrUploaded byHemanshu Dabas
- Supplier WorkplaceUploaded byBiswajit Mishra
- Lab diagramUploaded byKostas Dimitriou
- 10 Reasons to get a seedbox.PDFUploaded bydavidt7890
- Vlsi Interview Question AnswerUploaded bySuchitav Khadanga
- Kunci Jawaban All Quiz Oracle Academy Java Fundamental 2017 Part 11 - DS SanjayaUploaded byhana a nur arifah
- RE82701 1099 Electronic ComponentsUploaded byAbel
- types of computer their parts1Uploaded byapi-247871582
- Guia Compaq Pantalla Q2159Uploaded byAdlida
- SyncPA-1664.pdfUploaded bySerkan Kılıçaslan
- speedReleaseNotes11.04.010Uploaded bykhodabandelou
- IntegratingUploaded byVenkateshwar R Polaconda
- Dictionaries in pythonUploaded byGaneshBalaji Katuri
- SimUploaded byrpressi
- International Journal of Computer Science and Security (IJCSS), Volume (3), Issue (1)Uploaded byAI Coordinator - CSC Journals
- Xcell80Uploaded byFernando Crivellaro