Where does the SqueezeCompass point?

Published on 2021-02-17

SqueezeCompass ranks, filters, and visualises S&P500 stocks based on metrics such as short interest. The project emerges in the wake of the $GME bubble of early 2021. It is an attempt to delve into the fundamentals of a short squeeze by tracking and visualising its indicators, as well as an opportunity to explore Python type annotations and Angular 11.

SqueezeCompass: a grid of S&P500 stocks colour-coded to show information about each.

SqueezeCompass consists of two modules:

  • A Python data fetcher that stores snapshots of the make up of the S&P 500 and key financial data for these constituents on a given day.
  • An Angular application with which to display, filter, and browse the indicators aggregated in the daily snapshot.

Fetching financial data

Data is fetched on a daily basis from Yahoo Finance and stored in a SQLite database using the SQLAlchemy ORM. Written in Python, this section of the project gave me the opportunity to try out Type Annotations. As much as I enjoy the flexibility of Python's duck typing when putting together prototypes, the discipline & consistency encouraged by annotations was refreshing and helped me catch bugs where I tried to munge the wrong figures into a database field.

S&P 500 constituents are rebalanced on a quarterly basis on the third Friday of March, June, September and December. Every time the data fetcher runs it verifies whether the existing list of constituents is stale and, if so, assembles a fresh one. Daily data snapshots are exported to JSON, ready to be ingested by the web app that displays them and makes them interactive.

Bringing indicators to life

This is the first substantial side-project where I have had the pleasure to use modern Angular (11). It is a joy to actively develop in, and is somehow made even better when Bootstrap 5 (in beta at the time of writing) is introduced to the mix. After years writing JavaScript, becoming acquainted with TypeScript has introduced a much-appreciated degree of structure and clarity to my frontend code.

Angular's inbuilt reactivity and event flow handling is particularly suited for a data-rich application such as this one. It provides the perfect building blocks for being able to fluidly toggle between metrics or indicator visualisationS, and to dynamically filter a dataset with no stutter or superfluous reloads.

Turmoil in some sections of the market as a consequence of this frenzy notwithstanding, this has been a great opportunity to – in a short amount of time – try out technologies that had been beckoning for a while.
Give SqueezeCompass a spin (dataset frozen to late February 2021).


Main image made by remixing Bootstrap Icons (MIT license).
Dropcap background: Vine (1873) by William Morris, licensed under CC0.