Quant Mashup - Robot Wealth
How To Be a Quant Trader - Experiments with @QuantConnect [Robot Wealth]
This post presents an analysis of the SPY returns process using the QuantConnect research platform. QuantConnect is a strategy development platform that lets you research ideas, import data, create algorithms, and trade in the cloud, all in one place. For this research, I’ve used their online
- 4 years ago, 14 Jul 2020, 09:36am -
How to extend ETF prices with mutual fund data using SQL [Robot Wealth]
On Zero to Robot Master Bootcamp, we teach how to build a portfolio of three automated systematic trading strategies. One of them is a long term Risk Premia Harvesting strategy which trades asset class ETFs. ETFs are useful instruments for analysing long term (tradeable) performance of various asset
- 4 years ago, 8 Jun 2020, 11:09pm -
Why Aren't Call Options More Expensive Than Put Options? [Robot Wealth]
Why aren’t calls more expensive than puts for an asset which is more likely to go up than down? We have an asset trading at $100 for which the distribution of future returns is a known fact. It has annual returns described by a normal distribution with mean 5% and standard deviation 10%. This is,
- 4 years ago, 4 Jun 2020, 01:16pm -
Why We Use Apache Beam For Our Systematic Trading Data Pipeline [Robot Wealth]
In the world of Big Data, there are lots of tools and technologies to choose from. Choosing the “right” one depends on the things that you are building and the problems you are trying to solve. Trading firms have skilled teams that monitor and deploy data pipelines for their organisation and the
- 4 years ago, 3 Jun 2020, 11:02am -
Working with Tidy Financial Data in tidyr [Robot Wealth]
Holding data in a tidy format works wonders for one’s productivity. Here we will explore the tidyr package, which is all about creating tidy data. In particular, let’s develop an understanding of the tidyr::pivot_longer and tidyr::pivot_wider functions for switching between different formats of
- 4 years ago, 2 Jun 2020, 09:44am -
Exploiting The Non-Farm Payrolls Drift [Robot Wealth]
Anyone that’s been around the markets knows that the monthly release of the United States Department of Labor’s Non-Farm Payrolls (NFP) data can have a tremendous impact, especially in the short term. NFP is a snapshot of the state of the employment situation in the US, representing the total
- 4 years ago, 1 Jun 2020, 09:54am -
Performant R Programming: Chunking a Problem into Smaller Pieces [Robot Wealth]
When data is too big to fit into memory, one approach is to break it into smaller pieces, operate on each piece, and then join the results back together. Here’s how to do that to calculate rolling mean pairwise correlations of a large stock universe. Background We’ve been using the problem of
- 4 years ago, 28 May 2020, 10:31am -
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
- 4 years ago, 27 May 2020, 10:43am -
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
- 4 years ago, 26 May 2020, 04:34am -
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
- 4 years ago, 25 May 2020, 10:01am -
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
- 4 years ago, 21 May 2020, 10:26am -
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
- 4 years ago, 20 May 2020, 09:52am -
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
- 4 years ago, 19 May 2020, 10:31am -
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
- 4 years ago, 18 May 2020, 11:08am -
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,
- 4 years ago, 15 May 2020, 09:39am -
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,
- 4 years ago, 14 May 2020, 10:12am -
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,
- 4 years ago, 13 May 2020, 08:19am -
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
- 4 years ago, 12 May 2020, 10:05am -
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
- 4 years ago, 11 May 2020, 10:10am -
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
- 4 years ago, 8 May 2020, 09:35pm -
Pairs Trading Literature Review [Robot Wealth]
This post summarises the key lessons of the academic literature that has been published on pairs trading. The key themes are highlighted at the end of the page. Pair Trading Literature Review Gatev, Goetzmann, Rouwenhorst – “Pairs Trading: Performance of a Relative Value Arbitrage Strategy”
- 4 years ago, 6 May 2020, 11:31am -
Overnight and Intraday SPX returns [Robot Wealth]
One of the things I’ve noticed from staring at the screen all day for the last few months is that most of the large negative returns in US stock indexes have come overnight. What do you mean by “overnight”? The core stock trading session for US stocks is between 9:30 am and 4 pm Eastern Time.
- 4 years ago, 5 May 2020, 09:30am -
Using Apache Airflow to Extract CoT Data [Robot Wealth]
In today’s post we are going to be extracting CoT (Commitment of Traders) reports from the CFTC website using a pipeline built on Apache Airflow. What is CoT data? The CoT report is a weekly publication which reports the open positions of market participants in the U.S futures market. It’s
- 4 years ago, 4 May 2020, 09:28am -
The VIX Futures Basis [Robot Wealth]
In the eye of the recent storm, with VIX up over 50, many traders were looking to “short the VIX” using products like TVIX. “Surely it’s going to coming back down?” Well yeah, it will, eventually, but that doesn’t mean that you can profitably short VIX products. First, some basics…
- 4 years ago, 30 Apr 2020, 09:35am -
Efficiently Simulating Geometric Brownian Motion in R [Robot Wealth]
For simulating stock prices, Geometric Brownian Motion (GBM) is the de-facto go-to model. It has some nice properties which are generally consistent with stock prices, such as being log-normally distributed (and hence bounded to the downside by zero), and that expected returns don’t depend on the
- 4 years ago, 26 Apr 2020, 12:03pm -
Parameter Optimisation for Systematic Trading [Robot Wealth]
Optimisation tools have a knack for seducing systematic traders. And what’s not to love? Find me the unique set of parameters that delivered the greatest return in my ten-year backtest. And do it in under five seconds. That’s certainly attractive. But do you want to hear something controversial?
- 4 years ago, 19 Apr 2020, 02:27pm -
A Review of Zorro for Systematic Trading [Robot Wealth]
One of the keys to running a successful systematic trading business is a relentless focus on high return-on-investment activities. High ROI activities include: Implementing new trading strategies within a proven framework. An example might be to implement a portfolio of pairs trades in the equity
- 4 years ago, 16 Apr 2020, 01:00pm -
Revenge of the Stock Pickers [Robot Wealth]
To say we’re living through extraordinary times would be an understatement. We saw the best part of 40% wiped off stock indexes in a matter of weeks, unprecedented co-ordinated central bank intervention on a global scale, and an unfolding health crisis that for many has already turned into a
- 4 years ago, 30 Mar 2020, 10:10pm -
A Vector Autoregression Trading Model [Robot Wealth]
The vector autoregression (VAR) framework is common in econometrics for modelling correlated variables with bi-directional relationships and feedback loops. If you google “vector autoregression” you’ll find all sorts of academic papers related to modelling the effects of monetary and fiscal
- 4 years ago, 12 Mar 2020, 10:00am -
The Graphical Lasso and its Financial Applications [Robot Wealth]
Way back in November 2007, literally weeks after SPX put in its pre-GFC all-time high, Friedman, Hastie and Tibshirani published their Graphical Lasso algorithm for estimation of the sparse inverse covariance matrix. Are you suggesting that Friedman and his titans of statistical learning somehow
- 4 years ago, 4 Mar 2020, 09:19pm -
Kalman Filter Pairs Trading with Zorro and R [Robot Wealth]
In the first three posts of this mini-series on pairs trading with Zorro and R, we: Implemented a Kalman filter in R Implemented a simple pairs trading algorithm in Zorro Connected Zorro and R and exchanged data between the two platforms In this fourth and final post, we’re going to put it all
- 5 years ago, 16 Oct 2019, 05:56am -
Integrating R with the Zorro Backtesting and Execution Platform [Robot Wealth]
n the last two posts, we implemented a Kalman filter in R for calculating a dynamic hedge ratio, and presented a Zorro script for backtesting and trading price-based spreads using a static hedge ratio. The goal is to get the best of both worlds and use our dynamic hedge ratio within the Zorro
- 5 years ago, 3 Oct 2019, 08:25pm -
Pairs Trading in Zorro [Robot Wealth]
In our previous post, we looked into implementing a Kalman filter in R for calculating the hedge ratio in a pairs trading strategy. You know, light reading… We saw that while R makes it easy to implement a relatively advanced algorithm like the Kalman filter, there are drawbacks to using it as a
- 5 years ago, 25 Sep 2019, 08:27am -
How To Make A Kalman Filter in R for Pairs Trading [Robot Wealth]
Anyone who’s tried pairs trading will tell you that real financial series don’t exhibit truly stable, cointegrating relationships. If they did, pairs trading would be the easiest game in town. But the reality is that relationships are constantly evolving and changing. At some point, we’re
- 5 years ago, 19 Sep 2019, 09:25am -
Pattern Recognition with the Frechet Distance [Robot Wealth]
Chart patterns have long been a favourite of the technical analysis community. Triangles, flags, pennants, cups, heads and shoulders…. Name a shape, someone somewhere is using it to predict market behaviour. But, is there a grain of truth or reliability in these patterns? Can it really give you a
- 5 years ago, 13 Sep 2019, 10:04am -
Can you apply factors to trade performance? [Robot Wealth]
When tinkering with trading ideas, have you ever wondered whether a certain variable might be correlated with the success of the trade? For instance, maybe you wonder if your strategy tends to do better when volatility is high? In this case, you can get very binary feedback by, say, running
- 5 years ago, 10 Sep 2019, 09:56am -
A Quant's Approach to Drawdown: The Cold Blood Index [Robot Wealth]
In part 1 of this series, we talked about how a market-savvy systematic trader would approach a period of drawdown in a trading strategy. Specifically, they’d: do the best job possible of designing and building their trading strategy to be robust to a range of future market conditions chill out
- 5 years ago, 3 Sep 2019, 08:26am -
Practical Pairs Trading [Robot Wealth]
Some price series are mean reverting some of the time, but it is also possible to create portfolios which are specifically constructed to have mean-reverting properties. Series that can be combined to create stationary portfolios are called cointegrating, and there are a bunch of statistical tests
- 5 years ago, 10 Jul 2019, 11:55am -
Bond. Treasury Bond [Robot Wealth]
The Federal Reserve publishes the yield-to-maturity of US Treasury bonds. However, the actual returns earned by investors are not publicly available. Nor are they readily and intuitively discerned from historical yields, since “a bond’s return equals its yield only if its yield stays constant
- 5 years ago, 21 Jun 2019, 09:48am -
Shannon Entropy: A Genius Gambler's Guide to Market Randomness [Robot Wealth]
Before you commit your precious time to read this blog post, I need to warn you that this is one of those posts that market nerds like myself will get a kick out of, but which probably won’t add much of practical value to your trading. The purpose of this post is to scratch the surface of the
- 5 years ago, 18 Jun 2019, 12:00pm -
Optimising MetaTrader for Algorithmic Trading [Robot Wealth]
If you’ve ever delved into the world of retail foreign exchange trading, you’ll have come across the MetaTrader platform. Let’s be clear. The platform has its drawbacks. If you’ve traded “grown-up” markets, some of the features will leave you scratching your head. But one thing’s for
- 5 years ago, 31 May 2019, 03:04pm -
Backtesting Bias: Feels Good, Until You Blow Up [Robot Wealth]
In an ideal trading universe, we’d all have a big golden “causation magnifying glass”. Through the lens of this fictional tool, you’d zoom in and understand the fleeting, enigmatic nature of the financial markets, stripping bare all its causes and effects. Knowing exactly what causes
- 5 years ago, 15 May 2019, 09:47am -
Momentum Is Dead! Long Live Momentum! [Robot Wealth]
In our inaugural Algo Bootcamp, we teamed up with our super-active community of traders and developed a long-only, always-in-the-market strategy for harvesting risk premia. It holds a number of different ETFs, varying their relative weighting on a monthly basis. We’re happy with it. However, the
- 5 years ago, 29 Apr 2019, 10:47am -
Harvesting Risk Premia [Robot Wealth]
Trading and investing doesn’t have to be complicated. Check out this chart: source: Dimson, Marsh and Staunton, Triumph of the Optimists The blue line shows returns from US Stocks from 1900 to today. That’s a 48,000x increase in nominal value. The yellow line shows returns from US Bonds from
- 6 years ago, 15 Jan 2019, 09:22am -
The Law of Large Numbers - Part 2 [Robot Wealth]
Even if you’ve never heard of it, the Law of Large Numbers is something that you understand intuitively, and probably employ in one form or another on an almost daily basis. But human nature is such that we sometimes apply it poorly, often to great detriment. Interestingly, psychologists found
- 6 years ago, 16 Sep 2018, 06:45am -
The Law of Large Numbers - Practical Statistics for Algo Traders Part 2 [Robot Wealth]
Even if you’ve never heard of it, the Law of Large Numbers is something that you understand intuitively, and probably employ in one form or another on an almost daily basis. But human nature is such that we sometimes apply it poorly, often to great detriment. Interestingly, psychologists found
- 6 years ago, 13 Aug 2018, 07:11am -
Practical Statistics for Algo Traders [Robot Wealth]
How do you feel when you see the word “statistics”? Maybe you sense that it’s something you should be really good at, but aren’t. Maybe the word gives you a sense of dread, since you’ve started exploring its murky depths, but thrown your hands up in despair and given up – perhaps more
- 6 years ago, 22 Jul 2018, 08:25pm -
Simulating Variable FX Swaps in Zorro and Python [Robot Wealth]
One of the ongoing research projects inside the Robot Wealth community involves an FX strategy with some multi-week hold periods. Such a strategy can be significantly impacted by the swap, or the cost of financing the position. These costs change over time, and we decided that for the sake of more
- 6 years ago, 9 Jul 2018, 07:12pm -
Fun with the Cryptocompare API [Robot Wealth]
Cryptocompare is a platform providing data and insights on pretty much everything in the crypto-sphere, from market data for cryptocurrencies to comparisons of the various crytpo-exchanges, to recommendations for where to spend your crypto assets. The user-experience is quite pleasant, as you can
- 6 years ago, 12 Jun 2018, 04:48pm -
ETF Rotation Strategies in Zorro [Robot Wealth]
At Robot Wealth we get more questions than even the most sleep-deprived trader can handle. So whilst we develop the algo equivalent of Siri and brag about how we managed to get 6 hours downtime last night, we thought we’d start a new format of blog posts — answering your most burning questions.
- 6 years ago, 4 Jun 2018, 12:22pm -