Quant Mashup - Robot Wealth
A Beginner's Guide to Using DuckDB with Stock Price Data in R [Robot Wealth]
In this blog post, I will demonstrate how to work with stock price data using the DuckDB database management system in R. DuckDB is a fast and lightweight analytical database engine that is designed to work with various programming languages, including R. You can use Duck DB from the command line or
- 3 weeks ago, 9 May 2023, 10:42pm -
Webinar recordings and notebook [Robot Wealth]
Towards the end of last year, we ran a couple of free Zoom webinars on: The Basics of Edge Extraction – the “trader smarts” of getting an edge Data Analysis for Traders – an interactive research session. Here are the recordings: Basics of Edge Extraction Data analysis for Traders The colab
- 2 months ago, 23 Mar 2023, 09:40am -
More Intuitive Joins in dplyr 1.1.0 [Robot Wealth]
dplyr 1.1.0 was a significant release that makes several common data operations more syntactically intuitive. The most significant changes relate to joins and grouping/aggregating operations. In this post we’ll look at the changes to joins. First, install and load the latest version of dplyr:
- 2 months ago, 15 Mar 2023, 09:55pm -
Exploring the finnhub.io API [Robot Wealth]
Over the last few years, a number of new market data providers have come online. They tend to have modern websites, broad coverage, and well-documented RESTful APIs. Their services are often priced very competitively – especially for personal use – and usually have generous free tiers. One such
- 3 months ago, 23 Feb 2023, 07:47am -
How to get serious about making money trading [Robot Wealth]
In Australia, if you’re serious about getting the job done effectively and efficiently, you might say: “I’m not here to f*** spiders.” Many traders act like they are, indeed, here to f*** spiders. If you’re making soup, you first need a good stock. Stock isn’t exciting. Everyone has
- 1 year ago, 12 Jan 2022, 11:21am -
Steal ideas, not implementations [Robot Wealth]
Imagine you’re a relatively small, independent trader trying to turn trading from a hobby into a serious business. If that’s you, then there are a few concepts that will help you pick the right trades to get after. This is important because picking the right trades is most of the game. First,
- 1 year ago, 22 Sep 2021, 11:31am -
Optimising the rsims package for fast backtesting in R [Robot Wealth]
rsims is a new package for fast, quasi event-driven backtesting in R. You can find the source on GitHub, docs here, and an introductory blog post here. Our use case for rsims was accurate but fast simulation of trading strategies. I’ve had a few questions about how I made the backtester as fast as
- 1 year ago, 20 Aug 2021, 10:38am -
Exploring the rsims package for fast backtesting in R [Robot Wealth]
rsims is a new package for fast, realistic (quasi event-driven) backtesting of trading strategies in R. Really?? Does the world really need another backtesting platform…?? It’s hard to argue with that sentiment. Zipline, QuantConnect, Quantstrat, Backtrader, Zorro… there are certainly plenty
- 1 year ago, 13 Aug 2021, 10:44am -
How to Predict Asset Prices (and how not to) [Robot Wealth]
If you have some factor that you think predicts future stock returns (or similar) and you are making charts like below, then here are some tips… We’ll go through an example of trying to “time” SPX with the level of VIX. You get daily SPX index prices and daily VIX close data You align them
- 2 years ago, 16 Apr 2021, 12:10pm -
What P&L Swings Can I Expect as a Trader? [Robot Wealth]
Many beginner traders don’t realize how variable the p&l of a high-performing trading strategy really is. Here’s an example… I simulated ten different 5 year GBM processes with expected annual returns of 20% and annualized volatility of 10%. (If you speak Sharpe Ratios, I’m simulating a
- 2 years ago, 8 Apr 2021, 10:47am -
Three types of systematic strategies that "work" [Robot Wealth]
Broadly, there are three types of systematic trading strategy that can “work.” In order of increasing turnover they are: Risk premia harvesting Economically-sensible, statistically-quantifiable slow-converging inefficiencies Trading fast-converging supply/demand imbalances This post provides an
- 2 years ago, 10 Feb 2021, 10:04am -
Exporting Zorro Data to CSV [Robot Wealth]
Earlier versions of Zorro used to ship with a script for converting market data in Zorro binary format to CSV. That script seems to have disappeared with the recent versions of Zorro, so I thought I’d post it here. When you run this script by selecting it and pressing [Test] on the Zorro
- 2 years ago, 6 Jan 2021, 08:31pm -
Evolving Thoughts on Data Mining [Robot Wealth]
Several years ago, I wrote about some experimentation I’d done with data mining for predictive features from financial data. The article has had several tens of thousands of views and nearly 100 comments. I think the popularity of the article lay in its demonstration of various tools and modeling
- 2 years ago, 9 Dec 2020, 10:04am -
Are Cheap Stocks Expensive? A Simple Equity Factor Analysis Walkthrough [Robot Wealth]
I have been sharing examples of simple real-time trading research on my Twitter account. I do this kind of thing a lot in the training program of our trading group – and I’m sharing in the hope that it might also help a wider audience. Here’s a piece of analysis I did recently on a really
- 2 years ago, 2 Dec 2020, 09:44am -
Trading FX using Autoregressive Models [Robot Wealth]
I’m a big fan of Ernie Chan’s quant trading books: Quantitative Trading, Algorithmic Trading, and Machine Trading. There are some great insights in there, but the thing I like most is the simple but thorough treatment of various edges and the quant tools you might use to research and trade them.
- 2 years ago, 24 Nov 2020, 09:38am -
Tesla's inclusion in the S&P 500 - Is there a trade? [Robot Wealth]
The S&P index committee recently announced that Tesla, already one of the biggest stocks listed in the country, would be included in the S&P 500. Here’s the press release: Due to TSLA’s size, it was widely expected to have entered the S&P 500 index much earlier – but S&P has
- 2 years ago, 19 Nov 2020, 10:18am -
Where does FX sit in a Systematic Trading Portfolio? [Robot Wealth]
This post is a BONUS LESSON taken directly from Zero to Robot Master Bootcamp. In this Bootcamp, we teach traders how to research, build and trade a portfolio of 3 strategies including an Intraday FX Strategy, a Risk Premia Strategy and a Volatility Basis Strategy. If you’re interested in adding
- 2 years ago, 10 Nov 2020, 10:18am -
What Assumptions Are You Making About “Time” In Your Trading? [Robot Wealth]
I recently listened to a podcast about one of the earliest human civilizations – the ancient Sumerians. Apparently, our system of minutes, hours, and days has been with us since the time of these ancient people, who developed it based on a simple base-12 counting system: There are three joints in
- 2 years ago, 2 Nov 2020, 09:23pm -
My Thoughts on Quantopian's Closing [Robot Wealth]
I was very sad to learn that Quantopian is shutting down its community services. Quantopian’s efforts to bring quant finance outside of institutions was a genuine game-changer. The educational content was solid, the tech was excellent, and the QuantCon conferences were professional, well-run, and
- 2 years ago, 30 Oct 2020, 02:05am -
Trading the US Election – Profiting from “Known Unknowns” [Robot Wealth]
You’ve probably noticed that there’s a US election on the horizon. This is an event of known uncertainty: a “known unknown” in the now immortal language of Donald Rumsfeld. In trading, we sometimes observe marginal pricing inefficiencies around these “known unknowns”. For example, ahead
- 2 years ago, 29 Oct 2020, 10:58am -
Positional Option Trading by Euan Sinclair: A Review [Robot Wealth]
Trading books set a low bar for the reviewer. 99% are full of facile feel-good advice (don’t fight the trend, always use a protective stop). The 1% that are useful tend to either be dry technical treatments (quants who don’t trade), or sporadically helpful insights from traders who make money
- 2 years ago, 16 Sep 2020, 11:28am -
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
- 2 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
- 2 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,
- 3 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
- 3 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
- 3 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
- 3 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
- 3 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
- 3 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
- 3 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
- 3 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
- 3 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
- 3 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
- 3 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
- 3 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,
- 3 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,
- 3 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,
- 3 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
- 3 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
- 3 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
- 3 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”
- 3 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.
- 3 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
- 3 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…
- 3 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
- 3 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?
- 3 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
- 3 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
- 3 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
- 3 years ago, 12 Mar 2020, 10:00am -