Chapter 7. Working with Real-Time Data and Sockets

If you want to find the secrets of the universe, think in terms of energy, frequency, and vibration.

Nikola Tesla

Developing trading ideas and backtesting them is a rather asynchronous and non-critical process during which there are multiple steps that might or might not be repeated, during which no capital is at stake, and during which performance and speed are not the most important requirements. Turning to the markets to deploy a trading strategy changes the rules considerably. Data arrives in real time and usually in massive amounts, making a real-time processing of the data and the real-time decision making based on the streaming data a necessity. This chapter is about working with real-time data for which sockets are in general the technological tool of choice. In this context, here are a few words on central technical terms:

Network socket

Endpoint of a connection in a computer network, also simply socket for short.

Socket address

Combination of an Internet Protocol (IP) address and a port number.

Socket protocol

A protocol defining and handling the socket communication, like the Transfer Control Protocol (TCP).

Socket pair

Combination of a local and a remote socket that communicate with each other.

Socket API

The application programming interface allowing for the controlling of sockets and their communication.

This chapter focuses on the use of ZeroMQ as a lightweight, fast, and scalable socket programming ...

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.