Message Boards Message Boards

5 Replies
4 Total Likes
View groups...
Share this post:

Intermittent behavior of FinancialData

Posted 10 years ago

The function FinancialData accepts a starting date or a date range. Both are giving me intermittent failures, as seen below. When I execute the input below it gives me data perhaps 90% of the time, but for about 1 in 10, I get the error below. This occurs with other stocks as well, and with other date ranges, including those derived from DateList[]. It's making it quite difficult to produce a notebook which is guaranteed to execute.

Any ideas?

FinancialData["GE", {2011, 1, 1}];

FinancialData::notdate: {2011,1,1} is not a valid date range for FinancialData. >>
POSTED BY: David Keith
5 Replies

As long as historical quotes of a stock or index in available in Yahoo Finance, we can use following function to get financial data.

Options[YahooFinancialData] := {StartDate -> {0, 0, 0},  EndDate -> {0, 0, 0}, TradingPeriods -> "d"};

YahooFinancialData[id_String, opts : OptionsPattern[]] := 
  {startDate, endDate, tradingPeriods},
  startDate = ToString /@ OptionValue[StartDate];
  endDate = ToString /@ OptionValue[EndDate];
  tradingPeriods = OptionValue[TradingPeriods];
   "" <>
    id <>
    "&a=" <>
    startDate[[2]] <>
    "&b=" <>
    startDate[[3]] <>
    "&c=" <>
    startDate[[1]] <>
    "&d=" <>
    endDate[[2]] <>
    "&e=" <>
    endDate[[3]] <>
    "&f=" <>
    endDate[[1]] <>
    "&g=" <>

For more information on how to use the function please check the attached notebook.


FinancialData is basically a wrapper for Yahoo Finance's API and a couple of others. It's possible this might be caused by some issue with their API.

Instead of

FinancialData["GE", {2011, 1, 1}]

try evaluating:


Does this work? If not, then Yahoo's Finance API is down for some reason.

There are other ways of getting financial data into Mathematica. One is via the WolframAlpha function:

Or you can use the EntityFramework. Hit "Ctrl + = " and type something like "GE closing prices since 2011"


It shows you what code you'd use for this task:

the resulting code

In copyable code that's:

EntityValue[Entity["Financial", "NYSE:GE"], EntityProperty["Financial", "Close", {"Date" -> Interval[{DateObject[{2011}], DateObject["today"]}]}]]
POSTED BY: Sean Clarke

I don't think so. I don't have any problems with kernels or evaluation. It is just FinancialData function which sometimes works fine and sometimes gives the following error.

FinancialData::notdate: {2011,1,1} is not a valid date range for FinancialData.

POSTED BY: Kianoosh Kassiri

I am having the same exact problem. FinancialData has become unreliable recently.

POSTED BY: Kianoosh Kassiri
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
or Discard

Group Abstract Group Abstract