This repository contains a set of example functions for educational purposes, demonstrating how to use the Google Apps Script UrlFetchApp
class to integrate financial metrics from Yahoo Finance into Google Sheets. These functions are intended to serve as illustrative examples, providing a basic framework for fetching real-time financial data for personal learning and exploration.
getPrice(ticker)
: Demonstrates fetching the current stock price for a specified ticker.getMarketCap(ticker)
: Shows how to retrieve the market capitalization of a stock.getBeta(ticker)
: Retrieves beta.getPER(ticker)
: Retrieves Price to Earnings (P/E) ratio.YFgrowth(ticker)
: Retrieves five-year growth rate.getThirdFinColValue(ticker)
: Extracts a specific value from a stock's balance sheet as an example.extractGrossMargin(ticker)
: Scrapes the gross margin percentage.duplicateSheet()
: Example function to duplicate a specified sheet within the same spreadsheet, useful for data backup.
These functions utilize the Google Apps Script UrlFetchApp
class to make HTTP requests to Yahoo Finance's web pages and parse the returned HTML for specific financial data. They are designed to be copied into a Google Apps Script project linked to a Google Sheet for direct application and experimentation.
- Open the Google Sheet you wish to experiment with.
- Go to
Extensions > Apps Script
, and start a new script project. - Copy and paste the example functions into the script editor.
- Save the script project with a meaningful name.
- In your Google Sheet, call the functions within cells using the syntax
=FunctionName("Ticker")
, replacingFunctionName
with any of the provided examples and"Ticker"
with a valid stock ticker symbol.
- These example functions employ the
UrlFetchApp
class, documented here, for educational purposes. - As illustrative examples, they may require modifications to work with current Yahoo Finance web page structures or to meet specific educational objectives.
- This set of functions is intended for personal learning and should not be used for commercial purposes without understanding the implications, including adherence to Yahoo Finance's terms of service.
These functions are provided as-is for educational purposes to demonstrate coding practices and techniques with Google Apps Script. They are not intended for real-world financial analysis or investment decisions. Users should exercise caution and verify all data independently.
This README clarifies the intent and usage of the Google Sheets Yahoo Finance Example Functions, highlighting their educational purpose and guiding users on how to experiment with them for personal learning.
This README was generated with JavaScript Code Streamliner (https://chat.openai.com/g/g-cwBADUbq0-javascript-code-streamliner).