Message Boards Message Boards

0
|
4823 Views
|
2 Replies
|
1 Total Likes
View groups...
Share
Share this post:

Unexpected results from FinancialData[ ]?

Posted 3 years ago

Clearly I must have made a mistake, the S&P500 did not gain 150% in 2016. So what did I do wrong, or is the data in FinancialData in error???

From the internet -- gains of the S&P500 by year

enter image description here

Table constructed from Mathematica

enter image description here

My code

rus3RtnYr = FinancialData["IWV", "Return", {{2010}, {2021}, "Year"}];
rus2RtnYr = FinancialData["IWN", "Return", {{2010}, {2021}, "Year"}];
spxRtnYr = FinancialData["SPX", "Return", {{2010}, {2021}, "Year"}];
djRtnYr = FinancialData["^DJI", "Return", {{2010}, {2021}, "Year"}];

Grid[Prepend[
  Transpose[{Map[
     DateString[DateList[#], {"MonthName", " ", "Year"}] &, 
     Flatten[rus3RtnYr[[2, 2]]]], 
    Map[PaddedForm[#, {2, 1}] &, Flatten[rus3RtnYr[[2, 1]]]], 
    Map[PaddedForm[#, {2, 1}] &, Flatten[rus2RtnYr[[2, 1]]]], 
    Map[PaddedForm[#, {2, 1}] &, Flatten[spxRtnYr[[2, 1]]]], 
    Map[PaddedForm[#, {2, 1}] &, Flatten[djRtnYr[[2, 1]]]]}], {"Date",
    "Russell 3000", "Russell 2000", "S&P500", "DJIA"}], 
 Background -> {None, {LightRed[.3], {White, 
     Lighter[Blend[{Blue, Green}], .8]}}}, 
 Dividers -> {{Darker[Gray, .6], {Lighter[Gray, .5]}, 
    Darker[Gray, .6]}, {Darker[Gray, .6], Darker[Gray, .6], {False}, 
    Darker[Gray, .6]}}, Alignment -> {{Center, Center, Center}}, 
 ItemSize -> {{9, 8, 8, 8, 8}}, Frame -> Darker[Gray, .6], 
 ItemStyle -> 14, Spacings -> {.3, .8}]
POSTED BY: Raymond Low
2 Replies
Posted 3 years ago

Sorry Rohit, you nailed it -- typo with SPX, should be ^SPX, I checked three times because I didn't want to waste anyone's time.
The resource I used was -- but missed the carrot

enter image description here

The new Table is

enter image description here

Although Mathematica averages 2.5% less than the first list I found on the internet, I checked another site and Mathematica was within .25% of that site so the data does not seem to be an issue. My apologized for the typo.

POSTED BY: Raymond Low
Posted 3 years ago

Rather than guessing names based on what they sound like

FinancialData["SPX", "Company"] // CompanyData[#, "Website"] &
(* https://www.spx.com *)

FinancialData["SP500", "Name"]
(* "S&P 500 Index" *)
POSTED BY: Rohit Namjoshi
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract