yahoo-finance-api icon indicating copy to clipboard operation
yahoo-finance-api copied to clipboard

getQuotes with a invalid symbol

Open glaucoheitor opened this issue 3 years ago • 2 comments

When using $client->getQuotes($symbols), if one of the symbols is invalid or Yahoo don't have information about, the class will just skip it, so if I sent an array with 20 elements, I may get a return with only 18 elements.

I would like to suggest one of this options as a solution:

  • Make the resulted array have keys instead of an index only, maybe the symbol as a key
  • Instead of skipping it, it could add a new array element with an error message for that symbol

I'm not sure if I expressed myself well enough, but if not, please send me questions so I can clarify.

Thanks!

glaucoheitor avatar May 14 '21 04:05 glaucoheitor

Yea, understood. Would definitly make sense to get some better support from the library when dealing with these multi-fetch requests. Right now it's just transforming the data from the API and the API skips unknown symbols. I agree it would be great to have a more convenient way to figure out if the result was complete and what's missing.

scheb avatar May 14 '21 11:05 scheb

This was also an issue for me but what I ended up doing is just calling the "getSymbol()" function on the returned quote to validate what stock ticker the result was referring to.

eversionsystems avatar Dec 26 '21 11:12 eversionsystems