From d888e17828052a7718bd73ccfd8ee64d5f3064c3 Mon Sep 17 00:00:00 2001 From: JA-Ubuntu Date: Mon, 8 Jul 2024 12:20:04 -0500 Subject: [PATCH] vignette black update 1 --- vignettes/black_scholes_solver.Rmd | 62 ++++++++++++++++++++---------- 1 file changed, 42 insertions(+), 20 deletions(-) diff --git a/vignettes/black_scholes_solver.Rmd b/vignettes/black_scholes_solver.Rmd index 66b02c1..956ce18 100644 --- a/vignettes/black_scholes_solver.Rmd +++ b/vignettes/black_scholes_solver.Rmd @@ -11,13 +11,10 @@ vignette: > ## Introduction -1. Loading packages -```{r,eval=TRUE,message=FALSE, warning=FALSE} -library( CFINI ) -library( plotly ) -``` + + +A general representation of the equation related to the Black-Scholes model: -A general representation of the equation related to the Black-Scholes models. \begin{equation} \left\{ \begin{array}{ll} @@ -34,21 +31,29 @@ V( t, S_h ) = v_2( t ) & \forall t \in [ 0, T ] \right. \end{equation} -the particular case of Black-Scholes is given by the following parameters + +the particular case of Black-Scholes is given by $\alpha( t, S ) = \frac{1}{2}\sigma^2 S^2$, $\beta( t, S ) = r S$ and $\gamma( t, S ) = -r$ where $\sigma, r$ are constants. -It is important to observe that this model considers a final condition FC, that usually represents -the value of the option at the end of the contract. +Note that this model considers a final condition (*FC*) which usually represents the value of the +option at the end of the contract. -The idea of being able to produce a differential model that will be capable to produce a consistent -pricing model that will hedge the final option is supported by the the second fundamental theorem -of asset pricing, which precisely relates the ability to hedge arbitrary claims, to the uniqueness -of martingale measures. + + + + +The idea of being able to produce a differential model that will be capable of producing a +consistent pricing model to hedge the final option is supported by the the second fundamental +theorem of asset pricing. This theorem precisely relates the ability to hedge arbitrary claims to +the uniqueness of martingale measures. + +**Transformation of the particular case of Black-Scholes** + + +The previous model can be transformed to the *classical diffusion* problem by the right change of +variables: -## Transformation of the particular case of Black-Scholes -The previous model can be transformed in the classical diffusion problem, related to the heat -equation, by the right change of variables. \begin{equation} V( t, S ) = e^{\alpha x + \beta \tau} u( x, t )\\ \alpha = -\frac{1}{2}\left( \frac{2r}{\sigma^2} - 1 \right) \\ @@ -58,6 +63,15 @@ t = T - \frac{2 \tau}{\sigma^2} \end{equation} +## Example + +1. Load required packages + +```{r,eval=TRUE,message=FALSE, warning=FALSE} +library( CFINI ) +library( plotly ) +``` + 2. Related coefficients ```{r,eval=TRUE,message=FALSE, warning=FALSE} # Diffusion parameter constant @@ -93,6 +107,9 @@ I <- sapply( x, FUN = If ) A <- rep( 0, Nt ) B <- rep( 0, Nt ) ``` + + + \begin{equation} A = \begin{bmatrix} b_1 & a_1 & 0 & 0 & \cdots & 0 \\ @@ -104,15 +121,19 @@ c_1 & b_2 & a_2 & 0 & \cdots & 0 \\ \end{bmatrix} \end{equation} -5. Euler implicit scheme has the following form for the equation + +5. The implicit Euler method has the following form for the equation \begin{equation} u_{n+1,i} - u_{n,i} = \lambda_{n, i} ( u_{n+1,i+1} - 2 u_{n+1,i} + u_{n+1,i-1} ) + \rho_{n,i} ( u_{n+1,i+1/2} - u_{n+1,i-1/2} ) + \gamma_{n,i} u_{n+1,i} \end{equation} -From previous scheme at every time step $n$ we formulate a tridiagonal problem $A u_n = d$, with -the folowing definitions. + + +From the previous scheme, at every time step $n$ we formulate a tridiagonal problem $A u_n = d$, +with the folowing definitions: + \begin{eqnarray} \lambda_{n, i} & = & \alpha_{n, i} \frac{\Delta t_n}{\Delta x_{i}\ \Delta x_{i+1}} \\ \rho_{n, i} & = & \beta_{n, i} \frac{\Delta t_n}{2(x_{i+1} - x_{i})} \\ @@ -126,7 +147,8 @@ d_i & = & u_{n,i} Ueu <- cf_diff_solv_euls( alpha, I, A, B, t, x, FALSE ) ``` -6. Solving with Crank-Nicolson implicit method +6. Solving with Crank-Nicolson method + \begin{equation} u_{n+1,i} + \theta ( \lambda^2_{n,i} \Delta_x u_{n+1,i+1} - \lambda^1_{n,i} \Delta_x u_{n+1,i} ) = u_{n,i} + ( 1 - \theta ) ( \lambda^2_{n,i} \Delta_x u_{n,i+1} - \lambda^1_{n,i} \Delta_x u_{n,i} )