Simulation of LogNormal process for an asset pricing - Mathematica Stack Exchange most recent 30 from mathematica.stackexchange.com 2019-11-14T22:05:39Z https://mathematica.stackexchange.com/feeds/question/83519 https://creativecommons.org/licenses/by-sa/4.0/rdf https://mathematica.stackexchange.com/q/83519 1 Simulation of LogNormal process for an asset pricing Madmex https://mathematica.stackexchange.com/users/29493 2015-05-15T14:22:28Z 2015-06-20T19:34:34Z <p>I'm new to Mathematica programming, so forgive my rather unsophisticated question.</p> <p>I need to simulate 5000 "walks" of a process value (of a stock) that starts from its current value, at <code>t0</code>, and ends in <code>T</code> (expiration date of an option). The stocks follow a lognormal process. The process in question must have mean <code>(r - [Sigma]^2/2)</code> and standard deviation <code>([Sigma] Sqrt[T])</code>. After that, I need to calculate the mean of the 5000 final values that, probably, will correspond to the expected value <code>(E^Q) [Subscript[S, T]]</code>. All of this to find the price of a call option using:</p> <pre><code>Subscript[C, t] = E^(-r (T - t)) ((E^Q) [Subscript[S, T]] - K) </code></pre> <p>and find the value in <code>t</code> of my call option.</p> <p>In theory I know all of this but practically can not do anything. Can someone help me?</p> https://mathematica.stackexchange.com/questions/83519/-/83523#83523 1 Answer by MarcoB for Simulation of LogNormal process for an asset pricing MarcoB https://mathematica.stackexchange.com/users/27951 2015-05-15T14:44:27Z 2015-05-15T14:44:27Z <p>This should generate 5000 samples from the distribution you specified, once you plug in the values of <code>sigma</code> and <code>t</code>:</p> <pre><code>RandomVariate[ LogNormalDistribution[r - sigma^2/2, sigma Sqrt[t]], 5000 ] </code></pre> <p>For instance (I just made up numbers here for mean and sigma):</p> <pre><code>samples = RandomVariate[LogNormalDistribution[1 - 0.5^2/2, 0.5 Sqrt], 1000]; Histogram[samples] </code></pre> <p><img src="https://i.stack.imgur.com/teB0B.png" alt="Mathematica graphics"></p> https://mathematica.stackexchange.com/questions/83519/-/85918#85918 1 Answer by Sjoerd C. de Vries for Simulation of LogNormal process for an asset pricing Sjoerd C. de Vries https://mathematica.stackexchange.com/users/57 2015-06-14T17:50:12Z 2015-06-20T19:13:40Z <pre><code>With[{t0 = 0, tend = 1, σ = 0.8, r = .01, S0 = 100, Κ = 110}, data = RandomFunction[GeometricBrownianMotionProcess[0, σ, S0], {t0, tend, 1/12}, 5000]; Exp[-r (tend - t0)] Mean[Max[#, 0] &amp; /@ (data["LastValues"] - Κ)]] (* 27.5607 *) ListLinePlot[data, PlotRange -&gt; All, PlotStyle -&gt; Opacity[0.2]] </code></pre> <p><img src="https://i.stack.imgur.com/utHll.png" alt="Mathematica graphics"></p> <p>Comparing this with Black-Scholes:</p> <pre><code>d1[s_, x_, r_, t_, σ_] := (Log[s/x] + (r + 1/2 σ^2) t)/(σ Sqrt[t]) d2[s_, x_, r_, t_, σ_] := d1[s, x, r, t, σ] - σ Sqrt[t] c[s_, x_, r_, t_, σ_] := s CDF[NormalDistribution[], d1[s, x, r, t, σ]] - x E^(-r t) CDF[NormalDistribution[], d2[s, x, r, t, σ]] p[s_, x_, r_, t_, σ_] := x E^(-r t) (1 - CDF[NormalDistribution[], d2[s, x, r, t, σ]]) - s (1 - CDF[NormalDistribution[], d1[s, x, r, t, σ]]) With[{t0 = 0, tend = 1, σ = 0.8, r = .01, S0 = 100, Κ = 110}, data = RandomFunction[GeometricBrownianMotionProcess[0, σ, S0], {t0, tend, 1/12}, 5000]; c[S0, Κ, r, tend - t0, σ]}] (* 28.1904 *) </code></pre> <p>or, with the built-in <code>FinancialDerivative</code>:</p> <pre><code>With[{t0 = 0, tend = 1, σ = 0.8, r = .01, S0 = 100, Κ = 110}, FinancialDerivative[{"European", "Call"}, {"StrikePrice" -&gt; Κ, "Expiration" -&gt; 1}, {"InterestRate" -&gt; r, "Volatility" -&gt; σ, "CurrentPrice" -&gt; 100, "Dividend" -&gt; 0}] ] (* 28.1904 *) </code></pre>