Created
August 25, 2023 19:03
-
-
Save alexb4a/e98a71b030ca26d2ae5bdf6654dc1c1e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sp500CompaniesAsJSON from 'sp500-companies-as-json'; | |
import yahooFinance from 'yahoo-finance2'; | |
async function run(){ | |
const companies = await sp500CompaniesAsJSON(); | |
let counter = 0; | |
for (let i = 0; i < companies.length; i ++){ | |
counter ++; | |
console.log("Consulting company " + companies[i].ticker + " (" + counter + " of " + companies.length + ")"); | |
const queryOptions = { modules: ['price', 'summaryDetail', 'recommendationTrend'] }; // defaults | |
const quoteSummary = await yahooFinance.quoteSummary(companies[i].ticker, queryOptions); | |
if (quoteSummary) { | |
console.log(JSON.stringify(quoteSummary)); | |
} | |
} | |
} | |
run(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment