7 Handling time-series data and missing values

 

This chapter covers

  • Fetching data by using HTTP queries
  • Parsing JSON data
  • Working with dates
  • Handling missing values
  • Plotting data with missing values
  • Interpolating missing values

This is the last chapter of part 1, which focuses on the Julia language. A motivating use case for the topics that we will cover in this chapter is working with financial asset prices. Imagine you want to analyze how the price of a certain stock or the exchange rate between two currencies evolves over time. To be able to handle these questions in Julia, you need to know how to work with time-series data. A frequent feature of real-life temporal data is that it contains missing data for some timestamps. Therefore, the second major topic of this chapter is handling missing values in Julia.

The problem we tackle in this chapter is analyzing the PLN/USD exchange rate that is published by the National Bank of Poland (NBP). The data is made available via a Web API, which is described at https://api.nbp.pl/en.html.

We will perform our task via the following steps:

  1. Understand the format of the data that the Web API exposes.
  2. Fetch the data by using HTTP GET requests for a specified range of dates.
  3. Handle errors when the requested data is not available.
  4. Extract the PLN/USD exchange rate from the obtained result of the query.
  5. Perform simple statistical analysis of the fetched data.
  6. Plot the fetched data with a proper handling of missing values.

7.1 Understanding the NBP Web API

7.1.1 Getting the data via a web browser

7.1.2 Getting the data by using Julia

7.1.3 Handling cases when an NBP Web API query fails

7.2 Working with missing data in Julia

7.2.1 Definition of the missing value

7.2.2 Working with missing values