Blog

Exploring Our Scraped Options Data Bid-Ask Spreads (Part-2)
PythonResearch

Exploring Our Scraped Options Data Bid-Ask Spreads (Part-2)

Post Outline * Notes on Part-2 * The Data * Bid-Ask Spread Analysis * How Do Aggregate Bid-Ask Spreads Vary with Days To Expiration? * How Do Bid-Ask Spreads Vary with Volume? * How Do Bid-Ask Spreads Vary with Volatility? * Summary Conclusions Notes on Part-2 Some astute readers in the comments noted that analysis based on the absolute difference in bid-ask price is not robust when considering the price of the underlying option and can lead to spurious conclusions. They recomme

READ MORE
Exploring Our Scraped Options Data Bid-Ask Spreads
PythonResearch

Exploring Our Scraped Options Data Bid-Ask Spreads

Post Outline * The Objective * The Data * Basic Data Analysis * Bid-Ask Spread Analysis * How Do Aggregate Bid-Ask Spreads Vary with Days To Expiration? * How Do Bid-Ask Spreads Vary with Volume? * How Do Bid-Ask Spreads Vary with Volatility? * Summary Conclusions The Objective Compared to the equity market, the options market is a level up in complexity. For each symbol there are multiple expiration dates, strike prices for each expiration date, implied volatilities, and that'

READ MORE
How to Build a Sequential Option Scraper with Python and Requests
PythonResearch

How to Build a Sequential Option Scraper with Python and Requests

Post Outline * Recap * The Problem * The Solution * Barchart Scraper Class * Barchart Parser Class * Utility Functions * Putting it all together * The Simple Trick * Next Steps Recap In the previous post I revealed a web scraping trick that allows us to defeat AJAX/JavaScript based web pages and extract the tables we need. We also covered how to use that trick to scrape a large volume of options prices quickly and asynchronously using the combination of aiohttp and asyncio. The Pr

READ MORE
How to Scrape and Parse 600 ETF Options in 10 mins with Python and Asyncio
PythonResearch

How to Scrape and Parse 600 ETF Options in 10 mins with Python and Asyncio

Post Outline * Intro * Disclaimers * The Secret to Scraping AJAX Sites * The async_option_scraper script * first_async_scraper class * expirys class * xp_async_scraper class * last_price_scraper class * The option_parser Module * The Implementation Script * References Intro This is Part 1 of a new series I'm doing in semi real-time to build a functional options data dashboard using Python. There are many underlying motivations to attempt this, and several challenges to imp

READ MORE
Can We Use Mixture Models to Predict Market Bottoms? (Part 3)
PythonQuant

Can We Use Mixture Models to Predict Market Bottoms? (Part 3)

Post Outline * Recap * Webinar Hypothesis * Anaylsis/Conclusions * Jupyter (IPython) Notebook * Github Links and Resources Recap Thus far in the series we've explored the idea of using Gaussian mixture models (GMM) to predict outlier returns. Specifically, we were measuring two things: 1. The accuracy of the strategy implementation in predicting return distributions. 2. The return pattern after an outlier event. During the exploratory phase of this project there were some interestin

READ MORE
Can We Use Mixture Models to Predict Market Bottoms? (Part 2)
PythonResearch

Can We Use Mixture Models to Predict Market Bottoms? (Part 2)

Post Outline * Recap * Model Update * Model Testing * Model Results * Conclusions * Code Recap In the previous post I gave a basic "proof" of concept, where we designed a trading strategy using Sklearn's implementation of Gaussian mixture models. The strategy attempts to predict an asset's return distribution such that returns that fall outside the predicted distribution are considered outliers and likely to mean revert. It showed some promise but had many areas in need of improvement.

READ MORE
Can We Use Mixture Models to Predict Market Bottoms?
EducationPython

Can We Use Mixture Models to Predict Market Bottoms?

Post Outline * Recap * Hypothesis * Strategy * Conclusion * Caveats and Areas of Exploration * References Recap In Part 1 we learned about Hidden Markov Models and their application using a toy example involving a lazy pet dog. In Part 2 we learned about the expectation-maximization algorithm, K-Means, and how Mixture Models improve on K-Means weaknesses. If you still have some questions or fuzzy understanding about these topics, I would recommend reviewing the prior posts. In those po

READ MORE
Intro to Expectation-Maximization, K-Means, Gaussian Mixture Models with Python, Sklearn
PythonQuant

Intro to Expectation-Maximization, K-Means, Gaussian Mixture Models with Python, Sklearn

Post Outline * Part 1 Recap * Part 2 Goals * Jupyter (IPython) Notebook * References part 1 recap In part 1 of this series we got a feel for Markov Models, Hidden Markov Models, and their applications. We went through the process of using a hidden Markov model to solve a toy problem involving a pet dog. We concluded the article by going through a high level quant finance application of Gaussian mixture models to detect historical regimes. part 2 goals In this post, my goal is to impar

READ MORE
Introduction to Hidden Markov Models with Python Networkx and Sklearn
EducationPython

Introduction to Hidden Markov Models with Python Networkx and Sklearn

Post Outline * Who is Andrey Markov? * What is the Markov Property? * What is a Markov Model? * What makes a Markov Model Hidden? * A Hidden Markov Model for Regime Detection * Conclusion * References Who is Andrey Markov? Markov was a Russian mathematician best known for his work on stochastic processes. The focus of his early work was number theory but after 1900 he focused on probability theory, so much so that he taught courses after his official retirement in 1905 until his death

READ MORE
Understanding Hidden Variables with Python - Research Roadmap
PythonQuant

Understanding Hidden Variables with Python - Research Roadmap

Post Outline * Motivating the Journey * Where Do Edges Come From? * The Problem with Traditional Research * The Hidden Side * A Brief Description: * Part 1 - A Visual Introduction to Hidden Markov Models with Python * Part 2 - Exploring Mixture Models with Scikit-Learn and Python * Part 3 - Predicting Market Bottoms with Scikit-Learn and Python Motivating the Journey Where do Edges Come From? Edges come from superior ability to identify and execute profitable strategies

READ MORE
Advanced Time Series Plots in Python
PythonEducation

Advanced Time Series Plots in Python

POST OUTLINE 1. Motivation 2. Get Data 3. Default Plot with Recession Shading 4. Add Chart Titles, Axis Labels, Fancy Legend, Horizontal Line 5. Format X and Y Axis Tick Labels 6. Change Font and Add Data Markers 7. Add Annotations 8. Add Logo/Watermarks MOTIVATION Since I started this blog a few years ago, one of my obsessions is creating good looking, informative plots/charts. I've spent an inordinate amount of time learning how to do this and it is still a work in a progress. Howe

READ MORE
Backtesting the Implied Volatility Long/Short Strategy (12/31/16)
QuantResearch

Backtesting the Implied Volatility Long/Short Strategy (12/31/16)

Post Outline * Strategy Summary * References * 4-Week Holding Period Strategy Update * 1-Week Holding Period Strategy Updated (Target Leverage=2) Strategy Summary This is a stylized implementation of the strategy described in the research paper titled "What Does Individual Option Volatility Smirk Tell Us About Future Equity Returns" by Yuhang Xing, Xiaoyan Zhang and Rui Zhao. The authors show that their SKEW factor predicts individual equity returns up to 6 months! ABSTRACT Stocks exhi

READ MORE