This category contains 14 posts


John wrote a great post a few months back on the virtues of lazy evaluation and using this to generate infinite length geometric Brownian motion prices series. Lazy evaluation is popular in functional programming, whereby the evaluation of expressions is deferred until when they are actually needed. The purely functional language Haskell defaults to lazy … Continue reading »

Variance Factors on VIX Futures II - Principal Component Analysis

In my last post I demonstrated how you can generate synthetic futures prices. In this post I am going to build on this and show how you can apply principal component analysis (PCA) to determine how much of the variability in returns each of the different futures are responsible for. Creating our data set was … Continue reading »

Variance Factors on VIX Futures I - Synthetic Futures

In her paper on ETNs on VIX futures, Carol Alexander demonstrates how principal component analysis can be used to identify the main variance factors in the term structure of the VIX. Over the next couple of posts I am going to demonstrate how you can implement this. Principal component analysis (PCA) is a useful tool … Continue reading »

VIX Futures Expiry Dates

As VIX futures do not expire on the same day each month, I thought I'd share the following code you can use to determine the when the next expiry date is. There is one caveat - if the CBOE is closed on the third Friday of the month the date moves back one day, you'll … Continue reading »

Quickly run up microservices for your trading apps

In todays world of microservices, Flask is a great compact framework in Python for quickly creating web services. For simple services, it's faster to work with then Django (which incidentally is great for more complex services/sites). For instance, you can build a self-contained service that serves up random price data over JSON, in 15 lines … Continue reading »

Calculating Realistic Strategy Returns

In researching different trading strategies, you will come across simplified reference implementations, whereby your position in an asset is simply the price at a given point in time. Price returns can then be calculated based these prices, which can then be fed into a further calculation such as the Sharpe ratio or other risk-adjusted performance … Continue reading »

Visualising Strategy Drawdowns

Along with the Sharpe Ratio, the drawdown of a trading strategy is one of the most common indicators you will see used to evaluate its performance. The drawdown is simply the decline in value of a strategy at a point in time since a previous high. It's important as it gives you an indication of … Continue reading »

Modelling Asset Returns with Brownian Motion

The geometric Brownian motion model allows you to generate a series of prices for an asset. It is a type of stochastic process that follows a Brownian motion path with a drift. Stochastic processes are a concept from probability theory which are used to model the change in a seemingly random process over time. Brownian … Continue reading »

Parkinson Versus Close to Close Volatility Estimators

The Parkinson volatility estimator provides an alternative to the close to close estimator for determining historical price volatility. It uses a range based sample interval - high() and low() price log returns in its estimates, instead of a fixed sample interval such as the close price log returns used by the close to close estimator. … Continue reading »

Automatic Validation of Trading Models

One of the significant challenges faced with creating your own trading models is validation of their correctness. Usually you find a model, implement it in your favourite language, then run some numbers through it to verify it. The verification is often the tricky part, as you simply cannot afford to make mistakes in your calculations. … Continue reading »