Skip to Content
Python for Finance
book

Python for Finance

by Yves Hilpisch
December 2014
Intermediate to advanced
606 pages
13h 46m
English
O'Reilly Media, Inc.
Content preview from Python for Finance

Chapter 6. Financial Time Series

The only reason for time is so that everything doesn’t happen at once.

Albert Einstein

One of the most important types of data one encounters in finance are financial time series. This is data indexed by date and/or time. For example, prices of stocks represent financial time series data. Similarly, the USD-EUR exchange rate represents a financial time series; the exchange rate is quoted in brief intervals of time, and a collection of such quotes then is a time series of exchange rates.

There is no financial discipline that gets by without considering time an important factor. This mainly is the same as with physics and other sciences. The major tool to cope with time series data in Python is the library pandas. Wes McKinney, the main author of pandas, started developing the library when working as an analyst at AQR Capital Management, a large hedge fund. It is safe to say that pandas has been designed from the ground up to work with financial time series. As this chapter demonstrates, the main inspiration for the fundamental classes, such as the DataFrame and Series classes, is drawn from the R statistical analysis language, which without doubt has a strength in that kind of modeling and analysis.

The chapter is mainly based on a couple of examples drawn from a financial context. It proceeds along the following lines:

First and second steps
We start exploring the capabilities of pandas by using very simple and small data sets; we then proceed by ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Hands-On Python for Finance

Hands-On Python for Finance

Matthew Macarty

Publisher Resources

ISBN: 9781491945360Errata