Public
Edited
Jul 19, 2024
Importers
8 stars
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
`${baseUrl}/v10/finance/quoteSummary/${SYMBOL}?modules=${modules.join(",")}`
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
GetNews = async (symbol)=>{
return JSON.parse((await (await soFetch(`https://api.rss2json.com/v1/api.json?rss_url=http://feeds.finance.yahoo.com/rss/2.0/headline?s=${symbol}&region=US&lang=en-US`)).text())).items}
Insert cell
Insert cell
GetPeers('AIG')
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
JSON.parse(await (await soFetch(example_price_data)).text())
Insert cell
Insert cell
Insert cell
Insert cell
IntradayDataFetcher("AIG")
Insert cell
Insert cell
YahooQuoteFetcher (SYMBOL,'1d', 1558756800, 9999999999)
Insert cell
YahooChartDataFetcher = (symbol, interval, period1, period2)=> YahooQuoteFetcher(symbol,interval,period1,period2)
Insert cell
(await GetHistoricalData("AIG","1Y")).chartData
Insert cell
GetHistoricalData = async (symbol, range) => {
let d = new Date(Date.now());

if (range === '1Y') {
d.setMonth(d.getMonth() - 12);
Math.floor(d.getTime() / 1000);
}

return await YahooQuoteFetcher(
symbol,
"1d",
Math.floor(d.getTime() / 1000),
Date.now()
);
}
Insert cell
HistoricalData = (symbol, range) => {
let d = new Date(Date.now());

if (range === '1y') {
d.setMonth(d.getMonth() - 12);
Math.floor(d.getTime() / 1000);
}

YahooQuoteFetcher(symbol, "1d", Math.floor(d.getTime() / 1000), Date.now());
}
Insert cell
YahooQuoteFetcher("AIG", "1d", 0, 9999999999)
Insert cell
YahooQuoteFetcher = async (symbol, range, p1, p2) => {
let fetched = await (
await soFetch(
`https://cors-anywhere.herokuapp.com/query1.finance.yahoo.com/v8/finance/chart/?symbol=${symbol}&period1=${p1}&period2=${p2}&interval=${range}`
)
).text();

let parsedJson = JSON.parse(fetched);
// return parsedJson;
let chartData = extractChartData(parsedJson);
//cors-anywhere.herokuapp.com/
let quote = JSON.parse(
await (
await soFetch(
`https://cors-anywhere.herokuapp.com/query1.finance.yahoo.com/v7/finance/quote?symbols=${symbol}`
)
).text()
);

return {
quote: quote.quoteResponse.result[0],
chartData: chartData
};
}
Insert cell
Insert cell
(
await soFetch(
`${baseUrl}/v8/finance/chart/?symbol=${SYMBOL}&period1=0&period2=999999999&interval=${INTERVAL}`
)
).text()
Insert cell
Insert cell
Insert cell
test_fetch_july_option_series = JSON.parse(await getOptionSeries("AIG",1562284800))
Insert cell
test_fetch_option_chain = (await OptionChainFetcher("AIG")).map(x=>x.optionChain.result[0])
Insert cell
Insert cell
JSON.parse(await getOptionSeries("AIG", 1565308800))
Insert cell
Insert cell
getOptionSeries = async (symbol, expirationDate = null) => {
return await (
await soFetch(create_option_series_url(symbol, expirationDate))
).text();
}
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
TopETFs = async () =>
JSON.parse(
await (
await soFetch(
`${baseUrl}/v1/finance/screener/predefined/saved?formatted=false&lang=en-US&region=US&scrIds=top_etfs_us&count=250`
)
).text()
).finance.result[0]
Insert cell
TopMutualFunds = async () =>
JSON.parse(
await (
await soFetch(
`${baseUrl}/v1/finance/screener/predefined/saved?formatted=false&lang=enUS&region=US&scrIds=top_mutual_funds&count=5`
)
).text()
).finance.result[0]
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
spark_data_fetcher(["AIG"])
Insert cell
Type JavaScript, then Shift-Enter. Ctrl-space for more options. Arrow ↑/↓ to switch modes.

Insert cell
Insert cell
largest_company = "AAPL"
Insert cell
Insert cell
Insert cell
{
let d =new Date(Date.now());
d.setMonth(d.getMonth() - 3);
return Math.floor(d.getTime()/1000)
}
Insert cell
Insert cell
Insert cell
Type JavaScript, then Shift-Enter. Ctrl-space for more options. Arrow ↑/↓ to switch modes.

Insert cell
Insert cell
baseUrl = "https://cors-anywhere.herokuapp.com/query1.finance.yahoo.com"
Insert cell
soFetch = fetch // import { soFetch } from '@alecglassford/so-fetch'
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell

Purpose-built for displays of data

Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Learn more