MC2-Project-2

From Quantitative Analysis Software Courses
Revision as of 15:19, 28 October 2015 by Tucker (talk | contribs) (→‎Updates)
Jump to navigation Jump to search

Updates/FAQs

2015/10/28: Fixed filenames, replacing hyphens with underscores: bollinger_strategy.py, my_strategy.py

2015/10/28: Example chart for Bollinger Band Chart added.

2015/10/28: Q: Do we show all entry and exit signals or just the ones that are actually relevant for our current positions? For example, if there is an exit signal but we don't hold a position that would be exited yet do we show it on the chart? A: Only show the ones relevant to your current positions.

Overview

In this project you will develop trading strategies using Technical Analysis, then test them using your market simulator.

In this project we shift from an auto graded code format to a report format. For this project your grade will be based on the PDF report you submit. You will also submit your code that will be checked visually to ensure it appropriately matches the report you submit.

Template

Create your code within a directory named ml4t/mc2_p2/. Within that directory you should create/write two python files as follows:

  • bollinger_strategy.py: This code should generate a .png chart that illustrates the bollinger bands, and entry and exit points for a bollinger-based strategy.

It should also generate an orders.txt file that you feed into your market simulator to backtest the strategy.

  • my_strategy.py: This code should generate a .png chart (or charts) that illustrate the clever strategy you develop, along with indications of entry and exit points. It should also generate an orders.txt file that you feed into your market simulator to backtest the strategy.

You will submit all of the above code files along with your PDF report.

Time Period and Stock for Testing

We will use IBM and trade it from December 31, 2007 until December 31, 2009.

Part 1A: Bollinger Band Strategy Chart (15%)

If you don't know about Bollinger Bands already, go learn about them. Here are some references:

Here are the essential things you need to know and to implement. In addition to the price of a stock over time, Bollinger Bands include:

  • 20 day simple moving average (SMA) line.
  • Upper Band = SMA + 2 * 20 day standard deviation.
  • Lower Band = SMA - 2 * 20 day standard deviation.

A basic Bollinger Band trading strategy works as follows: There are two potential entries, long and short. The long entry is made when the price transitions from below the lower band to above the lower band. This indicates that the stock price has moved substantially away from the moving average, but is now moving back towards the moving average. When this entry signal criteria is met, buy the stock and hold it until the exit. The exit signal occurs when the price moves from below the SMA to above it.

The short entry and exit are mirrors of the long entry and exit: The short entry is made when the price transitions from above the upper band to below the upper band. This indicates that the stock price has moved substantially away from the moving average, but is now moving back towards the moving average. When this entry signal criteria is met, short the stock and hold it until the exit. The exit signal occurs when the price moves from above the SMA to below it.

You should create a chart that shows:

  • Stock price (adjusted close)
  • SMA
  • Upper Band
  • Lower Band
  • Long entries as a vertical green line at the time of entry.
  • Long exits as a vertical black line at the time of exit.
  • Short entries as a vertical RED line at the time of entry.
  • Short exits as a vertical black line at the time of exit.

Bb-example-small.png

Part 1B: Bollinger Band Strategy Backtest (15%)

Reuse your charting code to generate trades. Start with $10,000. For a long entry, BUY 100 shares and hold until the exit. For a short entry, SELL 100 shares and hold until the exit. Chart the performance of your fund over the time period described in "what to turn in" below.

Part 2: Your Strategy (70%)

For this component of the project you are to devise your own Technical Analysis-based signal. You should write code to create a chart that shows relevant information about the indicator, including long and short entry and exit events. Your strategy should outperform the Bollinger Band strategy described above (in terms of cumulative return).

Contents of the Report

Your report (PDF -- do not even think of submitting a Word document) should contain the following elements:

Part 1:

  • Bollinger Band strategy chart.
  • Bollinger Band strategy backtest chart.
  • Summary of Bollinger Band backtest performance metrics.

Part 2:

  • Written description of your strategy idea. You will be graded on the clarity of your description and also on how compelling an idea it is.
  • Chart or charts that illustrate your strategy idea. At least one of the charts should be similar to the Bollinger Band strategy chart.
  • Backtest chart of your strategy.
  • Analysis of the performance of your strategy idea over the 2008-2009 period. Note that your strategy should outperform the Bollinger Band strategy.
  • Summary of backtest performance metrics.

Implementation Suggestions

Consider augmenting the Bollinger Band strategy with additional consideration of the SPY's Bollinger values. If the individual stock is substantially different, this could signal an important move for the stock.

What to turn in

Be sure to follow these instructions diligently!

Via T-Square, submit as attachment (no zip files; refer to schedule for deadline):

  • Your code as bollinger_strategy.py, my_strategy.py
  • Your report as report.pdf

Unlimited resubmissions are allowed up to the deadline for the project.

Rubric

TBD