Thanks for subscribing!

  • Zach Wilkins

Earnings Season

What can you do when the fat cats share just how fat they've gotten to the very folks that helped make them fat? Well, this was the exact question I had! So, I lazily put together some code to pull earnings data from Zacks, S&P 500 info from Wikipedia, and daily Yahoo! Finance metrics.


Speaking frankly, this was fairly difficult to do. Pulling data from Wikipedia is very easy, as they have obvious table elements that are super simple to parse. Zacks was somewhat difficult as the parser did not work for empty tables and there were several to pull from--sales, revenues, EPS. It also needed some extra catch logic to skip when there weren't any data, or data was entered in an irregular format. Yahoo! Finance started out very hard, but was just an issue of not seeing the opportunities in front of me.


Yahoo! Finance is extremely straightforward, but my original technique was to pull directly from the HTML tables. The problem with that is the page loads more as you scroll, which R Studio cannot easily do for me. Instead, Yahoo! offers a .csv download directly accessible within the HTML table. That worked perfectly, because it accepts all filters that you pass it, no scrolling required, and you only need to use one of the most fundamental functions in R: read.csv().


I believe the most difficult part was figuring out a way to determine what the expected earnings are/were for a given stock on a given date, as well as its most recent earnings performance. Using lagging calculations might have been much cleaner, but I didn't think of that until recently. Instead, a custom function was built which goes down every row of the final data, uses that information to find the closest earnings reports for that stock ticker, then adds these new columns to the final dataset. This data is important for knowing what the benchmark is to beat.


The Tableau analysis is not incredibly deep. The munging script mentioned above took a lot of time to get into reasonable shape, so I spent less energy working on the analysis. A few models came out of this trying to predict when exactly to get in and out of trades, but because options chains are harder to track down, it seems that my best bet is to use these findings anecdotally--buy earlier, get more run up before earnings. In some cases, earnings reports will stoke enormous % changes for a stock. This report does a better job looking at those cases at a high-level.




This report works better as a way to see how a stock performed historically. Downloading it, you can look deeper into specific points to see exactly why this might be. Did EPS beat expectations, but drop from last earnings? Did the run-up go so high that a small beat led traders to selloff for profit? Take a look!


You'll probably see more about this in the near future.


18 views0 comments