How to Fill Gaps in Large Stock Data Universes Using tidyr and dplyr

How to Fill Gaps in Large Stock Data Universes Using tidyr and dplyr

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 time – you won’t have […]

Read more...

Find Cheap Options for Effective Crash Protection Using Crash Regressions

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 returns. This shows the […]

Read more...

Weekly Roundup 22 May – Doubling Down in Losing Trades Like a Drunken Hedge Fund Manager

Here’s a round-up of our new articles this week. They cover options trading, digital signal processing, data munging and Kris’s luxurious moustache… Trading Insanity! Every new trader tries out a few insane trading ideas! In a new series on the blog, Kris explores three insane trading strategies that tempted him back when he didn’t know any […]

Read more...

Financial Data Manipulation in dplyr for Quant Traders

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, load some price data. energystockprices.RDS contains a data frame of daily price observations for 3 […]

Read more...

How To Get Historical S&P 500 Constituents Data For Free

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 approach to dealing with this is to […]

Read more...

How to Find Cheap Options to Buy and Expensive Options to Sell

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. […]

Read more...

How to Hedge a Portfolio with Put Options

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 […]

Read more...

Probability Density Function for Prices from a GBM Process in R

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 as […]

Read more...

Pairs Trading Literature Review

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” https://papers.ssrn.com/sol3/papers.cfm?abstract_id=141615 This is the first meaningful academic paper on pair […]

Read more...

Overnight and Intraday SPX returns

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 […]

Read more...