Yahoo Finance Quote Download Summary

June 6, 2017

Overview

As a final post about the new Yahoo Finance quote download page and how to access the historical data I thought to offer a bit of a summary.

The four previous posts with examples for Bash, Python, Java and Clojure are available at the following urls. Please visit them if you have just arrived at this post without seeing them. At the very least, read the beginning of the first one for more details on the issue with the new Yahoo Finance download data page and the technique to call it programmatically.

Bash

Creating a Bash script to solve a problem is something every developer should be able to do. The Unix Philosophy of build modular functional components and connecting them together is a very powerful technique and well worth becoming comfortable with. To be successful though you must know a number of the available Unix commands. For our script here, prior knowledge of curl, tr, cut, grep and sed was necessary.

In practice the building of a Bash script could be considered a first step. Depending on what you eventually will need you may leave the script as a proof of concept as you add on layers of production requirements. Also, if you start building a number of scripts I suggest you always try to modularize them and start building libraries to share functions. If you get in the habit of building large scripts from active cut and paste sessions you'll eventually have a difficult situation to manage.

Python

If you look at the Python example soon after the Bash script you might think things look a bit cleaner. I'll say that. You'll notice I built the Python script up as a collection of small functions. This technique allows for an iterative development cycle in the repl where each function is carefully constructed and tested individually. Note, that this technique is also heavily used in the creation of Clojure programs. You'll see that later. For now, though realize that another Python developer who fashioned themselves as an object oriented one would have create an entirely different application.

If I was to continue with the Python script I'd share the same advice just given for Bash in that carefully consider moving useful functions to libraries so they are easily used for other applications. Other than that I'd find the Python example to be a good first step and one that could be used to grow with.

Java

It shouldn't be a big surprise to anyone who knows all of these languages that the Java example is the longest. Even though it relies on the HttpClient library to do most of the heavy lifting it still is longer. Also, the application has a blocky-ness to it compared to the small function smoothness of the Python example (ditto with Clojure). When developing with Java you'll get the feeling you are putting together Legos. Once bolted up it will work and you probably won't want to change it. Also, while doing the assembling you'll not have the same level of interactive development and will rely on much more granular tests. In fact, you'll essentially run things from the top with printlns to very each step.

If you are in a Java shop and you are required to use Java then you'd be set to start with the Java example.

Clojure

The last example in Clojure presents a newer language to some. For those, Clojure is a Lisp that runs on top of the JVM. This give you the nice looking syntax and the functional approach mentioned previously. It also lets you dip into the Java ecosystem if you want giving you a best of all worlds feeling. For me, the iterative development cycle of working in the repl is the best.

The Clojure program is shorter and easier to read than the Java example. Notice, also that the Clojure program relies on the same HttpClient library but it does so from a Clojure library which wraps the Java library. This practice makes things simpler and as such easier to maintain.

Summation

Some things to consider.

  • The Bash script is the clunkiest. With the right experience it can be developed quickly but will overtime cause maintenance grieve. I'd use it for a prototype but if pressed would defer to a Python replacement
  • The Python script is more elegant than the Bash script and if there was a choice I'd vote to have 'scripty' things done in Python. Notice I didn't build an OO app. That's my preference. You can do otherwise.
  • The Java class is also clunky but more robust. With the right scaffolding it could be made bullet proof. If this is what you want then you are set. If you are open minded I'd suggest the Clojure alternative but would understand if you were set in your ways.
  • The Clojure version is my favorite but I am biased.

Repos

Hope this was interesting and please leave comments.


Tags: clojure bash yahoo java quotes trading python