Wiener-Khinchin theorem and Gaussian processes
By Adrian Letchford · Nov 11, 2023 · 3 min read
There’s a magical little theorem that links a power spectral density to the autocovariance function. You can use this to quickly estimate a Gaussian process of a periodic time series.
Key insights: Imbalance in the order book
By Adrian Letchford · Oct 1, 2023 · 5 min read
I summarise key insights from a few papers studying the limit order book. You’l learn how to measure volume imblanace in the limit order book and how well it predicts price moves.
Intro to Black-Scholes, implied volatility and hedging
By Adrian Letchford · Aug 26, 2023 · 18 min read
A break down of how the Black-Scholes option pricing model works, what implied volatility is and how you can use the model to hedge risks.
Forecasting currency rates with fractional brownian motion
By Adrian Letchford · Aug 9, 2023 · 5 min read
Fractional Brownian motion is a stochastic process that can model mean reversion. Predicting future values turns out to be a simple linear model. This model has significant predictive power when applied to currencies.
Square root of a portfolio covariance matrix
By Adrian Letchford · Jul 27, 2023 · 4 min read
The square root of your portfolio’s covariance matrix gives you a powerful way of understanding where your portfolio variance is coming from. Here I show how to calculate the square root and provide an interactive example to explore how it works.
Recursive least-squares linear regression
By Adrian Letchford · Jul 22, 2023 · 7 min read
Rather than recalculating a least–squares model on each new data point, you can simply update the fitted coefficients. This saves you computational time and allows you to place greater emphasis on recent data.
How to engineer a monitoring system for your trading strategy
By Adrian Letchford · May 12, 2023 · 6 min read
Poorly monitoring your trading strategy means you are missing mistakes and leaving money on the table. By converting your bot’s logs from plain text to JSON you can create a near real time monitoring system and never miss a beat.
Mean reversion in government bonds
By Adrian Letchford · Apr 8, 2023 · 5 min read
Using the Ornstein–Uhlenbeck process, you can calculate the expected spread between bond yields of different maturities. These expected values can then be used to estimated the expected value of treasury ETF spreads.
Calculating the mean and variance of bond returns
By Adrian Letchford · Apr 5, 2023 · 4 min read
Bond returns are a function of yields. Calculating the expected value of this function is quite difficult. You can take a Taylor expansion to make calculating the mean and variance of returns much easier.
Moments of the Gaussian distribution
By Adrian Letchford · Apr 1, 2023 · 3 min read
A reference page listing the moments of a Guassian distribution and shows how to derive co-moments.
Estimating the half-life of a time series
By Adrian Letchford · Mar 18, 2023 · 1 min read
The half-life of a stationary series can be estimated with a linear regression. These notes show the derivation of the half-life from the regression coefficients.
Why Returns Are Not Gaussian
By Adrian Letchford · Mar 12, 2023 · 10 min read
Using the method of moments and building a compound distribution you can demonstrate some of the stylized facts of returns.
How to get 100 years of bond ETF prices
By Adrian Letchford · Nov 24, 2022 · 4 min read
The price of a bond ETF can be estimated from bond yields. You can use this technique to create a long term performance history of an ETF.
Understanding bond ETF returns
By Adrian Letchford · Nov 21, 2022 · 7 min read
The return of a bond ETF can be estimated from bond yields. The distribution of a bond ETF’s returns turns out to be a function of the interest rate, expected change and variance of the interest rate. Bond returns are skewed depending on the interest rate’s level.
Dockerising Interactive Brokers Client Portal API
By Adrian Letchford · Nov 13, 2022 · 2 min read
Interactive Broker’s REST API is a web server that you install and maintain locally in a convoluted fashion. I created a light weight docker image to make things easy.
Invest regularly
By Adrian Letchford · Dec 22, 2020 · 4 min read
Successful investors combine lots of simple things, each one providing a small improvement. One of these simple things is investing regularly.
Measuring performance
By Adrian Letchford · Jun 12, 2020 · 8 min read
How can you measure performance when investing? You might think you can simply measure how much money you make. However, this can lead to losing a large portion of your capital. I want to show you why that can happen and how I measure my own investment performance.
Fast Gaussian Kernel fit for Support Vector Regression
By Adrian Letchford · Jan 7, 2016 · 19 min read
Support vector regression models transform input vectors into a high number of dimensions where the regression problem becomes linear. This new space is defined by a kernel function. A major drawback of these models is that they are slow to fit the kernel parameters. Here I develop an algorithm to quickly fit the Gaussian kernel’s bandwidth parameter. This algorithm is fast, robust on some datasets, and has a similar fit to slower and more exhaustive methods.
Choosing the Gaussian Kernel's Bandwidth
By Adrian Letchford · Aug 6, 2015 · 27 min read
I created two algorithms that quickly optimise the bandwidth parameter for a Gaussian kernel. These algorithms only operate on the independent variables of a modelling task. This means they can be used regardless of the chosen kernel machine model and modelling task.