Difference between revisions of "Spring 2020 Project 6: Indicator Evaluation"
Line 11: | Line 11: | ||
* 2/24 Added text to Technical Indicator about momentum and volatility | * 2/24 Added text to Technical Indicator about momentum and volatility | ||
* 2/26 Updated Theoretically Optimal Strategy API call example | * 2/26 Updated Theoretically Optimal Strategy API call example | ||
+ | * 3/2 Strikethrough out of sample dates in the Data Details, Dates and Rules section | ||
==Overview== | ==Overview== |
Latest revision as of 21:49, 2 March 2020
Contents
Due Date
03/15/2020 11:59PM Anywhere on Earth time
Revisions
This assignment is subject to change up until 3 weeks prior to the due date. We do not anticipate changes; any changes will be logged in this section.
- 2/21 Added links to Technical Trading video and vectorize_me powerpoint.
- 2/21 Added README.txt instructions
- 2/24 Added text to Technical Indicator about momentum and volatility
- 2/26 Updated Theoretically Optimal Strategy API call example
- 3/2 Strikethrough out of sample dates in the Data Details, Dates and Rules section
Overview
In this project you will develop technical indicators and a Theoretically Optimal Strategy that will be the ground layer of a later project. Theoretically Optimal Strategy will give a baseline to gauge your later project against. The technical indicators you develop will be utilized in your later project to devise an intuition-based trading strategy and a Machine Learning based trading strategy. We hope Machine Learning will do better than your intuition, but who knows?
Please keep in mind that completion of this project is pivotal to Project 8 completion
Template
There is no distributed template for this project. You should create a directory for your code in ml4t/manual_strategy and make a copy of util.py there. You will have access to the data in the ML4T/Data directory but you should use ONLY the API functions in util.py to read it.
You should create the following code files for submission. They should comprise ALL code from you that is necessary to run your evaluations.
- indicators.py Your code that implements your indicators as functions that operate on dataframes. The "main" code in indicators.py should generate the charts that illustrate your indicators in the report.
- marketsimcode.py An improved version of your marketsim code that accepts a "trades" data frame (instead of a file). More info on the trades data frame below. It is OK not to submit this file if you have subsumed its functionality into one of your other required code files.
- TheoreticallyOptimalStrategy.py Code implementing a TheoreticallyOptimalStrategy object (details below). It should implement testPolicy() which returns a trades data frame (see below). The main part of this code should call marketsimcode as necessary to generate the plots used in the report.
Note that we may not test your code, so we may not know if you didn't organize your code as recommended, but this arrangement will be required for later projects, so it is worthwhile getting it set up this way. The key requirement is that, if necessary, a TA should be able to run your code on a buffet machine and get the same results (e.g., statistics and charts) that we see in your report.
Data Details, Dates and Rules
- Use only the data provided for this course. You are not allowed to import external data.
- Please add in an author function to each file.
- For your report, use only the symbol JPM. This will enable us to more easily compare results.
- Use the time period January 1, 2008 to December 31 2009.
The out of sample/testing period is January 1, 2010 to December 31 2011.Not used for this project- Starting cash is $100,000.
- Allowable positions are: 1000 shares long, 1000 shares short, 0 shares.
- Benchmark: The performance of a portfolio starting with $100,000 cash, investing in 1000 shares of JPM and holding that position.
- There is no limit on leverage.
- Transaction costs for TheoreticallyOptimalStrategy: Commission: $0.00, Impact: 0.00.
- Correct trades df format used.
Tasks
Technical Indicators
Develop and describe 5 technical indicators. You may find our lecture on time series processing, Technical Analysis video and vectorize_me powerpoint to be helpful. For each indicator you should create a single, compelling chart that illustrates the indicator.
As an example, you might create a chart that shows the price history of the stock, along with "helper data" (such as upper and lower Bollinger Bands) and the value of the indicator itself. Another example: If you were using price/SMA as an indicator you would want to create a chart with 3 lines: Price, SMA, Price/SMA. In order to facilitate visualization of the indicator you might normalize the data to 1.0 at the start of the date range (i.e. divide price[t] by price[0]).
Your report description of each indicator should enable someone to reproduce it just by reading the description. We want a written detailed description here, not code, however, it is OK to augment your written description with a pseudocode figure. Do NOT copy/paste code parts here as a description.
You should have already successfully coded the Bollinger Band feature:
bb_value[t] = (price[t] - SMA[t])/(2 * stdev[t])
Two other good features worth considering are momentum and volatility.
momentum[t] = (price[t]/price[t-N]) - 1
Volatility is just the stdev of daily returns.
It is usually worthwhile to standardize the resulting values (see https://en.wikipedia.org/wiki/Standard_score).
You are allowed to use two indicators presented in the lectures (SMA, Bollinger Bands, RSI) but the other three will need to come from outside the class material.
Theoretically Optimal Strategy
Assume that you can see the future, but that you are constrained by the portfolio size and order limits as specified above. Create a set of trades that represents the best a strategy could possibly do during the in sample period. The reason we're having you do this is so that you will have an idea of an upper bound on performance.
The intent is for you to use adjusted close prices with the market simulator that you wrote earlier in the course. For this activity, use $0.00, and 0.0 for commissions and impact respectively.
Provide a chart that reports:
- Benchmark (see definition above) normalized to 1.0 at the start: Green line
- Value of the theoretically optimal portfolio (normalized to 1.0 at the start): Red line
You should also report in text:
- Cumulative return of the benchmark and portfolio
- Stdev of daily returns of benchmark and portfolio
- Mean of daily returns of benchmark and portfolio
Your code should implement testPolicy() as follows:
import TheoreticallyOptimalStrategy as tos df_trades = tos.testPolicy(symbol = "AAPL", sd=dt.datetime(2010, 1, 1), ed=dt.datetime(2011,12,31), sv = 100000)
The input parameters are:
- symbol: the stock symbol to act on
- sd: A datetime object that represents the start date
- ed: A datetime object that represents the end date
- sv: Start value of the portfolio
The output result is:
- df_trades: A data frame whose values represent trades for each day. Legal values are +1000.0 indicating a BUY of 1000 shares, -1000.0 indicating a SELL of 1000 shares, and 0.0 indicating NOTHING. Values of +2000 and -2000 for trades are also legal so long as net holdings are constrained to -1000, 0, and 1000.
Implement author() function (deduction if not implemented)
You should implement a function called author() that returns your Georgia Tech user ID as a string. This is the ID you use to log into Canvas. It is not your 9 digit student number. Here is an example of how you might implement author():
def author(): return 'tb34' # replace tb34 with your Georgia Tech username.
Implementing this method correctly does not provide any points, but there will be a penalty for not implementing it.
README.txt
Create a README.txt file that has:
- Description of what each file is for/does
- explicit instructions on how to properly run your code.
Report
Describe each indicator you use in sufficient detail that someone else could reproduce it. You should also provide a compelling description regarding why that indicator might work and how it could be used. You should also provide one or more charts that convey how each indicator works in a compelling way. (up to 10 charts).
For the Theoretically Optimal Strategy, describe how you created it and any assumptions you had to make to make it work. Provide a chart that illustrates its performance versus the benchmark.
What to turn in
Be sure to follow these instructions diligently! No zip files.
Submit the following files (only) via Canvas before the deadline:
- Project 6: Indicator Evaluation (Report)
- Your report as report.pdf.
- Project 6: Indicator Evaluation (Code)
- Your code as indicators.py, TheoreticallyOptimalStrategy.py and marketsimcode.py (optional if needed)
- readme.txt document
Unlimited resubmissions are allowed up to the deadline for the project.
Rubric
Report
General
- Neatness (up to 5 points deduction if not).
- Bonus for exceptionally well written reports (up to 2 points)
- Is the required report provided (-100 if not)
Indicators
- Is at least three indicators different from those provided by the instructor's code or lectures (i.e., another indicator that is not SMA, Bollinger Bands or RSI) (-15 points each if not)
- Does the submitted code indicators.py properly reflect the indicators provided in the report (up to -75 points if not)
Individual Indicators (up to 15 points potential deductions per indicator):
- Is there a compelling description why the indicator might work (-5 if not)
- Is the indicator described in sufficient detail that someone else could reproduce it? (-5 points if not)
- Is there a chart for the indicator that properly illustrates its operation including properly labeled axis and legend? (up to -5 points if not)
Theoretically optimal (up to 20 points potential deductions):
- Is the methodology described correct and convincing? (-10 points if not)
- Is the chart correct (dates and equity curve) including properly labeled axis and legend (up to -10 points if not)
- Historic value of benchmark normalized to 1.0 with green line (-5 if not)
- Historic value of portfolio normalized to 1.0 with red line (-5 if not)
- Are the reported performance criteria correct ? See appropriate section for required stats. (-2 points for each item if not)
Code
Is the required code provided, including code to recreate the charts and usage of correct trades data frame. DO NOT use plt.show() and manually save your charts. The charts should be created and saved using Python code (up to -100 if not)
Auto-Grader
No auto-grader for this assignment
Required, Allowed & Prohibited
Required:
- Your project must be coded in Python 3.6.x.
- Your code must run on one of the university-provided computers (e.g. buffet01.cc.gatech.edu).
- Use only the API functions in util.py to read data.
- All charts must be generated in Python, and you must provide the code you used.
Allowed:
- You can develop your code on your personal machine, but it must also run successfully on one of the university provided machines or virtual images.
- Your code may use standard Python libraries.
- You may use the NumPy, SciPy, matplotlib and Pandas libraries. Be sure you are using the correct versions.
- Code provided by the instructor, or allowed by the instructor to be shared.
- A herring.
Prohibited:
- Generating charts using a method other than Python.
- Any other method of reading data besides util.py
- Modifying (or depending on modifications to) util.py.
- Any libraries not listed in the "allowed" section above.
- Any code you did not write yourself.
FAQ
- Q: I want to read some other values from the data besides just adjusted close, how can I do that?
A: Look carefully at util.py and you will see that you can query for other values.
- Q: Are we only allowed one position at a time?
A: You can be in one of three states: -1000 shares, +1000 shares, 0 shares.
- Q: Are we required to trade in only 1000 share blocks? (and have no more than 1000 shares long or short at a time?
A: You can trade up to 2000 shares at a time as long as you maintain the requirement of holding 1000, 0 or -1000 shares.
- Q: Are we limited to leverage of 2.0 on the portfolio?
A: There is no limit on leverage.