Thanks to “Rod Lm” I got some very nice input for the following problem.
My intention is to simulate within a Manipulate
function a given number of possible stock price paths and to calculate their mean. So, if something is manipulated the “new mean” is also calculated automatically and both are shown by a line and numerically within the chart. I would also like to know how I can also calculate the mean outside the chart. I tried the following but it didn't work:
Mean[Table[
RandomFunction[
GeometricBrownianMotionProcess[0.1, 0.2, 100], {0, 250, 0.05}][
"Path"], {20}][[All, -1]]]
The next step -if possible- is to introduce a lower boundary. So for example if the initial stock price is 100 then the boundary could be at, let’s say, 70. First, I want the boundary to be shown by a line. Second, I would like to stop all stochastic processes that fall below this threshold and then receiving the mean from all remaining processes.
Alternatively, if it’s not possible to stop the processes that fall below the threshold, I also just want the mean of the remaining processes that are beyond the threshold. Third, I also would like to have a manipulable threshold. So, in short, I want to be able to switch the threshold between 20 and 90 and then receive the mean of the processes that remain beyond this boundary.
Is something like that possible? If yes, I would be really thankful if I would receive some suggestions how to solve my problem, or at least parts of it. So far I have done the following and is it even possible to modify this code in such a manner that my problem can be solved?
My code so far:
Manipulate[
SeedRandom[seed];
ListLogPlot[
Table[RandomFunction[
GeometricBrownianMotionProcess[μ,σ,S0], {0, 250, 0.05}]["Path"], {P}],
Joined -> True,
AxesLabel -> {"Time", "St"},
PlotLabel -> Style["Forecasted Stock Price\n (Brownian Motion)", Bold],
PlotRange -> All,
ImageSize -> 500,
PlotStyle -> Directive[{Thin, Lighter@Gray}]
],
{{S0, 100, "Initial Stock Value"}, 100, 500, 0.05, Appearance -> "Labeled"},
{{μ, 0.01, "Drift μ"}, 0.01, 1, 0.05, Appearance -> "Labeled"},
{{σ, 0.01, "Standard Deviation σ"}, 0.01, 1, 0.05, Appearance -> "Labeled"},
{{P, 1, "Paths"}, 1, 100, 1, Appearance -> "Labeled"},
{{seed, 77777, "New Random Case"}, 10000, 999999, 1},
Button["Set Initial Values", {S0 = 25, μ = 0.01, σ = 0.01}, ImageSize -> 150],
ControlPlacement -> Left]
S_0
doesn't look correct to me. You can't use an underscore (=Blank
) in a variable name. $\endgroup$