Refactor code for improved readability and consistency across multiple Jupyter notebooks

- Added missing commas in various print statements and function calls for better syntax.
- Reformatted code to enhance clarity, including breaking long lines and aligning parameters.
- Updated function signatures to use float type for sigma parameters instead of int for better precision.
- Cleaned up comments and documentation strings for clarity and consistency.
- Ensured consistent formatting in plotting functions and data handling.
This commit is contained in:
2025-12-13 23:38:17 +01:00
parent f89ff4a016
commit d5a6bfd339
50 changed files with 779 additions and 449 deletions

View File

@@ -17,7 +17,7 @@
"source": [
"import matplotlib.pyplot as plt\n",
"import numpy as np\n",
"import scipy.stats as stats"
"from scipy import stats"
]
},
{
@@ -46,15 +46,12 @@
"outputs": [],
"source": [
"def S(t, S0, mu, sigma, W):\n",
" \"\"\"\n",
" Solution exacte de l'EDS de Black-Scholes\n",
" \"\"\"\n",
" \"\"\"Solution exacte de l'EDS de Black-Scholes\"\"\"\n",
" return S0 * np.exp((mu - 0.5 * sigma**2) * t + sigma * W)\n",
"\n",
"\n",
"def euler_maruyama(mu, sigma, T, N, X0=0.0):\n",
" \"\"\"\n",
" Simulation d'une EDS de Black-Scholes par la méthode d'Euler-Maruyama\n",
" \"\"\"Simulation d'une EDS de Black-Scholes par la méthode d'Euler-Maruyama\n",
"\n",
" Paramètres :\n",
" mu (float) : drift\n",
@@ -84,8 +81,7 @@
"\n",
"\n",
"def plot_brownien(t, X, B=None):\n",
" \"\"\"\n",
" Plot la simulation d'Euler-Maruyama\n",
" \"\"\"Plot la simulation d'Euler-Maruyama\n",
"\n",
" Paramètres :\n",
" t (array-like) : tableau des temps\n",
@@ -169,8 +165,7 @@
"\n",
"\n",
"def plot_convergence(S0, mu, sigma, T):\n",
" \"\"\"\n",
" Plot la convergence du schéma d'Euler-Maruyama\n",
" \"\"\"Plot la convergence du schéma d'Euler-Maruyama\n",
"\n",
" Paramètres :\n",
" S0 (int) : valeur initiale\n",
@@ -291,7 +286,7 @@
"print(\n",
" \"La barrière a été franchie\"\n",
" if is_barrier_breached(X, B)\n",
" else \"La barrière n'a pas été franchie\"\n",
" else \"La barrière n'a pas été franchie\",\n",
")"
]
},
@@ -335,8 +330,7 @@
" \"\"\"\n",
" if not is_barrier_breached(X, B):\n",
" return max(X[-1] - K, 0)\n",
" else:\n",
" return 0\n",
" return 0\n",
"\n",
"\n",
"def call_BS(x):\n",