Intraday Stock Mean Reversion Trading Backtest in Python With Short Selling Carrying on from the last post which outlined an intra-day mean reversion stock trading strategy, I just wanted to expand on that by adapting the backtest to allow short selling too. So as well as buying stocks that have gapped down, we will be…Continue Reading “Intraday Stock Mean Reversion Trading Backtest in Python With Short Selling”

Intraday Stock Mean Reversion Trading Backtest in Python After completing the series on creating an inter-day mean reversion strategy, I thought it may be an idea to visit another mean reversion strategy, but one that works on an intra-day scale. That is, we will be looking for the mean reversion to take place within one…Continue Reading “Intraday Stock Mean Reversion Trading Backtest in Python”

Staying on the same topic of optimisation that we visited in the last post concerning portfolio holdings and efficient frontiers/portfolio theory, I thought I would quickly revisit the moving average crossover strategy we built a few posts ago; the previous article can be found here. Optimisation of Moving Average Crossover Trading Strategy In Python In…Continue Reading “Optimisation of Moving Average Crossover Trading Strategy In Python”

In this post I’ll be looking at investment portfolio optimisation with python, the fundamental concept of diversification and the creation of an efficient frontier that can be used by investors to choose specific mixes of assets based on investment goals; that is, the trade off between their desired level of portfolio return vs their desired…Continue Reading “Investment Portfolio Optimisation with Python”

Welcome back…this post is going to deal with a couple of questions I received in the comments section of a previous post, one relating to a moving average crossover trading strategy – the article can be found here. The questions I received at first asked whether the code for the backtest could be adapted to…Continue Reading “Moving Average Crossover Trading Strategy Backtest in Python – V 2.0”

Monte Carlo Simulation in Python – Simulating a Random Walk Ok so it’s about that time again – I’ve been thinking what my next post should be about and I have decided to have a quick look at Monte Carlo simulations. Wikipedia states “Monte Carlo methods (or Monte Carlo experiments) are a broad class of…Continue Reading “Monte Carlo Simulation in Python – Simulating a Random Walk”

In this post I thought I’d take advantage of the results we got from the moving average crossover strategy backtest in the last post (can be found here), and spend a bit of time digging a little more deeply into the equity curve and producing a bit of analysis concerning some key performance indicators and…Continue Reading “Analysis of Moving Average Crossover Strategy Backtest Returns Using Pandas”

Hi all, for this post I will be building a simple moving average crossover trading strategy backtest in Python, using the S&P500 as the market to test on. A simple moving average cross over strategy is possibly one of, if not the, simplest example of a rules based trading strategy using technical indicators so I…Continue Reading “Moving Average Crossover Trading Strategy Backtest in Python”

I thought I’d finish off this short series of Python Backtesting Mean Reversion by providing a full, executable script that incorporates the use of SQL queries to extract our ticker symbols from the SQLite database we created in an earlier post (This can be found here) In this particular example I have decided to run…Continue Reading “Python Backtesting Mean Reversion – Part 4”

Right, welcome back and sorry for the slight delay between posts…I’ve been way more busy than I had hoped. Onto our python backtesting! So this, I guess, could be considered the first proper post regarding the ETF mean reversion backtest script we’re trying to come up with. In the last post we went over creating…Continue Reading “Python Backtesting – ETF Mean Reversion – creating the ticker pairs”

SQLite database python web scrape… As promised, here is the first part of my “ETF mean reversion strategy backtest” series. This article deals with scraping ETF data from the web and sticking it in an SQLite3 database. I’m using SQLite as it’s very easy to set up, and requires nothing complex to get up and…Continue Reading “Scraping ETF data from the web and sticking it in an SQLite3 database”

python skew kurtosis

Python…skew…kurtosis… So you have a series of returns you wish to analyse….mean and variance are easy to calculate…how easy does Python make it to calculate skew and kurtosis? When we look at a series of investment returns, we tend to concentrate on the first 2 ‘moments’ of the distribution; that is the mean and the…Continue Reading “What are ‘skew’ lookin’ at? – calculating skew and kurtosis with Python…”

Ok so I thought it was about time we got into the nitty gritty of some “financial analysis”, rather than have me spout info regarding available beginners courses like I’m some sort of salesman. “I want to do some analysis”, I hear you scream… Well ok then…let’s start. With the Python Pandas module. So financial…Continue Reading “Python Pandas…Eats, shoots and leaves…?”

As promised in the last blog post, it’s time to review some of the beginner resource material mentioned previously, aimed at those who want to learn Python. I’ve decided to start off with the courses provided by Coursera ( They were my second port of call after when I first started learning Python on…Continue Reading “Want to learn Python? Coursera…of course!”

Ok, so…it’s time to get started. I thought the best thing to begin with would be to do a bit of research regarding available resources for beginner Python students. As I mentioned in a previous post, I have dabbled on and off (although very lightly) with learning Python, using some starter resources over the last…Continue Reading “Learning Python – From a single acorn grows…”

learn python

I will be posting here regarding my journey to learn Python for use in designing and building automated trading strategies, along with general data analysis and perhaps (eventually) some web based python involving Flask and Django. I have been meaning to do this for some time (especially on the automated trading strategy side of things),…Continue Reading “Learn Python for finance, trading and data analysis –the journey begins!”