das_Urmel
das_Urmel

Reputation: 23

How to skip warnings in a loop [wolfram-mathematica]

My goal is to read in data on all the available stocks at NASDAQ using FinancialData[], and do some computations on it. The problem is (I already contacted the support because of this and it is a known problem), that if I use

Slist = FinancialData["NASDAQ:*", "Lookup"];

to readin all available ticker symbols and then

Dlist = FinancialData[#] & /@ Slist;

to download the current price at the market, this does not work for all entries because of errors in the database and mathematica gives several warnings along the lines of:

NASDAQ:AAMALX is not a known entity, class, or tag for FinancialData.  
Use FinancialData[] for a list of entities.

Since this cannot be helped, I would now like to find a way to only read in the working entries and skip the ones with the warning. Although I did already quite some research on possible functions that would allow for this (for example in a for loop), I couldn't come up with a solution.

Even a short hint on the direction that I have to look, would already be very helpful. I am using Mathematica 10 on a Mac.

Upvotes: 2

Views: 171

Answers (1)

Chris Degnen
Chris Degnen

Reputation: 8680

Use Quiet to suppress the warning messages, then select number cases.

Slist = FinancialData["NASDAQ:*", "Lookup"];
Dlist = Cases[Quiet[{#, FinancialData[#]} & /@ Slist], {_, _?NumberQ}]

Upvotes: 1

Related Questions