The full code for the stock analysis exercise is available as a GitHub repo at https:// github.com/modern-fortran/stock-prices. If you use git, you can clone it directly from the command line:
git clone https://github.com/modern-fortran/stock-prices
Otherwise, you can download it as a zip file from http://mng.bz/OMZo.
The repository already includes the stock price data needed for this exercise in the data directory. However, if this exercise leaves you hungry for more in-depth analysis or larger stock price datasets, there’s an easy way to get more data.
To download the stock data in CSV format for this exercise, I used the free service Alpha Vantage (https://www.alphavantage.co), which provides an HTTP API to obtain data in JSON or CSV format. You’ll need to register for the API key at their website. Once you have one, you can make your own API requests to get various stock data. For an example, see the download script that I used to download the daily data for this exercise in data/get_data.sh.
Cloning the repository (or downloading the zip file) will also get you the complete code that implements the three data analysis challenges. We’ll implement them step-by-step in the following sections, so if you want to follow along, defer reading the final code until the end of this chapter.