Working with Real-Time Data and Sockets

ZeroMQ is a lightweight, fast, and scalable socket programming library. ZeroMQ supports different patterns for socket communication. One of those patterns is the so-called publisher-subscriber (PUB-SUB) pattern where a single socket publishes data and multiple sockets simultaneously retrieve the data. Running a Simple Tick Data Server Euler discretisation of geometric Brownian motion S is the…

Building Classes for Event-Based Backtesting

Potential shortcomings of the approach are the following: Look-ahead bias Vectorised backtesting is based on the complete data set available and does not take into account that new data arrives incrementally. Simplification For example, fixed transaction costs cannot be modelled by vectorisation, which is mainly based on relative returns. Also, fixed amounts per trade or…

Predicting Market Movements with Machine Learning

Using Linear Regression for Market Movement Prediction Using logistic regression to predict market direction Without considering transaction costs Consider the same strategy applied to the GDX ETF, for which an out-of-sample outperformance (over the year 2018) Taking transaction costs into account Using deep learning for market movement prediction The simple classification problem revisited “MLP” stands…

Zipline and PyFolio

Zipline and PyFolio abstract away the complexities of the backtesting and performance/risk analysis aspects of algorithmic trading strategies. Backtesting should include all relevant factors, such as slippage and trading costs. Zipline is one of the most advanced open source Python libraries for algorithmic trading backtesting engines. PyFolio is an open-source Python performance and risk analysis…

Financial Market Data Access in Python

Exploring the yahoofinancials Python library The yahoofinancials Python library provides free access to the market data available from Yahoo Finance, whose provider is ICE Data Services. It provides access to historical and, for most assets, also real-time pricing data for the following: Single-ticker retrieval Convert the nested JSON to a pandas’ DataFrame Real-time data retrieval…

Statistical Estimation, Inference, and Prediction

Four key statistical libraries in Python statsmodels is a Python library to explore data, perform statistical tests, and estimate statistical models Normal distribution test with Q-Q plots While there are many robust statistical tests for normal distributions, an intuitive visual method is known as a quantile-quantile plot (Q-Q plot). If a sample is normally distributed,…