The main change is that FinancialData now returns a TimeSeries object.
I haven't touched Mathematica 10,11 and 12, learning 13 on Wolfram Cloud
right now. Mathematica has changed a lot!!
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(* 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}] | |