Financial Headline Generator
Posted on July 27, 2023 • 2 minutes • 254 words
Table of contents
https://openbagtwo.github.io/MarketWatch/
I woke up this morning and, as am I am wont to do, was randomly wandering through the SMBC archive when I came across this webcomic from 2020:
I thenthought to myself, “Hey, I bet I could code that pretty easily!”
How does it work?
The two components going into this work were:
- getting market data (is the market up or down on any given day?)
- getting news headlines
I figured the first would be easy and the second would be hard, but the reverse ended up being true, as most Finance APIs I could find were either decommissioned (Google), paid (NASDAQ DataLink) or didn’t contain composite indices (Alpha Vantage). Luckily, not only is Yahoo Finance still around, but there’s even a well-maintained Python package called <code>yfinance</code> that I could use without even creating a developer account!
On the news side, I found this handy list of news media APIs and decided to go with The Guardian . Their documentation was excellent, and their API was extremely easy to use.
If you’d like to get a deeper look at how I combined the two halves, the code, as always, is freely available on GitHub, where you can find the development notebook I used to prototype everything in addition to the script that generates the posts .
The project is licensed under the Affero GPL this time, because if anyone out there wants to serve this ridiculously stupid content, they should be making the source code readily available.