# trading strategies

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 number of paid workers, excluding farm employees and public servants. We know your barn is hiding a giant mining station, Rick The release of the monthly NFP data typically causes large swings in the currency markets, even when the results are in line with estimates. Here, we are interested in exploring potential seasonal effects around the release of this data. For example, does price tend to drift prior to the release? If so, which way? For this analysis, we'll explore the EUR/USD exchange rate. To set up this research problem, we need to know that NFP is released on the first Friday of the month at 8:30am ET - usually. If the first Friday is a holiday, NFP is released the following Friday. These sorts of details can make seasonal analysis...

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. That's when most stock market transactions take place. When we look at daily OHLC (Open High Low Close) stock data, the open price is the first trade of the core 9:30 am session, and the close price is the price of the auction at the end of the 4 pm core trading session. However, stocks also trade in the “pre-open” or “early trading session” which starts at 6:30 am and in the “late trading session” which goes until 8 pm. Futures on stock indexes also trade most of the day. I'm interested to see how overnight returns (the jump from the close to the open) differ from intraday returns - and how that relationship may have changed recently. Intuitively, we'd probably expect to see...

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 tragedy. As an investor or trader, what do you do? You manage your exposures the best you can, dial everything down, and go hunting for the opportunities that inevitably present themselves in a stressed out market. We've been hunting pretty much since this thing kicked off - and we want to show you what we found. And, more importantly, the tools and approach we used to find them. To that end, we are opening the gates to our Robot Wealth Pro community, a tight-knit network of independent traders with whom we share our firm's research, data, systematic trading strategies, and real-time ideas. We normally insist that you go through an introductory Bootcamp before joining our Pro team, but these are extraordinary times and we want to get after these opportunities as...

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 policy on various aspects of the economy. This is only of passing interest to traders. However, if we consider that the VAR framework finds application in the modelling of correlated time series, the implication being that correlation implies a level of forecasting utility, then perhaps we could model a group of related financial instruments and make predictions that we can translate into trading decisions? So we'll give that a try. But first, a brief overview of VAR models. Overview of VAR models The univariate autoregression (AR) is a model of a time series as a function of past values of itself: (Y_t = \alpha + \beta_1 Y_{t-1}+ \beta_2 Y_{t-2} ) That's an AR(2) model because it uses two previous values in the time series (Y) to estimate the next value. The name of the game is figuring out how many...

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 together and develop a pairs trading script that uses Zorro for all the simulation aspects (data handling, position tracking, performance reporting and the like) and our Kalman implementation for updating the hedge ratio in real-time. You can download the exact script used in this post for free down at the very bottom. Let's go! Step 1: Encapsulate our Kalman routine in a function Encapsulating our Kalman routine in a function makes it easy to call from our Zorro script - it reduces the call to a single line of code. Save the following R script, which implements the iterative Kalman operations using data sent from Zorro, in your Zorro strategy folder: ###### KALMAN FILTER ####### delta <- 0.0001 Vw <- delta/(1-delta)*diag(2) Ve <- 0.01 R <- matrix(rep(0,...

This Kalman Filter Example post is the first in a series where we deploy the Kalman Filter in pairs trading. Be sure to follow our progress in Part 2: Pairs Trading in Zorro, and Part 3: Putting It All Together. 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 forced to make uncertain decisions about how best to capture those changes. One way to incorporate both uncertainty and dynamism in our decisions is to use the Kalman filter for parameter estimation. The Kalman filter is a state space model for estimating an unknown ('hidden') variable using observations of related variables and models of those relationships. The Kalman filter is underpinned by Bayesian probability theory and enables an estimate of the hidden variable in the presence of noise. There are plenty of tutorials online that describe the mathematics of the Kalman filter, so I won't...

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 for this property. We'll return to these shortly. While you can, in theory, create mean reverting portfolios from as many instruments as you like, this post will largely focus on the simplest case: pairs trading. What is Pairs Trading? Pairs trading involves buying and selling a portfolio consisting of two instruments. The instruments are linked in some way, for example they might be stocks from the same business sector, currencies exposed to similar laws of supply and demand, or other instruments exposed to the same or similar risk factors. We are typically long one instrument and short the other, making a bet that the value of this long-short portfolio (the spread) has deviated from its equilibrium value and will revert back towards that value. One of the major attractions of pairs trading is that...

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. Lately our Class to Quant members have been looking to implement rotation-style ETF and equities strategies in Zorro, but just like your old high-school essays, starting is the biggest barrier. These types of strategies typically scan a universe of instruments and select one or more to hold until the subsequent rebalancing period. Zorro is my go-to choice for researching and even executing such strategies: its speed makes scanning even large universes of stocks quick and painless, and its scripting environment facilitates fast prototyping and iteration of the algorithm itself - once you've wrestled it for a while (get our free Zorro for Beginners video course here). I'm going to walk you through a general design paradigm for constructing strategies like this with Zorro, and demonstrate the entire process with a...

I recently read Gary Antonacci's book Dual Momentum Investing: An Innovative Strategy for Higher Returns with Lower Risk, and it was clear to me that this was an important book to share with the Robot Wealth community. It is important not only because it describes a simple approach to exploiting the "premier anomaly" (Fama and French, 2008), but because it is ultimately about approaching the markets with a critical, inquisitive mindset, while not taking oneself too seriously. I think we can all do with a dose of that sometimes. Gary's style is unique: this is the work of a free and critical thinker who is not afraid to question the status quo. While articulately drawing from a range of sources, from Shakespeare to Bacon and Einstein to Buffet (even Thomas Conrad's 1970 book Hedgemanship: How to Make Money in Bear Markets, Bull Markets and Chicken Markets While Confounding Professional Money Managers and Attracting a Better Class of Women, which has got to be the greatest title in the history of trading books), Gary comes across as playful and slightly eccentric (which is wonderfully refreshing...

Introduction My first post on using machine learning for financial prediction took an in-depth look at various feature selection methods as a data pre-processing step in the quest to mine financial data for profitable patterns. I looked at various methods to identify predictive features including Maximal Information Coefficient (MIC), Recursive Feature Elimination (RFE), algorithms with built-in feature selection, selection via exhaustive search of possible generalized linear models, and the Boruta feature selection algorithm. I personally found the Boruta algorithm to be the most intuitive and elegant approach, but regardless of the method chosen, the same features seemed to keep on turning up in the results. In this post, I will take this analysis further and use these features to build predictive models that could form the basis of autonomous trading systems. Firstly, I'll provide an overview of the algorithms that I have found to generally perform well on this type of machine learning problem as well as those algorithms recommended by David Aronson (2013) in Statistically Sound Machine Learning for Algorithmic Trading of Financial Instruments (SSML). I'll also discuss a framework for measuring the...