Chapter 3. Working with Financial Data

Clearly, data beats algorithms. Without comprehensive data, you tend to get non-comprehensive predictions.

Rob Thomas (2016)

In algorithmic trading, one generally has to deal with four types of data, as illustrated in Table 3-1. Although it simplifies the financial data world, distinguishing data along the pairs historical versus real-time and structured versus unstructured often proves useful in technical settings.

Table 3-1. Types of financial data (examples)
  Structured Unstructured
Historical End-of-day closing prices Financial news articles
Real-time Bid/ask prices for FX Posts on Twitter

This book is mainly concerned with structured data (numerical, tabular data) of both historical and real-time types. This chapter in particular focuses on historical, structured data, like end-of-day closing values for the SAP SE stock traded at the Frankfurt Stock Exchange. However, this category also subsumes intraday data, such as 1-minute-bar data for the Apple, Inc. stock traded at the NASDAQ stock exchange. The processing of real-time, structured data is covered in Chapter 7.

An algorithmic trading project typically starts with a trading idea or hypothesis that needs to be (back)tested based on historical financial data. This is the context for this chapter, the plan for which is as follows. “Reading Financial Data From Different Sources” uses pandas to read data from different file- and web-based sources. “Working with Open Data ...

Get Python for Algorithmic Trading now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.