TL;DR – Decided to build an automated email newsletter to track the stock market and show pre-market data and historical performance of S&P 500, Nasdaq, and Dow Jones to help with my investments.
Checking my email is one of the first things I do when I wake up, in a quick scan I know if there’s something important I should pay attention to, I read the news, and I take the time to keep my inbox tidy. Email is a central tool in my daily workflow.
One thing I like to do is to subscribe to email newsletters mostly about tech like Techmeme, Ruby Weekly, Hacker News, Node Weekly and news from WSJ, Morning Brew and NYT, I signup to a bunch all the time but I’m very diligent only to keep those I’ll read.
Email has a bad rep, spam, clutter. Still, for me, it’s such a joy to receive a well-crafted email where people took the time to write something worthwhile and even more time to package that in a beautiful clean design especially in a finicky medium like email with dozens of different clients all rendering things slightly different from one another.
Being stranded at home living the “quarantine” life and with some time in my hands, I thought about building something, and my requirements were:
- It needs to be something I can finish in over a week tops
- Any service I use should be free or freemium
- Needs to be fully automated, no interventions after it’s running
- Needs to be something useful to me
Watching the markets tank in March was brutal. The stock market was so volatile that it was hard to keep up with its ups and downs, so my idea was to build something around that.
When you read the news or listen to podcasts about the topic they always talk about when the market open or close in terms of points like the Nasdaq composite closed down 300 points to 7500 or something like that, that’s useful for someone in finance or more versed in the markets. Still, to me, all I want to know is how much percentage it gained or lost in a given period like the day before, a week ago, six months ago, and with that, I can tell how the market is trending.
Another thing that I learned some time ago is related to Stock futures, also called pre-market, and that gives you a good indication if the market is trending up or down for the day before it opens for business.
Going back to email and the tweet from Jason Fried, I decided to build an email newsletter with information about the stock markets and data I cared about including:
- Pre-market data for major indexes Nasdaq, S&P 500 e Dow Jones
- Historical performance represented in percentage points
The idea is for the mailing list to go out every weekday before the market opens so you can be informed enough to decide if it’s worth paying close attention to the market on any given day and make some moves.
With that in mind, I started with some good old research to figure out what I need to build this thing.
- API to get stock market futures
- API that returns historical data for major indexes
- Email marketing tool with API support
- Design UI for the newsletter
- Service to track errors and notify via email
- A way to schedule and send the emails every day
- A website so people can sign up
- Write code to put everything together
- Ship it 🚀
I’ve spent the first day or two signing up and playing with finance APIs and email marketing tools until I found one that did what I want and offered a freemium option. I ended up landing on Sendgrid for email and
Alpha Vantage Yahoo Finance undocumented API for stock market data.
It’s incredible the amount of work it takes to build even the simplest thing, besides writing code which is the fun part there are a ton of other tedious admin tasks that need to be done and configured to make everything work like:
- Find a name
- Buy and set up a domain
- Create and redirect email like firstname.lastname@example.org
- Validate email and domain on Sendgrid
- Setup Google Analytics and Google search console
- Create Gravatar and Google account to have a profile pic in the email
- Setup DNS pointing to Github to host the website
Probably finding a name and available domain to register takes the longest in most of my side projects, and it’s the first thing I do contrary to what most people would say. I enjoy playing with names, and finding the one that feels right to me gets me psyched and in the right frame of mind to work on the project.
Some of the names I’ve considered:
- Buy high sell low
- Buy the dip
- Bull or bear
- Mr. Market
The name that resonated the most with me was Bullish▲, I guess because it’s timely related to the end of one of the longest US bull markets in history, and I’ve found the perfect domain available for the small fortune of $3.88, and that’s how https://bullish.email happened.
If there’s one cool thing about tech nowadays is that pretty much everyone offers a free version of something. You can play with any cloud provider and use it gratis forever as long you are within their free tier. You can publish a site on GitHub for free, including SSL, also free; and a bunch of other stuff. It’s awesome!
Anyway, back to the project, after I hooked everything together and spent an awful lot of time designing the email in Sendgrid plus a couple more days writing trash code to test things out and then rewriting it again the proper way, I’ve finally got to a working version that was up to my standards.
The last thing to do was to decide how to schedule the code to run, prepare, and trigger Sendgrid to send emails every morning. My first choice was to go serverless with Lambda that would fit nicely and wouldn’t cost a dime, but then I realized I have a Raspberry Pi laying around, so why not use that instead?
So I’ve set up the Raspberry Pi to run a Cron job every day around 9:00 AM eastern time, which is 30 minutes before the market opens and I’ve also used a nifty little app called Cronhub to monitor the job and alert me if it doesn’t run, and that was it. A little over a week’s worth of work and that nice runner’s high kind of feeling of getting another project across the finish line.
Stay healthy. Cheers ~