Peregrine is a Google App Engine app that fetches Australian share prices and save them to Google Sheets.
This project is part of 52projects and the new stuff that I learn through this project: pygsheets and yahoo-finance.
I read a blog post in February about using Google Spreadsheets as a database. I got excited since a spreadsheet also acts as an easy to use user-interface for our app. Motivated by this, I started to investigate gspread that was mentioned in the blog post. Unfortunately, it relies on the old API. Further research brought me to pygsheets that uses the current Google Sheets API (v4).
Peregrine utilises a cron job that runs every hour from 10:00 am to 4:00 pm (the time that the Australian Stock Exchange open for trading) to fetch share prices and save them to a Google Sheets document.
The main user interface is through a spreadsheet document as shown below. This document is shared with a Google service account (fiftytwo-peregrine) that makes hourly edits.
The app is implemented by one main file: fetch.py that is invoked by a GAE cron job service every hour to retrieve share prices, process them, and save them to Google Sheets. The share prices are retrieved using a Python library that talks to Yahoo! Finance.
Please note that before running or deploying this application, install the dependencies using pip:
pip install -t lib -r requirements.txt
Depending on the use cases, I think a spreadsheet is a good alternative to a database. A spreadsheet offers a familiar user interface to many people. Plus with get the benefit of mobile accessibility through Google iOS / Android apps. The yahoo-finance library is quite easy to use. With pygsheets, sometimes I encountered memory issues on GAE instances where the process exceeded the default 128 MB memory limit. It could be because the library loads up the whole spreadsheet onto memory, but I can't be sure of the exact cause.
