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

quoteCombine for quoteSummary function ? #114

Closed
nicogenz opened this issue Apr 7, 2021 · 3 comments
Closed

quoteCombine for quoteSummary function ? #114

nicogenz opened this issue Apr 7, 2021 · 3 comments

Comments

@nicogenz
Copy link
Contributor

nicogenz commented Apr 7, 2021

Currently its possible to combine multiple quote calls into a single call via quoteCombine, see also QuoteCombine docs.
I was wondering if it would make sense to offer the exact same functionality for the quoteSummary function?

@nicogenz nicogenz changed the title quoteCombine for quoteSummary function quoteCombine for quoteSummary function ? Apr 7, 2021
@advaiyalad
Copy link
Contributor

I don't think so, since the yahoo finance API's endpoint doesn't support multiple symbols at once. The whole point of combining network calls would be lost. What do you think, @gadicc?

@gadicc
Copy link
Owner

gadicc commented Apr 7, 2021

Hey @RoXioTD, thanks for the issue. @PythonCreator27 is correct, quote is I think the only Yahoo API that allows multiple symbols in a single network request. However, I do plan to provide some guidance on how to do best do a number of concurrent requests (even though each one will involve it's own network request).

To get started (this will become part of the docs soon):

const symbols = ['TSLA', 'MSFT', 'AAPL'];

// Will perform one request at a time, one after the other
const data = [];
for (let symbol of symbols)
  data.push(await yahooFinance.quoteSummary(symbol));

// Will perform all requests simultaneously (not great for > ~8 symbols)
const data = Promise.all(symbols.map(symbol => yahooFinance.quoteSummary(symbol)));

Both approaches return an identical result, the only different is that the 2nd method performs all requests at the same time.

You can use something like p-limit to limit the number of simultaneous requests to something like 8 or whatever is appropriate for your network. I'm currently working on baking this in with #76, so you can watch that space. That will make it easier to limit the total concurrent calls across different functions or callbacks, which has the same convenience of quoteCombine - even though it will still be with multiple network requests. You can do it already without a limit but you might choke your connection if you do it with too many requests simultaneously.

Hope that all makes sense and let me know if you have any more questions. The code above is not tested but should be good 😅

@nicogenz
Copy link
Contributor Author

nicogenz commented Apr 7, 2021

@PythonCreator27 @gadicc Thx for your answers and explanantions. Sounds good to me.

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

3 participants