This scheduled script is designed to retrieve stock data using the yfinance library and write it into a Google Spreadsheet using the Google Sheets API. The script also help with spreadsheet maintenance by removing unused tabs.
Use the package manager pip to install the required Python packages.
pip install -r requirements.txt
-
Follow the guide on the Google Sheets API documentation to create a GCP project
-
Enable the Google Sheets API
-
Generate the required credentials file
-
Rename the credentials file to keys.json and place it in the project's root directory.
-
Open the Google Spreadsheet where you want to write the stock data. Copy the spreadsheet's ID from the URL and store it in a sp_id.txt file in the project's root directory.
-
Create a sheet named config and write the tickers of the stocks to track in column A