Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(Error: Failed to download data) after trying to run this program in a loop #84

Open
destroyer22719 opened this issue Sep 6, 2021 · 1 comment

Comments

@destroyer22719
Copy link

destroyer22719 commented Sep 6, 2021

Error: Failed to download data (404 - {"quoteSummary":{"result":null,"error":{"code":"Not Found","description":"No fundamentals data found for any of the summaryTypes=summaryDetail,financialData,defaultKeyStatistics,summaryProfile"}}})
    at /home/nathan/Downloads/Code_Projects/investing/node_modules/yahoo-finance/lib/quote.js:146:15
    at tryCatcher (/home/nathan/Downloads/Code_Projects/investing/node_modules/bluebird/js/release/util.js:16:23)
    at Promise._settlePromiseFromHandler (/home/nathan/Downloads/Code_Projects/investing/node_modules/bluebird/js/release/promise.js:547:31)
    at Promise._settlePromise (/home/nathan/Downloads/Code_Projects/investing/node_modules/bluebird/js/release/promise.js:604:18)
    at Promise._settlePromise0 (/home/nathan/Downloads/Code_Projects/investing/node_modules/bluebird/js/release/promise.js:649:10)
    at Promise._settlePromises (/home/nathan/Downloads/Code_Projects/investing/node_modules/bluebird/js/release/promise.js:725:18)
    at _drainQueueStep (/home/nathan/Downloads/Code_Projects/investing/node_modules/bluebird/js/release/async.js:93:12)
    at _drainQueue (/home/nathan/Downloads/Code_Projects/investing/node_modules/bluebird/js/release/async.js:86:9)
    at Async._drainQueues (/home/nathan/Downloads/Code_Projects/investing/node_modules/bluebird/js/release/async.js:102:5)
    at Immediate.Async.drainQueues [as _onImmediate] (/home/nathan/Downloads/Code_Projects/investing/node_modules/bluebird/js/release/async.js:15:14)
    at processImmediate (internal/timers.js:456:21)

My code:

const getData = async (name, symbol, loc) => {
    try {
        const data = await yahooFinance.quote({
            symbol,
            modules: [
                "summaryDetail",
                "defaultKeyStatistics",
                "financialData",
                "summaryProfile",
            ],
        });

       return data

     } catch (err) {
        console.log(err)
    }
};

...

for (const stock of rows) {
   const data = await getData(stock.symbol)
  console.log(data)
}

That above isn't exactly my code but more or less what it is.

@gadicc
Copy link
Collaborator

gadicc commented Sep 7, 2021

Hey @destroyer22719. This error is because you're asking for data that doesn't exist for one of the symbols you're fetching in your loop. You should wrap the call in a try...catch and then I guess then try loop over each individual module type (also in a try...catch) if you want to get the max amount of information possible).

I have a feeling in v2 (see the README) the errors are more descriptive and it will be easier to tell which symbols are generating these errors.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants