Quant500 Academy

2. APIs and communication protocols: REST, FIX and WebSocket

Level 13: Connecting to Real Brokers

APIs (Application Programming Interfaces) and communication protocols are the piece that lets two programs talk to each other. They define a set of rules and conventions for building applications and interacting with them. In trading there are three technologies you will run into again and again: REST, FIX and WebSocket.

REST API

REST (Representational State Transfer) is an architecture based on web standards that uses HTTP. It is *stateless* and employs the classic HTTP methods: GET, POST, PUT and DELETE. It is used massively to build interfaces with databases and backend services, and it is the usual way to send orders to a cryptocurrency exchange or to a modern broker.

Its two key ideas are:

In practice, with REST you ask. If you want to know the price, you request it. If you want to know it continuously, you have to request it over and over: that is called *polling*, and it collides head-on with the rate limits every exchange imposes.

FIX API Protocol 4.2

FIX (Financial Information eXchange) is a communication protocol designed specifically for the real-time exchange of information about securities transactions. It is used across the financial industry, above all on trading platforms, to communicate orders and executions.

Its two key ideas are:

FIX is not HTTP. It works with persistent sessions, messages made up of tag-value pairs, and sequence numbers that make it possible to detect and recover lost messages. It is the institutional world's standard, and also the heaviest to implement. Version 4.2 remains very common despite its age, precisely because the entire ecosystem supports it.

WebSocket

WebSocket is a communication protocol that provides *full-duplex* channels over a single TCP connection. It is used in applications that need real-time two-way communication.

Its two key ideas are:

In trading, the typical division is this: WebSocket to receive data, REST to send orders. You subscribe over WebSocket to the order book and to fills, and the server pushes every change to you without your asking; when you decide to trade, you fire off a signed REST request. That combination gives you real-time data without exhausting the rate limits, and a clear, auditable confirmation of every order sent.

The rest of Quant500

What you are learning, applied to the index every day:

The model portfolio, weekly in your inbox

Every Saturday, its week in one minute: how it went, the best and the worst, and which insiders bought with their own money. Plus, the day the model is rebuilt, which stocks come in and which go out. A simulation, not advice. At most one email a week, no ads, no account; one-click unsubscribe. Made by one person: Pol Gracia.

A model portfolio with simulated results, not a personalized recommendation. Your email is used for this only: privacy.

Behind the Academy and the rest of Quant500 there is one person: Pol Gracia Serrahima.