Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

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?

share|improve this question

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
1  
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

1 Answer 1

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"}, 
 PlotLabel -> Style["Simulated Google Price"]]
share|improve this answer
    
Hi, thank you a lot for your help. I really appreciate your help. –  Milan Ivica May 22 '13 at 14:25
    
I have one more question: How can I avoid such mistakes when I copy and paste the codes? I am asking because, when I copy the code first into word in order to see where a space is and where not, the code is in the form of a formula. Do you know who I can avoid it? And how did you see that I made these copy and paste mistakes? Thank you –  Milan Ivica May 23 '13 at 12:33
    
Hi, excuse me, I think I have herea technical problem with Mathematica I am still not very experienced but when I copied your code and entered it, it worked perfectly. when I reopened Wolfram Finance Platform Quickstart Notebook, and tried to work further in a new notebook. Again it didn’t work. And when I opened the notebook with the code you sent me, and refreshed it, also the one that worked perfectly didn’t work anymore. Could it be that Mathenatica cannot differ between the two notebook, although they weren’t open at the same time? Or what could be the problem? Thank you for your help. –  Milan Ivica May 23 '13 at 13:46
    
@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
    
... execution of your code. As to Notebooks influence each other": yes, that happens by default. Notebooks usually share the same context and variables defined in one and changed in the other will be effected in both. If you don't want that, change the Notebook's default context in the Evaluation menu. –  Sjoerd C. de Vries May 23 '13 at 18:19

Not the answer you're looking for? Browse other questions tagged or ask your own question.