"QF-Lib is a Python library..for portfolio construction, time series analysis, risk monitoring and diverse charting...An extensive part...is dedicated to backtesting investment strategies."
“QuantStats Python library that performs portfolio profiling, allowing quants and portfolio managers to understand their performance better by providing them with in-depth analytics and risk metrics.”
"Introduction to Option Pricing using Python library quantsbin"..."incorporates tools for pricing and plotting of vanilla option prices, greeks and various other analysis around them."
"Orbit is an open-source Python package [that] provides a range of models for time-series forecasting, including Bayesian Structural Time-Series, Bayesian AutoRegressive Integrated Moving Average, and Bayesian Neural Networks." and
Python code example for "the pairs trading strategy... a market-neutral trading approach that seeks to profit from the relative movements of two or more, AKA stat arb, closely related financial instruments."
Python code: "Factor Investing with Machine Learning": "Construct an equity long/short strategy using a factor model with machine learning estimators."
Github repository "Algorithmic Trading in Python" contains Python code examples for "Algorithmic Trading Fundamentals", "Building A Quantitative Momentum Investing Strategy" and "Building A Quantitative Value Investing Strategy" in Jupyter notebooks.
"findatapy creates an easy to use Python API to download market data from many sources including Quandl, Bloomberg, Yahoo, Google etc. using a unified high level interface. Users can also define their own custom tickers, using configuration files."
Very short "Introduction to Arbitrage Trading Strategies": "[These] strategies typically rely on quantitative analysis and mathematical models...We introduce five popular arbitrage trading strategies."
"Non-linear models such as neural networks and random forests have the ability to capture complex and time-varying relationships between stock characteristics and future returns [and] describe cross-sectional returns with surprising accuracy."
Post: "Forecasting Volatility: Deep Dive into ARCH & GARCH Models" shows a simple application of these methods for financial return time series in Python.
"Using an unsupervised machine learning algorithm to detect different stock market regimes": "A Gaussian Mixture model will be used to detect different moods in the stock market...using price data, and... macro-economical data."
"Q-Fin A Python library for mathematical finance" including bond pricing, option pricing, stochastic processes, simulation pricing, and futures pricing.
"Mean Reversion Strategies": "An introductory overview of mean-reversion strategies [with Python code] delving into key concepts that underpin such approaches."
Brief instruction: "Make your own [proxy] VIX [in Python] for quite literally any stock with an options chain...All [you] need to do is track the price of an ATM delta-neutral straddle." 🇺🇦
Python library "Lazy Predict helps build a lot of basic models without much code and helps understand which models work better without any parameter tuning". 🇺🇦
"The Wasserstein k-means algorithm...automates the process of classifying market regimes...[and] does not depend on modelling assumptions of the underlying time series...[It] vastly outperforms all considered competitor approaches."
"The Hurst exponent can be used to...detect whether a market is trending, mean-reverting, or just random...There are multiple ways to estimate the Hurst exponent [in Python]." 🇺🇦
All Python data science in one place:
"Awesome data science with Python: A curated list of awesome resources for practicing data science using Python, including not only libraries but also links to tutorials, code snippets, blog posts, and talks."
"Predicting risk/reward ratio in financial markets for asset management using machine learning": "This approach is designed for algorithmic trading, enabling to assess the profitability of each trade and calibrate the optimal trade size."
"Volatility timing...based on high-dimensional models mostly yields higher Sharpe ratios compared with the market...The least absolute shrinkage and selection operator (LASSO) generates the most accurate forecasts, leading to outstanding performance." 🇺🇦
"Correlation Matrix Clustering for Statistical Arbitrage": "We... partition the correlation matrix of market residual returns of stocks into clusters... and evaluate the performance of mean-reverting statistical arbitrage portfolios within each cluster."
Github repository "Machine Learning for Asset Managers" contains "implementation of code snippets and exercises [related to a book] written by Prof. Marcos López de Prado."
"Value at Risk (VaR) and Its Implementation in Python": "A comprehensive understanding of VaR, its importance in risk management, and a practical implementation."
“skfolio is a Python library for portfolio optimization built on top of scikit-learn. It offers a unified interface and tools compatible with scikit-learn to build, fine-tune, and cross-validate portfolio models.”
"With... deep learning models, financial time series forecasting models have advanced significantly... We provide a comprehensive assessment of research from 2020 to 2022 on deep learning models used to predict prices based on financial time series."
"Analysis of Stock Returns using ‘pyfolio’ [Python library]": "A step-by-step tutorial on how...to perform an in-depth analysis of stock returns and comparing them to a benchmark." 🇺🇦
Python package “TSFRESH extracts 100s of features from time series that describe basic characteristics…such as the number of peaks... or more complex features such as the time-reversal symmetry statistic.”
"We show theoretically and empirically that flows into index funds raise the prices of large stocks in the index disproportionately more than the prices of small stocks...Flows predict a high future return of the small-minus-large index portfolio."
"AutoTrader is a Python-based platform [for] the development, optimization, and deployment of automated trading systems...from simple indicator-based strategies to complex non-directional hedging strategies."
Python tutorial: "The Probabilistic Sharpe Ratio incorporates skewness and kurtosis into its formulation... Combinations of skewness and kurtosis in returns distribution do impact the standard deviation of the Sharpe Ratio estimate."
"A Simple Method for Predicting Covariance Matrices of Financial Returns": "We propose a relatively simple [model] that requires little or no tuning or fitting, is interpretable [and] outperforms MGARCH in terms of regret."
"Advanced Statistical Arbitrage with Reinforcement Learning": "For mean reversion spreads, we establish an empirical reversion time metric and optimize asset coefficients by minimizing this empirical mean reversion time."
"Non-linear correlation analysis in financial markets using hierarchical clustering": "The distance correlation coefficient...is capable of detecting nonlinear associations that are undetectable by the classical Pearson correlation coefficient." 🇺🇦
"Empyrial is a Python-based open-source quantitative investment library dedicated to portfolio management [combining] risk analysis, quantitative analysis, fundamental analysis, factor analysis, and prediction making."
"Top 6 Volatility Indicators in Python": "End-to-end Implementation with buy and sell signals. Indicators include Keltner Channels, Relative Volatility Index, and more."
"A volatility-managed portfolio, which reduces selling of volatility assets during periods of heightened volatility, considerably enhances long-run performance. Our findings are robust across three types of volatility assets - variance swaps, VIX futures, and S&P 500 straddles."…
"The Ignored Effect of Options on Liquidity": "options have a monumental, forgotten impact on liquidity and markets — that only a few sophisticated market participants are aware of." 🇺🇦
"Trended Momentum": "A stock with a clearer price path signals a clearer continuation trend compared to those with erratic, volatile paths... A distinct price trend significantly enhances the momentum strategy."
"Factor Momentum in Commodity Futures Markets": "A commodity factor’s past returns positively predict its future returns [with] sizable economic profits."
Python code: "The Chicago Fed National Activity Index has an amazing track record at predicting recessions... By plotting three series, we can get a great handle on the current state of the economy."
Github repo: "Stock Analysis for Quants" contains some helpful code on the very basics of "data analysis, technical analysis, fundamental analysis, quantitative analysis, and different types of trading strategies."
"Options market makers' delta hedging has a growing impact on underlying stock prices... We [use] real-time options information to calculate the spot elasticity of delta and expected hedging demand."
"Modelling Extreme Stock Market Events With Copulas in Python": "Copulas capture the dependence structure between random variables without altering their individual behaviors."
"We propose a method to detect linear and nonlinear lead-lag relationships in stock returns... to rank the assets from leaders to followers [and construct] a lead-lag portfolio."
"Pairs trading...is based on statistical concepts like mean reversion and stationary stochastic processes...The key challenges are to find a good pair for trading, optimal entry/exit and a stop loss as...risk management." Example with Python code:
Detecting trends and mean reversion with the Hurst exponent:
The Hurst exponent is a statistical measure of long-term memory of time series. Financial asset and portfolio returns are not generally governed by random walks. 🇺🇦
"Option Momentum": "We find strong momentum patterns in the returns of straddle and strangle strategies, with the formation period spanning one to three years."
"Maximizing Portfolio Predictability with Machine Learning": "Portfolios that take advantage of... predictability of returns and employ a Kelly criterion style strategy consistently outperform the benchmark."
"Hurst Exponent to Identify Trading Strategies": "The Hurst exponent...measures..a financial time series [deviation] from a random walk...[and] the long-term memory of a time series, characterizing it as mean-reverting, trending, or a random walk." 🇺🇦
"[The equity trading] ‘factor zoo’ can be compressed, focusing on explaining the available alpha... About 15 factors are enough to span the entire factor zoo... The selected factor styles remain persistent"
Release: Macrosynergy package 0.1
The standard Python package for working with macro and financial market data in panel form (across countries).
Designed for JPMaQS, but works with all data of that type and free JPMaQS set on
"Principal Component Analysis (PCA)... holds particular importance in finance... where data is voluminous... extracting meaningful patterns, optimizing portfolios, managing risk, and identifying underlying factors."
Optimizing macro trading signals – A practical introduction
Post and Jupyter Notebook show sequential signal optimization based on the scikit-learn package. The focus is on feature selection, return prediction, and market regime classification.
"Extracting information from option implied volatility surfaces for the cross-section of stock returns, using image recognition...delivers a higher Sharpe ratio, and has a significant alpha relative to a battery of standard and option-implied factors."
"We download news headlines and alerts on the front page of Wall Street Journal from 1996 to 2022 and ask ChatGPT-3.5 to [classify] good and bad news... Investors tend to underreact to the positive contents... which leads to significant market predictability"…
"A Data Scientist’s Approach for Algorithmic Trading": "End-to-end tutorial in one Jupyter Notebook: get the data, perform data engineering, train and deploy the Deep Reinforcement Learning agent, place trades, check the portfolio performance."
Regression-based macro trading signals
A little guide on the use of various types of regression in statistical learning to combine economic indicators into trading signals.
"We develop a collaborative machine learning algorithm that optimizes portfolio weights so that the resulting synthetic security is maximally predictable...by wielding a Random Forest...and a constrained Ridge Regression."
"High-Frequency Realized Stochastic Volatility Model": "The volatility of intraday returns is assumed to consist of the autoregressive process, the seasonal component... and the [economic] announcement component."
"Identify Key Market Shifts with the Volatility Ratio": " [It divides] the True Range [based on a day's high and low and the previous close] by its exponential moving average [and] measures the magnitude of price changes in relation to its recent history."
"Optimizing Portfolio Allocation with Hierarchical Risk Parity in Python - Advanced Strategy to Account for Correlations, Risk, and Returns in your Portfolio Leveraging Hierarchical Structures"
"We study probability forecasts [for] cross-sectional asset pricing... A probability forecast model can perform as well as a sophisticated... model... Combining probability forecasts with return forecasts yields superior portfolio performance."
Paper presents "evidence that stock returns, both at the market level and the individual stock level, can be predicted by the timing of uninformed inflows and outflows of cash that are known in advance...[i.e.] aggregate dividend payments."
Classifying market regimes:
Market regimes affect the relevance of investment factors and the success of trading strategies. The challenge is to detect regime changes and to backtest methods. Machine learning offers several approaches.
"Predicting Financial Market Trends using Time Series Analysis and Natural Language Processing": "Our study has revealed a robust association between the emotions conveyed in tweets and fluctuations in stock prices."
"The choice of time intervals in the volatility calculations... captures different aspects of risk... Short-interval volatilities predominantly capture idiosyncratic risk, while longer intervals capture systematic risk."
"We introduce a momentum crash aversion index [showing] a substantial difference in momentum and market returns across high and low crash aversion states."
"LSTM-XGBoost Hybrid Stock Forecasting": "Combinations of Deep Learning models together with Decision trees or Linear Regressions [offers] new ways to extract much more information from raw [data] inputs."
Post and Python code: “Uncovering the value of the Hurst exponent...a statistical measure that can be used to quantify the long-term memory or persistence of a time series...in quantitative finance" 🇺🇦
"The pandas-market-calendars package...provides access to over 50+ unique exchange calendars for global equity and futures markets...with the holiday, late open and early close calendars for specific exchanges and OTC conventions." 🇺🇦
"This paper examines the co-jump transmission in 36 commodity futures returns using co-jump network models... Gold exerts the strongest influence, with many commodity futures being influenced by [its] jumps."