1. Introduction to the Course
Welcome to the first video of the "Introduction to Time Series Analysis Using Python" course. My name is Rob Reider. I'm an Adjunct Professor in the Math-Finance Master's program at NYU's Courant Institute, where I teach a course on Time Series Analysis. I'm also a consultant to a company called Quantopian, which has built a Python-based platform for analyzing and backtesting quantitative trading strategies. Authors of algorithms can enter into paper trading contests and be considered for an allocation of money. Authors receiving allocations are paid 10 percent of the strategy’s net profits, based on their strategy’s individual performance. Also, Quantopian hosts a community where members can ask for help, share ideas, and discuss and share code.
2. Example of Time Series: Google Trends
Time series analysis deals with data that is ordered in time. Of course, there are many other types of data that are not covered in this course - for example, cross-sectional data that are taken at one point in time.
Time series come up in many contexts. Here is a time series of the frequency of Google searches for the word "diet" over a five year period. You can see an interesting pattern: it hits a low around the holidays, and then spikes up at the beginning of the year when people make New Year's resolutions to lose weight.
3. Example of Time Series: Climate Data
Here is another example of a time series: the average annual temperature in New York City since 1870. Notice that this time series is trending up. Many of the most interesting applications of time series analysis are financial time series. In this course, you will look at a variety of financial time series: stocks, bonds, commodities, even crytpocurrencies like Bitcoin.
4. Example of Time Series: Quarterly Earnings Data
Here is the time series of quarterly earnings for the company H&R Block. H&R Block is in the business of preparing tax returns for customers and selling tax software. The vast majority of their earnings occurs in the quarter that taxes are due. Notice the strong seasonality pattern in the earnings.
5. Example of Multiple Series: Natural Gas and Heating Oil
You will also look at two related series in the last chapter of this course. Here are the prices of two energy commodities, heating oil and natural gas, which move together.
6. Goals of Course
In this course, you will learn about various time series models, fit the data to these models, and use these models to make forecasts of the future.
You will also learn how to use various statistical packages in Python to perform these tasks. Numerous examples will be provided, and I hope that these examples not only demonstrate how to apply these tools, but also address some interesting puzzles, mainly in the field of finance.
7. Some Useful Pandas Tools
In the course of analyzing time series data, you will use several convenient pandas tools for manipulating time series data. These methods will be used repeatedly throughout the course, so we will highlight a few of them now:
to_datetime() is used to convert an index, often read in as a string, into a datetime index.
The plot method of pandas is a quick way to plot data, and if the index has been converted to a datetime object, you can slice the data by year, for example. You will sometimes need to merge or join two DataFrames.
8. Some Useful Pandas Tools
For example, one DataFrame may contain stock prices and another DataFrame may contain bond prices.
Pandas makes it easy to resample data. For example, a DataFrame of daily data can be converted to weekly data with the resample method
9. More pandas Functions
Often, you will want to convert prices to returns, which you can do with the pct_change method. Or if you want differences, you can use the diff method.
You can compute the correlation of two series using the corr method, and the autocorrelation using the autocorr method. You'll learn more about these methods later in this chapter.
10. Let's practice!
Now let's practice using a few of these time series tools.