Skip to main content

Posts

Simple moving average trading strategy using Python

Hi All, I am presenting simple boiler point code that can quickly be applied to test technical indicator strategies using Python. The code: 1. downloads daily stock data from google, 2. calculates the short and long moving averages 3. generates the trading signals 4. calculates the daily returns 5. runs the moving average strategy and calculates the cumulative return 6. plots cumulative return of our simple strategy Here is the code ... enjoy trying it out and extend it as required: import numpy as np import pandas_datareader as datar import datetime import matplotlib.pyplot as plt date_start = datetime.datetime( 2017 , 1 , 1 ) date_end = datetime.datetime( 2017 , 6 , 30 ) data = datar.get_data_google( 'AAPL' , date_start , date_end) short_ma = 5 long_ma = 20 data[ 'short_ma' ] = data[ 'Close' ].rolling(short_ma).mean() data[ 'long_ma' ] = data[ 'Close' ].rolling(long_ma).mean() data[ 'masig' ] = data[ 'short_ma...
Recent posts

Type-2 Fuzzy Logic in High Frequency Trading

In a recent journal publication we investigate the viability of Type-2 fuzzy systems in high frequency trading. We propose Type-2 models based on a generalisation of the popular ANFIS model (ANFIS/T2). Type-2 models score significant risk adjusted performance improvements over Type-1. Benefits of Type-2 models increase with higher trading frequencies. Paper available at: http://www.sciencedirect.com/science/article/pii/S0957417416300203

What software architects/developers frequently forget ...

When looking at code or architectures, sometimes I get the feel that developers forget that the art of programming, or any other problem solving task, is really the beauty of being able to transform a complex problem into a series of simple, well defined logical steps. Here is what some of the most intelligent people the world has ever seen remind us: “If you can't explain it to a six year old, you don't understand it yourself.”  ―  Albert Einstein “Simplicity is the ultimate sophistication.”  ―  Leonardo da Vinci "Fools ignore complexity. Pragmatists suffer it. Some can avoid it. Geniuses remove it." - Alan Perlis So, the gist of the story, the role of an excellent developer or architect is not to complicate the simple, but to simplify the complicated. Sometimes people can easily get mislead about the beauty of a solution by admiring its complexity, but really and truly the greatness lies in the ability to simplify a complex problem.

Data Visualisation tools

At the moment I am looking for some data visualisation tools. Here is an interesting link with some great visualisation tools I met. Web Link