Tag Info

Hot answers tagged

18

Most of the financial modeling/Mathematica books I've seen are intended to (1) provide theorical insights and Mathematica based tools to price "exotic" derivatives, and/or (2) to show how to use Mathematica to develop derivative trading strategies. Very helpful for experienced quants. Not the best way to learn about investing. Successful investing ...


17

I own a copy of Modelling Financial Derivatives with Mathematica by William Shaw. I think it was a ground-breaking book for its time. However, here are some issues you should be aware of: It was published in 1998 and is based on Mathematica version 3. We are now at 8, anticipating 9. Much of the graphics code he uses is now obsolete (eg Graphics`Graphics). ...


13

Here's a set of functions that allows to do this. The code uses many ideas found on this site and on other places on the web. It is a bit factorized already so it should be easily reusable. More on YQL and available tables here: https://developer.yahoo.com/yql https://github.com/yql Query test Here are usage examples symbol="YHOO"; ...


12

data = FinancialData["SPY", "Jan. 1, 2011"] /. {d_List, v_} :> {AbsoluteTime@d, v}; model = a x^4 + b x^3 + c x^2 + d x + e; fit = FindFit[data, model, {a, b, c, d, e}, x] modelf = Function[{x}, Evaluate[model /. fit]] Plot[modelf[x], {x, Min@data[[All, 1]], Max@data[[All, 1]]}, Epilog -> Map[Point, data]] Edit Better (tick labels showing dates) ...


11

Well, let me try to answer the OP's question. And thanks MMA.SE, for reopening this interesting question! DATA To answer this question, you have to get the data using Mathematica's FinancialData function. This was the only thing originally done by the OP! First step: define which stocks will be included in the portfolio: Portfolio = {"AAPL", "BA", ...


9

Maybe this question will be closed again. Anyway I'll try to answer the question not correcting the original code, but using a new one with some basic explanations... First of all, you can basically divide stocks in two big groups: growth stocks and value stocks. This is important, because the way you simulate growth stocks is completely different from that ...


9

I just wrote a book on financial engineering that uses Mathematica heavily. The publisher (World Scientific) says it should be available for purchase within a week or two. I have taught risk management and asset pricing and derivatives with these materials for the past few years at NYU-Poly. The point of the book is precisely to do lots of projects, the ...


9

If one looks for curated data accessible from Mathematica, the WolframAlpha function should always be considered as an option, because it links to curated data bases with frequent continuous updating: data = WolframAlpha["^DJI price history", {{"HistoryDaily:Close:FinancialData", 1}, "TimeSeriesData"}, PodStates -> ...


9

I implemented this function using YQL: acquireOptions[stock_String, expiration_, type_] := Module[{options, list, data}, options = Cases[Import[ "http://query.yahooapis.com/v1/public/yql?q=SELECT%20*%20FROM%20yahoo.finance.option_chain%20WHERE%20symbol%3D'" <> stock <> "'%20AND%20expiration%3D'" <> expiration <> ...


8

I'm not sure if I correctly understood what you want... However, I could read in the question that you want to simulate Ito Processes and, at the same time, to be able to change its parameters, especially the processes drifts and volatilities. In the comments I've read about the processes being correlated, so, let me try to put everything together in this ...


7

Although I have found ItoProcess an excellent tool in nearly all cases, in those situations where a correlation matrix is supplied to it ItoProcess incorrectly uses the Cholesky decomposition of the correlation matrix when it should actually be using the transpose of the Cholesky. Note that I discovered this bug back in December 2012 when I was looking at ...


7

The reason might be gleaned from examining the output from TracePrint. DateDifference["Jan 2, 2013", "Jan 8, 2013", "Week"] // TracePrint (* Warning Huge Output *) Somewhere close to the end of this humongous output we see the following: DataPaclets`CalendarDataDump`n:Except[_Integer] :> N[DataPaclets`CalendarDataDump`n] 6/7 /. ...


6

I've done a lot of option pricing with MMA, but I can't relate your code to plain old Black-Scholes: d1[spot_,strike_,ir_,div_,vol_, T_] = (Log[spot/strike] + (ir-div+vol^2/2) T) / (vol T^0.5]); d2[spot_,strike_,ir_,div_,vol_, T_] = (Log[spot/strike] + (ir-div-vol^2/2) T) / (vol T^0.5]); N[z_] = (1 + Erf[z/Sqrt[2]])/2 ; (*cumulative normal density*) ...


6

For your first question you can look at the customer stories in finance and analytics. You might also be interested in the recordings from the Wolfram Finance Platform virtual workshop.


6

Here are some links I collected in my answer to the post Where can I find examples of good Mathematica programming practice?. The first link exposes quite well the new functionalities of Mathematica in this field. Finance (some CUDA examples also) http://www.wolfram.com/events/chicago2011/nVidiaFinancePresentation.nb High-Performance Computing in ...


6

You can suppress those functionalities with PerformanceGoal: chart = TradingChart[data, {FinancialIndicator["AverageDirectionalMovementIndex", 7]}, Appearance -> "Line", PerformanceGoal :> "Speed"] and proceed further with Cases to extract what you need: Cases[chart, _Graphics, ∞] Cases[Cases[chart, _Graphics, ∞][[3]], Line[x_, ...


5

NTDOY is the Nasdaq ticker for the Nintendo ADR. Once it's traded on an American stock exchange you don't need to define the stock exchange previously (i.e., you don't need to use PK: before the NTDOY ticker). So, the only thing you have to do is to use FinancialData["NTDOY"] and Mathematica will retrieve the current price: 11.79 EDITED You have ...


5

Well, I think this solves your question: Manipulate[SeedRandom[seed]; meanvector := Mean[assets]; assets = Table[RandomFunction[GeometricBrownianMotionProcess[μ, σ, S0], {0, time, 0.1}]["Path"], {P}]; processes = Transpose[assets[[#]]][[2]] & /@ Range@Length[assets]; processesposition=Flatten[Position[Min[processes[[#]]]&/@Range@Length[assets], _?(# ...


5

The More Information section of the help file says The coupon may be specified as a single rate or a time-dependent payment function. So, you should use "Coupon" -> (Piecewise[{{.04125, #1 < 3}, {.06, 3 <= #1 < 5}, {.0775, 5 <= #1 < 7}}] &) For example, FinancialBond[{"FaceValue"->100, "Coupon" -> ...


5

The question is a little broad. In my shop, we routinely use Mathematica for risk analysis and portfolio reporting, also for hypothesis testing and a variety of other front-office tasks. We have a master library of functions that we have created for these purposes over the last six years or so, and we also created the MathematicaLinkToBloomberg package that ...


5

Appearance->"Line" option setting gives line graphs: TradingChart[{"GOOG", {{2010, 1, 1}, {2010, 6, 1}}}, {"Open", "Low", "High", "Volume"}, Appearance -> "Line"] You can also use ChartElementFunction->"Line": TradingChart[{"GOOG", {{2010, 1, 1}, {2010, 6, 1}}}, {"Open", "Low", "High"}, ChartElementFunction -> "Line"] By the way, ...


5

You can get exchange rates from the Federal Reserve using their data download package maker at:- http://www.federalreserve.gov/datadownload/ See the link for Exchange Rates and International Data. The package maker produces a download link that can be used as shown. startdate = "12/31/1995"; enddate = DateString[{"Month", "/", "Day", "/", "Year"}]; ...


4

Unless I'm mistaken, FinancialBond is a function that returns values given parameters. It isn't similar to those objects returned by the likes of NonlinearModelFit, that have internal data and methods. Coupon dates can be found using, for instance, the following: matDate = {2020, 12, 31}; faceValue = 1000; couponRate = 0.07; cDates = Rest@NestWhileList[ ...


4

A bit puzzling, but I think you have problems with the levels in ListLogPlot (where you added another set of values), and with the PlotStyle directives (where you added options to a Directive). I changed a few things quasi-randomly and got something which I think is closer to what you want. Manipulate[ SeedRandom[seed]; Column[{ test2[μ_, σ_, S_, P_] ...


4

portf = {"AAPL", "BA", "IBM", "BMW.DE", "DIS", "R", "PEP", "BRBY.L", "AXP", "BTI"}; prices = FinancialData[#, "Price", {{2004}, {2011}, "Month"}] & /@ portf; Returns are often calculated as the difference of the logarithms of the prices: Differences[Log@#] &[prices[[1, All, 2]]] This works because ...


4

1. You can also use all FinancialIndicator[...] functions directly on data: data = FinancialData["IBM", "OHLCV", {{2013, 12, 31}, {2014, 3, 31}}]; admi = FinancialIndicator["AverageDirectionalMovementIndex", 7][data] (* {22.3186, 25.4227, 27.7113, 30.474, 34.1408, 38.1074, 41.6553, 44.6964, 47.9435, 51.9707, 55.5629, 55.1122, 52.5314, 45.1471, 38.9678, ...


4

It's all in the Documentation Center: By convention, yield to maturity and coupon specifications are assumed to be nominal with a compounding interval equal to the coupon payment interval. By using the EffectiveInterest function or a functional interest rate specification, any desired compounding can be achieved. (...) FinancialBond takes a ...


3

To correctly compute the mean, try this: Manipulate[SeedRandom[seed]; meanvector := Mean[assets]; assets = Table[RandomFunction[GeometricBrownianMotionProcess[μ, σ, S0], {0, time, 0.1}]["Path"], {P}]; G1 := ListLogPlot[assets, GridLines -> {{}, {watermark}}, GridLinesStyle -> Directive[Green, Thick], Joined -> True, AxesLabel -> {"Time", "St"}, ...


3

You can do this: bas = FinancialData["MSFT", {DatePlus[Date[], -365], Date[]}, "Value"] (* Here bas is defined as the time-series of prices for Microsoft (ticker: MSFT) *) Now you can compute the log-returns: Differences[Log[bas]]



Only top voted, non community-wiki answers of a minimum length are eligible