# Forecast Future Stock Prices - Brownian Motion [closed]

Hi I have some questions: Could anyone of you suggest me some literature or tutorial or similar stuff concerning financial modelling in Mathematica?

I found the Wolfram Finance Platform where I downloaded the notebooks and watched the videos. I tried to start and replicate the first notebook with the title “Wolfram Finance Platform: Quick Start” , which can be accessed under the following link: http://www.wolfram.com/training/videos/FIN021/

Everything went well, however when I tried to replicate the chapter “Forecast Future Stock Prices – Brownian Motion” I had one major problem concerning the most interesting part for me. The Problem started on page 9 of the presentation.

I entered the following code:

BrownianMotion[period_,"steps_Integer: 1000,init_: 0]:=Accumulate[Prepend[RandomVariate[NormalDistribution[0,Sqrt[period⁄steps]],steps],init]]
ListLinePlot[BrownianMotion[1,1000],AxesLabel→{"Time","Bt"}]

BrownianMotionPaths[period_,steps_Integer: 1000,paths_Integer,init_List]/;(Length[init]==paths):=
Transpose[Accumulate[Prepend
[RandomVariate[NormalDistribution[0,Sqrt[period⁄steps]],{steps,paths}],init]]]

brownianPaths=ListLinePlot[BrownianMotionPaths[1,1000,50,ConstantArray[0.5,50]],AxesLabel→{"Time" ,"Bt" }]

GOOGExpRet=Mean[FinancialData["GOOG" ,"Return" ,DatePlus[-365],"Value" ]]
GOOGPrice=FinancialData["GOOG" ]
GOOGVol=FinancialData["GOOG" ,"Volatility50Day" ]

ListLinePlot[GOOGPrice*(1+GOOGExpRetConstantArray[1,251]+BrownianMotion[1,250]*GOOGVol),AxesLabel→{"Time" ,"St" },PlotLabel→Style["Simulated Google Price" ]]


So far everything went well and I was able to simulate a single path.

HOWEVER, now the problem started when I began to simulate multiple paths. Thereby, I entered the following code:

ListLinePlot[GOOGPrice*(1+GOOGExpRetConstantArray[1,{50,251}]+BrownianMotionPaths[1,250,50]*GOOGVol),AxesLabel→{"Time","St"},PlotLabel→Style["Simulated Google Price"]]


The result was just an empty coordinate system. I even copied and pasted the same code as the author of the presentation did and in his presentation it is working and when I try it, I only get again the empty coordinate system.

Can anybody of you please tell me what the problem is, and suggest me a solution? I just want to forecast stock prices using Brownian Motion and simulating multiple paths within one chart and then calculate the average? I would be very thankful if anybody can help me, modify the code or suggest me another possible way to generate multiple stock price forecasts? Is there maybe the possibility that the author of this code made a mistake? Could anyone of you please also try to replicate his codes and compare them with my code if its working?

I am also looking for an experienced Mathematica user with financial background who could give me some advice or even lessons via skype, of course against payment. So is anyone of you interested to give me some advice or may be additional lessons in financial modelling with Mathematica?

-

## closed as too localized by Sjoerd C. de Vries, whuber, Yves Klett, rm -rf♦May 22 '13 at 15:22

This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, visit the help center.If this question can be reworded to fit the rules in the help center, please edit the question.

You could have a look at the docs. –  b.gatessucks May 22 '13 at 13:04
See: mathematica.stackexchange.com/questions/8267/… Also, MathEstate.com, brilliant. Its authors know Mma & have more original insights than anything you'll find in conventional financial engineering. Its hard to find anything on financial engineering that doesn't start & end with unfounded assumptions whether the authors know Mathematica or not. So stick with basics: Taleb's "Dynamic Hedging", his best book by far. Mandelbrot's, "Misbehavior of Markets" Brown's "Poker Face of Wall Street" & "Red Blooded Risk". Thorp's "Beat the Market". –  Jagra May 22 '13 at 13:14
I don't believe the last part of your question, which boils down to a job advertisement is allowed here. –  Sjoerd C. de Vries May 22 '13 at 13:19
More important than any of the above: John Kelly's seminal 1956 paper "A New Interpretation of Information Rate" indispensable. Still amazing how so few in financial engineering know of it. Thorp, who invented Black Scholes long before Black and Scholes did and also invented Delta hedging (arguably the 1st quantitative approach) relied completely on Kelly as do PIMCO, Brown, and all frequentist oriented quantitative strategies. –  Jagra May 22 '13 at 13:22
The code here mathematica.stackexchange.com/a/3148/66 allows you to simulate stocks and correlated stocks. You can inspire yourself from it for other related models. –  Faysal Aberkane May 22 '13 at 13:25

You've made just a bunch of typos and/or copying errors. I found a spurious quote character in the first line, arrows with the wrong character code in some options, and the same for two division slashes. You also used the wrong number of arguments in the second BrownianMotionPaths call and omitted the space indicating the multiplication of two variables on two occasions. Given this rather specific situation I will be voting to close the question as "Too Localized".

Below, you'll find the corrected code:

BrownianMotion[period_, steps_Integer: 1000, init_: 0] :=
Accumulate[
Prepend[RandomVariate[NormalDistribution[0, Sqrt[period/steps]],
steps], init]]

ListLinePlot[BrownianMotion[1, 1000], AxesLabel -> {"Time", "Bt"}]

BrownianMotionPaths[period_, steps_Integer: 1000, paths_Integer,
init_List] /; (Length[init] == paths) :=
Transpose[Accumulate[Prepend
[RandomVariate[
NormalDistribution[0, Sqrt[period/steps]], {steps, paths}],
init]]]

brownianPaths =
ListLinePlot[
BrownianMotionPaths[1, 1000, 50, ConstantArray[0.5, 50]],
AxesLabel -> {"Time" , "Bt" }]

GOOGExpRet =
Mean[FinancialData["GOOG" , "Return" , DatePlus[-365], "Value" ]]
GOOGPrice = FinancialData["GOOG" ]
GOOGVol = FinancialData["GOOG" , "Volatility50Day" ]

ListLinePlot[
GOOGPrice*(1 + GOOGExpRet ConstantArray[1, 251] +
BrownianMotion[1, 250]*GOOGVol), AxesLabel -> {"Time" , "St" },
PlotLabel -> Style["Simulated Google Price" ]]

ListLinePlot[
GOOGPrice*(1 + GOOGExpRet ConstantArray[1, {50, 251}] +
BrownianMotionPaths[1, 250, 50, ConstantArray[0.5, 50]]*GOOGVol),
AxesLabel -> {"Time", "St"},

@MilanIvica As to your first comment: I feel you should avoid copying any code whatsoever into Word. You'll never know what it does with your code. It may do auto-replacements (like -> into arrow characters) insert smart quotes or whatever. If you want to copy Mathematica code into another text-processor (but why would you want that?) use an ASCII editor like Notepad. Also, if you want to copy code to copy to StackExchange do a "copy as input text" or convert your cells to InputForm. In your case, I got some clues from the syntax coloring and from error messages after the cell-by-cell ... –  Sjoerd C. de Vries May 23 '13 at 18:16