Stock Prices Lab


Overview

Using the Intrinio Financial Data API (application programming interface) we can programmatically retrieve end-of-day OHLC (open, high, low, close) prices for thousands of U.S. company securities (stocks) which are actively traded on major exchanges such as NASDAQ and NYSE.

We will use the Get Security Stock Prices API end-point to retrieve stock prices throughout this lab.

In this lab we will cover:

  • Retrieving stock prices for Apple Inc. (AAPL) using Python or R
  • Retrieving stock prices for several companies
  • Charting stock prices

Code Examples

Code examples in Python and R are provided throughout this lab.

All code examples can be run in your browser using a Jupter Notebook. To launch the Jupyter Notebook for any code example simply click the Run Jupyter Notebook button at the top of the code example.

If you wish to run the code examples in your own development environment, be sure to first install the Intrino SDK for the language of your choice:

API Keys

In code examples throughout this lab you will be asked to provide your API Key.

The API keys assigned to you are available below.

For the purposes of this lab, be sure to use your Production API key

Production
To view your API keys, click here to log in.

Section 1

Retrieving Stock Prices for Apple Inc.

In this section we'll use the Get Security Stock Prices API end-point to retrieve stock prices for Apple Inc. from January 1st, 2015 through January 1st, 2020.

Run the code below to see the result...

Section 2

Retrieving Stock Prices for Multiple Companies

Now that we've seen how to retrieve stock prices for a single company, let's create an array of multiple companies and retrieve 5 years of stock price data for all of them.

To do so we'll iterate over an array of company tickers, executing a call to Get Security Stock Prices for each company.

The API response for each stock will contain Open, High, Low and Close pricing data - along with split-adjusted versions of those values. Here, we are interested in the Adjusted Close Prices for each stock.

We'll process the API responses for each company to extract all Adjusted Close Prices , storing them in a new object called 'adjusted_close_price_data'.

Run the code below to see the result...

Section 3

Graphing Stock Prices for multiple companies

Building on our previous work, now let's graph the adjusted close prices for all of our companies.

Run the code below to see the result...

Going further...
  • Daily open, high, low, and close prices are all important when technically analyzing a stock's price.
    Can you create a graph representing all of these values for Apple Inc. over the past 90 days?
    Remember to use the split-adjusted values!
  • In many cases we need to retrieve the most current stock prices for an entire exchange - can you use the
    Stock Prices by Exchange API end-point to retrieve all stock prices for NASDAQ and NYSE?
    (hint: use the USCOMP exchange identifier)