4

After some poking around, I found how to get the price of the S&P500:

FinancialData["^SPX"]` and `FinancialData["^SPX", "Company"]

However, I am trying to illustrate the calculation of betas, so I need historical prices, but putting past dates (for example FinancialData["^SPX", DateObject[DatePlus[Today, -90]]]) gives Missing[NotAvailable]. My workaround has been to use an index fund instead, but I would strongly prefer doing this the right way. Any ideas about how to get historical data for the S&P500 with FinancialData[ ]?

By the way I did consult these answers, but

WolframAlpha["s&p500 prices from 10/23/2015 to 10/22/2016",{"DateRangeSpecified:Last:FinancialData"}]

does not produce a TimeSeries list. And, yes, I know that if I was connected to Bloomberg, then an interface exists, I am not.

Nicholas G
  • 1,981
  • 10
  • 15

1 Answers1

4

Try using Entity to feed FinancialData:

ts = TimeSeries[FinancialData[EntityClass["Financial", "SP500"], {{2016, 1, 1}, Today}]]

DateListPlot[ts]

Mathematica graphics

kale
  • 10,922
  • 1
  • 32
  • 69
  • 1
    Using "SP500" instead of EntityClass["Financial", "SP500"] returns the same data. – Karsten7 Oct 24 '16 at 05:50
  • 1
    The symbol "^GSPC" also returns the same data. – Karsten7 Oct 24 '16 at 05:57
  • Thanks all. Wrapping in TimeSeries[ ] would not produce a list that I could then use to calculate and graph relations with stocks. But it turns out that FinancialData["SP500", {{2014, 10, 23}, {2016, 10, 22}}] worked just fine. How could I have found the correct symbol string? I searched for all symbols containing SP with FinancialData["*SP*", "Lookup"] but it did not produce SP500. – Nicholas G Oct 24 '16 at 13:08
  • @Karsten7. This is my feeble attempt to use the Entity framework which is still almost indecipherable to me. :) – kale Oct 24 '16 at 13:48