Jan 11, 2022

Code update: Stock Market Performance in January

This is a simple code update for Stock Market Performance in January, it is tested with the free Wolfram Cloud

The main change is that FinancialData now returns a TimeSeries object.
(* https://mathgis.blogspot.com/2022/01/code-update-stock-market-performance-in.html *)
cc[stock_, year_] := FinancialData[stock, {{year, 1, 1}, {year, 1, 31}}]
data=Association[#->cc["SP500",#]&/@Range[2002,2021]];
lineColor [values_]:=If[Last[values]-First[values]>=0,Green,Red]
a=DateListPlot[data[#],PlotStyle->lineColor[data[#]["Values"]],PlotTheme->"Marketing",PlotLabel->#] &/@Range[2002,2021];
Labeled[Grid[Partition[a,5],Frame->All],{"SPY January Performance (2002-2021)","Red -- lose, Green -- gain at the end of January"},{Top,Bottom}]
view raw gistfile1.nb hosted with ❤ by GitHub
I haven't touched Mathematica 10,11 and 12, learning 13 on Wolfram Cloud right now. Mathematica has changed a lot!!