# quantitative analysis

Posted on Jul 14, 2020 by
0 Views

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 research notebook, and it came preinstalled with all the libraries and data (intraday) I needed to complete the analysis at no cost. It's very impressive indeed.   I love those predictions of the future from the past. It's funny how the people viewed the future back then. You can see how their preconceived notions on the world were simply extrapolated forward into the future. Consider a flying wooden car. They guessed that cars would have to be flying by then (Elon, do it already!) but they missed the fact that wood will no longer be the preferred material for building cars. Take look at this excellent article from the Independent. The tale of beginner traders can be similar. They are deeply entrenched in their beliefs of how the market works, and they try to...

Posted on Jun 02, 2020 by
0 Views

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 tidy data. In this video, you'll learn: What tidy data looks like Why it's a sensible approach The difference between long and wide tidy data How to efficiently switch between the two format When and why you'd use each of the two formats   What's tidy data? Tidy data is data where: Every column is variable. Every row is an observation. Every cell is a single value. Why do we care? It turns out there are huge benefits to thinking about the “shape” of your data and the best way to structure and manipulate it for your problem. Tidy data is a standard way of shaping data that facilitates analysis. In particular, tidy data works very well with the tidyverse tools. Which means less time spent transforming and cleaning data and more time spent solving problems. In...

Posted on May 11, 2020 by
0 Views

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 relate to equity options? If we take the (liquid) US Equity options market as an example then there are an absolute ton of options contracts you could be trading. 95% of them are sufficiently fairly valued that you won't make much money trading them once you've paid all the costs to buy and sell them and hedge your risk. The remaining 5% are worth looking for. Options have a positive dependency on volatility. In looking for "cheap" or "expensive" options, we're really looking for cheap or expensive "volatility". So we ask the following questions: When does the forward volatility "implied" by options prices tend to be lower than the volatility that realises in the subsequent stock price process? We would look to buy...

Posted on May 08, 2020 by
0 Views

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 first requires a pricing model. Or, at the least, an understanding of when and under what conditions put options tend to be cheap. The second doesn't necessarily. We'll assume that we're going to have to pay a premium to protect our portfolio - and that not losing a large amount of money is more important than the exact price we pay for it. Let's run through an example… We have a portfolio comprised entirely of 100 shares of SPY. About $29k worth. We can plot a payoff profile for our whole portfolio. This is going to show the dollar P&L from our portfolio at various SPY prices. At the time of writing, SPY closed at$287.05 if (!require("pacman")) install.packages("pacman") pacman::p_load(tidyverse, rvest, slider, tidyquant, alphavantager, kableExtra) SPYprice <- 287.05...

Posted on May 07, 2020 by
0 Views

We've been working on visualisation tools to make option pricing models intuitive to the non-mathematician. Fundamental to such an exercise is a way to model the random nature of asset price processes. The Geometric Brownian Motion (GBM) model is a ubiquitous way to do this. We can represent the price of an asset at time $t$ as the state $x(t)$ of a GBM process. $x(t)$ satisfies an Ito differential equation  [latex display="true"] dx(t) = \mu x(t) dt + \sigma x(t) dw(t) [/latex] where $w(t)$ follows a wiener process with drift $\mu$ and volatility $\sigma$. The probability distribution of future prices follows a log-normal distribution  [latex display="true"] [(\mu - \frac{\sigma^2}{2}) + \log{x_0}, \sigma\sqrt{t}] [/latex] OK, nerd, but how do I get the probability distribution of future prices from the starting price of the asset, and assumptions about the return distribution? I couldn't work that out quickly, so I asked Wolfram Mathematica that question. PDF[GeometricBrownianMotionProcess[\[Mu], \[Sigma], Subscript[x, 0]][t], x] [latex display="true"] \frac{exp{\frac{(-t(\mu - \frac{\sigma^2}{2}) + \log{x} - log{x_0})^2}{2t\sigma^2}}}{\sqrt{2\pi}\sqrt{t}x\sigma}, x > 0...

Posted on Sep 10, 2019 by
1 Comment.
0 Views

Posted on Apr 29, 2019 by
0 Views

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 perennial question remains: can we do better? As you might expect, we found evidence suggesting that risk premia are time-varying. If we could somehow predict this variation, we could use that prediction to adjust the weightings of our portfolio and quite probably improve the strategy's performance. This might sound simple enough, but we actually found compelling evidence both for and against our ability to time risk premia returns. We're always telling our Bootcamp participants that developing trading and investment strategies requires the considered balancing of evidence in the face of uncertainty. In this case, we decided that there was enough evidence to suggest that we could weakly predict time-varying risk premia returns, at least to the extent that slight weight adjustments in accordance with these predictions might provide value. The strategy was already decent enough, so...

Posted on Jan 03, 2017 by
0 Views

What if you had a tool that could help you decide when to apply mean reversion strategies and when to apply momentum to a particular time series? That's the promise of the Hurst exponent, which helps characterise a time series as mean reverting, trending, or a random walk. For a brief introduction to Hurst, including some Python code for its calculation, check out our previous post. Even if you have read this post previously, it is worth checking out again as we have updated our method for calculating Hurst and believe this new implementation is more accurate. It would be great if we could plug some historical time series data into the Hurst algorithm and know whether we expect the time series to mean revert or trend. But as is usually the case when we apply such tools to the financial domain, it isn't quite that straightforward. In the last post, we noted that Hurst gives different results depending on how it is calculated; this begs the question of how to choose a calculation method intelligently so that we avoid choosing...

Posted on Oct 14, 2016 by