That's a Big Idea
Categories
  • Personal (53)
    • Finance & Trading (6)
    • Music (5)
    • Parenting (12)
    • Projects (11)
    • Topical (18)
    • Travel (1)
  • Technology (11)
    • Application Development (8)
    • Product Management (1)
    • Recruiting (2)
Archives
  • July 2024 (1)
  • June 2024 (1)
  • August 2022 (1)
  • October 2017 (1)
  • September 2017 (10)
  • August 2017 (1)
  • June 2017 (1)
  • February 2017 (1)
  • November 2016 (1)
  • October 2016 (6)
  • April 2014 (1)
  • March 2014 (5)
  • March 2013 (2)
  • March 2012 (1)
  • February 2012 (1)
  • January 2012 (1)
  • December 2011 (2)
  • November 2011 (7)
  • October 2011 (10)
  • September 2011 (8)
That's a Big Idea
  • Notes on Technology
    • Application Development
    • Recruiting
    • Product Management
  • Stuff I Think About
    • Finance & Trading
    • Music
    • Parenting
    • Projects
    • Topical
    • Travel
  • About Me
    • Who am I?
    • Random Side Projects
  • Finance & Trading

Analysis of Technical Analysis

  • craig
  • March 8, 2013
close up photo of data in a monitor
Photo by Romulo Queiroz on Pexels.com

I’ve put together a small framework for testing out technical-based trading strategies.  You can create indicators, generate trading signals, calculate P&L, and chart the results.  I know there are a bunch of mature packages out there that do this, but it’s a fun thought experiment.  The code is public in case it’s of interest.  I may throw a few random studies up here showing the futility of technical analysis, which is the consistent result of my experience with it.

As an example, consider this strategy:

  • Buy when the price > VWAP * 1.005
  • Sell when the price < VWAP * .995 (and there’s an open position)
  • Long only, starting cash of $10000, run from 1/1/2012 through 1/3/2013, trading just SPY, no transaction costs

Strategy P&L = $871 vs Buy & Hold = $2028

In addition to showing the price movement and signals, this chart demos some other random indicators.

If you reverse the strategy and go contrarian (buy with a price dip instead of buying on the trend movement), the strategy beats the Buy & Hold performance, earning $2129 (that’s above and beyond the initial $10k outlay).  The contrarian strategy, if run from 1/1/2005 actually earns a profit of $17K compared to $4.6K for just buying and holding!  Anyway, this framework makes it easy to backtest strategies, test a universe of securities, and look at how different indicators perform.  It’d also be easy to extend the backtester to note additional interesting stats, such as max drawdown.

Happy to help test out any strategies – feel free to drop them in the comments.

You May Also Like
stacks of coins
View Post

Tracking Personal Finances

graphs display on an ipad
View Post

Analysis of Moving Average Triggers

blur board game business challenge
View Post

Trading Games… Working the Limits

3 comments
  1. Gautam Kishore says:
    April 7, 2016 at 7:54 am

    Thanks Craig, nice article and great work in code. Can you please mention those “bunch of mature packages” as well?

  2. Craig Perler says:
    April 7, 2016 at 10:05 am

    Thank you Gautam. I think the most well known mature package is zipline (https://github.com/quantopian/zipline) which is used by the site Quantopian, definitely check that out if you have any interest in putting these sorts of algorithms together.

  3. Harrison Delfino says:
    May 1, 2017 at 4:40 am

    I like using MarketXLS for this. It’s great for me.

Comments are closed.

Read Next
  • Illustration of code being packed into a truck and shipped off to a server factory, featuring a neon color palette with purples and pinks and a matrix-like tech-themed background.
    Deploying a Dockerized Django Application to Production
    • July 2, 2024
  • How to Set up Django with Docker, PostgreSQL and React
    • June 5, 2024
  • resume checklist next to a computer
    How to Craft and Optimize an Awesome Tech Resume
    • August 20, 2022
  • Most Common First Baby Words
    • October 5, 2017
  • baby blocks
    12 Proven Ways to Improve Baby Name Recognition
    • September 28, 2017
I’m Everywhere!
I'm Everywhere! FacebookI'm Everywhere! TwitterI'm Everywhere! LinkedInI'm Everywhere! YouTubeI'm Everywhere! GithubI'm Everywhere! VimeoI'm Everywhere! Goodreads
Craig Perler's Blog
That's a Big Idea!

Input your search keywords and press Enter.