Quant Mashup How to Fill Gaps in Large Stock Data Universes Using tidyr and dplyr [Robot Wealth]When you’re working with large universes of stock data you’ll come across a lot of challenges: Stocks pay dividends and other distributions that have to be accounted for. Stocks are subject to splits and other corporate actions which also have to be accounted for. New stocks are listed all the(...) Two Centuries of Value and Momentum [Two Centuries Investments]As a quant, I have been obsessed with systematic Value and Momentum since the first day I ran a backtest. Part of me knows that the future for this combo is unlikely to be as good as the past. In my R&D, I moved on to other factors more than a decade ago. But another part of me is still in love(...) Tactically Adjusting Everything in a Financial Crisis? Bad Idea. [Alpha Architect]With the current market conditions and the wild ride we’ve all been on, we’ve pivoted our attention to focus on supplying academic research on responding to a crisis. This article investigates what the appropriate tactical adjustments investors should consider when making changes to their(...) How to develop, test and optimize a trading strategy - complete guide [Milton FMR]Developing a trading strategy from start to finish is a complex process. The process follows the following steps: Formulation of the strategy Write Pseudo Code Transform into working code Start first backtests Optimize Evaluate test results Go live Monitor performance Evaluate and adjust(...) Tactical ETFs: Tactfully No, Thank You? [Factor Research]Tactical investing aims to deliver better risk-adjusted returns and/or reduced drawdowns Tactical ETFs have not achieved either objective in recent years It is challenging to explain the consistent underperformance across different types of tactical ETFs INTRODUCTION Every investor is a tactician,(...) Find Cheap Options for Effective Crash Protection Using Crash Regressions [Robot Wealth]One way we can quantify a stock’s movement relative to the market index is by calculating its “beta” to the market. To calculate the beta of MSFT to SPY (for example) we: calculate daily MSFT returns and daily SPY returns align the returns with one another regress MSFT returns against SPY(...) Defensive Equity with Machine Learning [Flirting with Models]Defensive equity strategies are comprised of stocks that lose less than the market during bear markets while keeping up with the market during a bull market. Coarse sorts on metrics such as volatility, beta, value, and momentum lead to diversified portfolios but have mixed results in terms of their(...) Long-Short vs Long-Only Implementation of Equity Factors [Quantpedia]How should be equity factor strategies implemented? In a long-only (smart beta) way? As a long-short strategy, as most of the hedge funds usually do? Or in a partially-hedged fashion by going long equity factor and shorting market to offset some of the market risks? There is no one universal answer(...) Rolling and Expanding Windows For Dummies [Robot Wealth]In today’s article, we are going to take a look at rolling and expanding windows. By the end of the post, you will be able to answer these questions: What is a rolling window? What is an expanding window? Why are they useful? What is a Rolling or Expanding window? Here is a normal window. We use(...) Joint predictability of FX and bond returns [SR SV]When macroeconomic conditions change rational inattention and cognitive frictions plausibly prevent markets from adjusting expectations for futures interest rates immediately and fully. This is an instance of information inefficiency. The resulting forecast errors give rise to joint predictability(...) Research Review | 22 May 2020 | Tail Risk [Capital Spectator]The Law of Regression to the Tail: How to Mitigate COVID-19, Climate Change, and Other Catastrophic Risks Bent Flyvbjerg (University of Oxford) 13 May 2020 Regression to the mean is nice and reliable, regression to the tail is reliably scary. We live in the age of regression to the tail. It is only(...) Speaking to Legends: New Podcast from The Team at The Quant Conference (@TheQuantConf) [Speaking to Legends]Speaking to Legends is a quest for ideas, insights, and stories from the lives of the most successful hedge fund managers. We learn about their spectacular careers, we share life lessons and dissect their investment techniques. Join us for this journey. Handling a Large Universe of Stock Price Data in R: Profiling with profvis [Robot Wealth]Recently, we wrote about calculating mean rolling pairwise correlations between the constituent stocks of an ETF. The tidyverse tools dplyr and slider solve this somewhat painful data wrangling operation about as elegantly and intuitively as possible. Why did you want to do that? We’re building a(...) VADER Sentiment Analysis in Algorithmic Trading [Quant Insti]In Finance and Trading, a large amount of data is generated every day. This data comes in the form of News, Scheduled Economic releases, employment figures, etc. It is clear that the news has a great impact on the prices of stocks. Every trader takes great efforts in keeping track of the latest news(...) An Improved Volume Profile Chart with Levels [Dekalog Blog]Without much ado, here is the code ## Copyright (C) 2020 dekalog ## ## This program is free software: you can redistribute it and/or modify it ## under the terms of the GNU General Public License as published by ## the Free Software Foundation, either version 3 of the License, or ## (at your option)(...) How to Wrangle JSON Data in R with jsonlite, purr and dplyr [Robot Wealth]Working with modern APIs you will often have to wrangle with data in JSON format. This article presents some tools and recipes for working with JSON data with R in the tidyverse. We’ll use purrr::map functions to extract and transform our JSON data. And we’ll provide intuitive examples of the(...) A Big Gap Up That Wipes Out A Big Loss Yesterday [Quantifiable Edges]After closing down more than 1% yesterday, SPY is set to open up enough to erase all of yesterday’s losses. I decided to look back at other times this has happened. SPY Big Gap Up Erases Yesterdays Loss - Open to Close Results Not exactly a consistent edge, but I thought the general upside(...) Probabilistic Sharpe Ratio [Quant Dare]Can a Sharpe ratio of 1.55 be better than a Sharpe ratio of 1.63 in a 1 year track-record? Not necessarily. Sharpe ratios are not comparable, unless we control the skewness and kurtosis of the returns. In this post we are going to analyze the advantages of the Probabilistic Sharpe Ratio exposed by(...) Implied risk premia [OSM]In our last post, we applied machine learning to the Capital Aset Pricing Model (CAPM) to try to predict future returns for the S&P 500. This analysis was part of our overall project to analyze the various methods to set return expectations when seeking to build a satisfactory portfolio. Others(...) Prospect Theory Helps Explain Return Anomalies [Alpha Architect]The field of behavioral finance provides us with fascinating insights into individual investor behavior, including how individuals view risk, as well as the impact of those views on asset prices. Prospect theory plays a major role in explaining investor behavior. The theory, formulated in 1979 by(...) Using Digital Signal Processing in Quantitative Trading Strategies [Robot Wealth]In this post, we look at tools and functions from the field of digital signal processing. Can these tools be useful to us as quantitative traders? What’s a Digital Signal? A digital signal is a representation of physical phenomena created by sampling that phenomena at discrete time intervals. If(...) Trend Following the S&P 500? Some Practical Advice [Alpha Architect]Now that market volatility is back, tail risk management strategies are gaining some attention. A lot of investors are dipping their toe into the water and exploring trend-following strategies on the S&P 500 — arguably the most popular U.S. stock market index.This paper explores multiple trend(...) Periodically Rebalanced Static Allocation 'Buy and Hold' Strategies in QSTrader [Quant Start]For those systematic traders who are considering a long-term investment horizon one of the most common forms of generating a portfolio involves static proportional capital allocation amongst a collection of (hopefully) diversifying asset classes, which is periodically rebalanced to maintain the(...) Profiling S&P 500 Drawdowns Since 1871 [Capital Spectator]Longer is better for analyzing the stock market, which is why Professor Robert Shiller’s data set (with an 1871 starting date) is one of the great free resources on the internet for studying the history of US equities. With that in mind, let’s review how the current drawdown for the S&P 500(...) A Volume Profile With Levels Chart [Dekalog Blog]Just a quick post to illustrate the latest of my ongoing chart iterations which combines a levels chart, as I have recently been posting about, but with the addition of a refined methodology of creating the horizontal histograms to more clearly represent the volumes over distinct periods. The main(...) Adding a 1-Day Lag When Executing TAA Strategies [Allocate Smartly]We track 50+ public Tactical Asset Allocation (TAA) strategies in near real-time, allowing us to draw broad conclusions about TAA as a trading style. By design, most of those strategies trade just once per month, and most assume that next month’s asset allocation is both calculated and executed on(...) How to Calculate Rolling Pairwise Correlations in the Tidyverse [Robot Wealth]How might we calculate rolling correlations between constituents of an ETF, given a dataframe of prices? For problems like this, the tidyverse really shines. There are a number of ways to solve this problem … read on for our solution, and let us know if you’d approach it differently! First, we(...) Cheap vs Expensive Factors [Factor Research]This research note was originally published at Alpha Architect. Here is the link. SUMMARY Factors can be valued like stocks Factor valuations have not changed structurally over the last 30 years Cheap factors outperformed expensive ones on average INTRODUCTION Tesla (TSLA) breached the $100 billion(...) Thoughts on Systematic Value Investing [Two Centuries Investments]As a risk factor, Value is very much alive. Confusing the risk side and return side of factors creates the misconceived question of whether the value factor is dead. Something that is dead, does not move. A dead factor is a flat horizontal line with random noise. By contrast, value has been moving(...) A Comparison of Charts [Dekalog Blog]Earlier in May I posted about Market Profile with some charts and video. Further work on this has made me realise that my earlier post should more accurately be described as Volume Profile, so apologies to readers for that. Another, similar type of chart I have seen described as a TPO chart (TPO(...) How to Run Python from R Studio [Robot Wealth]Modern data science is fundamentally multi-lingual. At a minimum, most data scientists are comfortable working in R, Python and SQL; many add Java and/or Scala to their toolkit, and it’s not uncommon to also know one’s way around JavaScript. Personally, I prefer to use R for data analysis. But,(...) Is this the pullback you’ve been waiting for? [Quantifiable Edges]It has been 47 trading days since SPX posted its last 3-day pullback. That is a long time. And it is especially long considering SPX is still below its 200ma. Should SPX fail to rally out of this early hole this morning, we will finally see the 1st 3-day pullback since March 9th. Bulls could look at(...) YTD Performance of Equity Factors - Update After Two Months [Quantpedia]Nearly two months ago, in a time of the highest turmoil during the current pandemic crisis, we performed a quick assessment of the status of performance of equity factor strategies. The world has still not been able to ward-off health-care crisis completely, but a lot of countries have made(...) Discussion: Managing the Costs of Passively Investing in Active Strategies [Alpha Architect]We recently covered a paper by David Blitz that highlighted the potential problems with passively investing in “active” strategies. The research piece is great and surfaces a lot of great concepts. Like a lot of research we publish/summarize this article appears to “shoot Alpha Architect in(...) Tracking Bitcoin Gains since its 3rd Halving in May 2020 using Python [Quant at Risk]The Bitcoin’s 3rd halving was the most anticipated event this year. This a moment when a reward for all Bitcoin block miners is cut by half. It happens every 4 years or every 210,000 blocks on the Bitcoin blockchain. The previous two halving events took place in 2012 and 2016, respectively. Before(...) Financial Data Manipulation in dplyr for Quant Traders [Robot Wealth]In this post, we’re going to show how a quant trader can manipulate stock price data using the dplyr R package. Getting set up and loading data Load the dplyr package via the tidyverse package. if (!require('tidyverse')) install.packages('tidyverse') library(tidyverse) First,(...) Academic Finance Research Galore. WFA Sessions Announced [Alpha Architect]Attention all finance geeks. The latest and greatest from academic researchers is available for all to review. The WFA recently released their sessions. WFA is one of the more prestigious academic conferences and papers presented at the conference often find their way into top-tier academic(...) Machine Learning and Investing: Forecasting Fundamentals w/ Ensembles [Alpha Architect]Quantitative factor portfolios generally use historical company fundamental data in portfolio construction. The key assumption behind this approach is that past fundamentals proxy for elements of risk and/or systematic mispricing. However, what if we could forecast fundamentals, with a small margin(...) Get Rich Quick Trading Strategies (and why they don't work) [Robot Wealth]Every aspiring millionaire who comes to the markets armed with some programming ability has implemented a systematic Get Rich Quick (GRQ) trading strategy. Of course, they don’t work. Deep down even the greenest of newbies knows this. Yet, still, we are compelled to give them a try, just once,(...) Designing an energy arbitrage strategy (h/t @PyQuantNews) [Steve Klosterman]The price of energy changes hourly, which opens up the possibility of temporal arbitrage: buying energy at a low price, storing it, and selling it later at a higher price. To successfully execute any temporal arbitrage strategy, some amount of confidence in future prices is required, to be able to(...) How To Get Historical S&P 500 Constituents Data For Free [Robot Wealth]In this post, we are going to construct snapshots of historic S&P 500 index constituents, from freely available data on the internet. Why? Well, one of the biggest challenges in looking for opportunities amongst a broad universe of stocks is choosing what stock “universe” to look at. One(...) Skulls, Financial Turbulence and Risk Management [Alpha Architect]When hunting for diversity, the typical investor considers only average correlations. However, when measuring an asset’s diversification benefits utilizing average correlations tend to mislead investors. For example, when both U.S. and non-U.S. equities produce returns greater than one standard(...) Straddles and Trend Following [Flirting with Models]The convex payoff profile of trend following strategies naturally lends itself to comparative analysis with option strategies. Unlike options, however, the payout of trend following is not guaranteed. To compare and contrast the two approaches, we replicate simple trend following strategies with(...) How to Find Cheap Options to Buy and Expensive Options to Sell [Robot Wealth]If you want to make money trading, you’re going to need a way to identify when an asset is likely to be cheap and when it is likely to be expensive. You want to be a net buyer of the cheap stuff and a net seller of the expensive stuff. Thanks, Capitain Obvious. You’re welcome. How does this(...) Value Investing: Even Deeper History [Two Centuries Investments]In last week’s post we extended the systematic value factor (or at least a pretty good proxy of it) back to 1871. The response from readers was encouraging, perhaps because of the pain that value investing has been causing lately. Long-run history gives some relief. This week we dig deeper,(...) The Case Against Factor Investing [Factor Research]Factor investing is likely the best option for investors seeking to outperform the market However, the cyclicality of factors makes factor investing challenging when it underperforms Investors that do not understand this cyclicality are likely better served by plain, rather than smart beta FREE(...) Online Portfolio Selection: Mean Reversion [Hudson and Thames]Mean Reversion is an effective quantitative strategy based on the theory that prices will revert back to its historical mean. A basic example of mean reversion follows the benchmark of Constant Rebalanced Portfolio. By setting a predetermined allocation of weight to each asset, the portfolio shifts(...) How to Hedge a Portfolio with Put Options [Robot Wealth]There are 2 good reasons to buy put options: because you think they are cheap because you want downside protection. In the latter case, you are looking to use the skewed payoff profile of the put option to protect a portfolio against large downside moves without capping your upside too much. The(...) Machined risk premia [OSM]Over the last few posts, we’ve discussed methods to set return expectations to construct a satisfactory portfolio. These methods are historical averages, discounted cash flow models, and risk premia. our last post, focused on the third method: risk premia. Using the Capital Asset Pricing Model(...) When endogenous risk management isn't enough: a simple risk overlay [Investment Idiocy]"How does your risk management work?" ... is a question I'm frequently asked. In fact this is actually a difficult question, if you were to look at my open source python backtesting project pysystemtrade, you would struggle to point at a piece of code and say "Behold! Right(...)