1 / 105

Computational Finance

Computational Finance. Zvi Wiener 02-588-3049 http://pluto.mscc.huji.ac.il/~mswiener/zvi.html. Plan. 1. Introduction, deterministic methods. 2. Stochastic methods. 3. Monte Carlo I. 4. Monte Carlo II. 5. Advanced methods for derivatives. Other topics:

allan
Télécharger la présentation

Computational Finance

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Computational Finance Zvi Wiener 02-588-3049 http://pluto.mscc.huji.ac.il/~mswiener/zvi.html Bank Hapoalim

  2. Plan 1. Introduction, deterministic methods. 2. Stochastic methods. 3. Monte Carlo I. 4. Monte Carlo II. 5. Advanced methods for derivatives. Other topics: queuing theory, floaters, binomial trees, numeraire, ESPP, convertible bond, DAC, ML-CHKP. CF1

  3. Linear Algebra 1 -2 1 Vectors {1, 1}, {-2, 1} rows or 1 -2 columns 1 1 CF1

  4. Linear Algebra CF1

  5. Basic Operations 1 2 3 2 + -1 = 1 -2 1 -1 1 3 3 2 = 6 2 6 CF1

  6. Linear Algebra vector Vectors form a linear space. Zero vector Scalar multiplication CF1

  7. Linear Algebra Matrices also form a linear space. matrix Zero matrix Unit matrix CF1

  8. Linear Algebra Matrix can operate on a vector How does zero matrix operate? How does unit matrix operate? CF1

  9. Linear Algebra Transposition of a matrix A symmetric matrix is A=AT for example a variance-covariance matrix. CF1

  10. Linear Algebra Matrix multiplication CF1

  11. Scalar Product a is orthogonal to b if ab = 0 CF1

  12. Linear Algebra Scalar product of two vectors Euclidean norm CF1

  13. Determinant Determinant is 0 if the operator maps some vectors to zero (and can not be inverted). CF1

  14. Linear Algebra • Matrix multiplication corresponds to a consecutive application of each operator. • Note that it is not commutative! ABBA. • Unit matrix does not change a vector. • An inverse matrix is such that AA-1=I. CF1

  15. Linear Algebra • Determinant of a matrix ... • A matrix can be inverted if det(A)0 • Rank of a matrix • Matrix as a system of linear equations Ax=b. • Uniqueness and existence of a solution. • Trace tr(A) – sum of diagonal elements. CF1

  16. Linear Algebra • Change of coordinates C-1AC. • Jordan decomposition. • Matrix power Ak. • Matrix as a quadratic form (metric) xTAx. • Markov process. • Eigenvectors, eigenvalues Ax=x, optimization. CF1

  17. Problems Check how the following matrices act on vectors: CF1

  18. Simple Exercises • Show an example of ABBA. • Construct a matrix that inverts each vector. • Construct a matrix that rotates a two dimensional vector by an angle . • Construct a covariance matrix, show that it is symmetric. • What is mean and variance of a portfolio in matrix terms? CF1

  19. Examples • Credit rating and credit dynamics. • Variance-covariance model of VaR. • Can the var-covar matrix be inverted • VaR isolines (the ovals model). • Prepayment model based on types of clients. • Finding a minimum of a function. CF1

  20. Calculus • Function of one and many variables. • Continuity in one and many directions. • Derivative and partial derivative. • Gradient and Hessian. • Singularities, optimization, ODE, PDE. CF1

  21. Linear and quadratic terms $ x CF1

  22. Taylor series CF1

  23. Variance-Covariance CF1

  24. Variance-Covariance Gradient vector: CF1

  25. Variance-Covariance CF1

  26. Variance-Covariance CF1

  27. Variance-Covariance For a short time period , the changes in the value are distributed approximately normal with the following mean and variance: CF1

  28. Variance-Covariance Then VaR can be found as: CF1

  29. Weighted Variance covariance Volatility estimate on day i based on last M days. CF1

  30. Weighted Variance covariance Covariance on day i based on last M days. It is important to check that the resulting matrix is positive definite! CF1

  31. Positive Quadratic Form For every vector x a we have x.A.x > 0 Only such a matrix can be used to define a norm. For example, this matrix can not have negative diagonal elements. Any variance-covariance matrix must be positive. CF1

  32. Positive Quadratic Form Needs["LinearAlgebra`MatrixManipulation`"]; ClearAll[ positiveForm ]; positiveForm[ a_?MatrixQ ] := Module[{aa, i}, aa = Table[ Det[ TakeMatrix[ a, {1, 1}, {i, i}] ], {i, Length[a]}]; { aa, If[ Count[ aa, t_ /; t < 0] > 0, False, True]} ]; CF1

  33. Stochastic (transition) Matrix Used to define a Markov chain (only the last state matters). A matrix P is stochastic if it is non-negative and sum of elements in each line is 1. One can easily see that 1 is an eigenvalue of any stochastic matrix. What is the eigenvector? CF1

  34. Markov chain • credit migration • prepayment and freezing of a program CF1

  35. Stochastic (transition) Matrix Theorem: P0 is stochastic iff (1,1,…1) is an eigenvector with an eigenvalue 1 and this is the maximal eigenvalue. If both P and PT are stochastic, then P is called double stochastic. CF1

  36. Cholesky decomposition The Cholesky decomposition writes a symmetric positive definite matrix as the product of an upper­triangular matrix and its transpose. In MMA CholeskyDecomposition[m] CF1

  37. Generating Random Samples We need to sample two normally distributed variables with correlation . If we can sample two independent Gaussian variables x1 and x2 then the required variables can be expressed as CF1

  38. Generating Random Samples We need to sample n normally distributed variables with correlation matrix ij, ( >0). Sample n independent Gaussian variables x1…xn. CF1

  39. Function of a matrix CF1

  40. ODE CF1

  41. ODE CF1

  42. Bisection method f If the function is monotonic, e.g. implied vol. x CF1

  43. Newton’s method f x2 x3 x x1 CF1

  44. Solve and FindRoot Solve[ 0 = = x2- 0.8x3- 0.3, {x}] {{x -> -0.467297}, {x ->0.858648 -0.255363*I}, {x -> 0.858648 + 0.255363*I}} FindRoot[ x2 + Sin[x] - 0.8x3 - 0.3, {x, 0,1}] {x -> 0.251968} CF1

  45. Max, min of a multidimensional function • Gradient method • Solve a system of equations(both derivatives) CF1

  46. Gradient method CF1

  47. Level curve of a multivariate function ContourPlot[ x^2+y^3, {x,-2,2}, {y,- 2,2}] ContourPlot[ x^2+y^3, {x,-2,2}, {y,- 2,2}], Contours->{1 ,-0.5}, ContourShading->False]; CF1

  48. ContourPlot[ x^2+y^3, {x,-2,2}, {y,- 2,2}] CF1

  49. ContourPlot[ x^2+y^3, {x,-2,2}, {y,- 2,2}], Contours->{1 ,-0.5}, ContourShading->False]; CF1

  50. Example Consider a portfolio with two risk factors and benchmark duration of 6M. The VaR limit is 3 bp. and you have to make two decisions: a – % of assets kept in spread products q – duration mismatch we assume that all instruments (both treasuries and spread) have the same duration T+q months. CF1

More Related