# Event Driven Portfolio Analyzer

This project is the homework from the Coursera class Computational Investing. I enjoyed this class while working through it. The way that the individual pieces work together at the end of the class really make this course great. It’s akin to a movies tying up loose ends in the last five minutes.

HW1
In the first assignment, there were four parts.
Part 1 – Get familiar with the QSTK library
Part 2 – Write a Python function that can simulate and assess the performance of a 4 stock portfolio. The inputs were Start Date, End Date, the list of Symbols and the allocation weights.
The function returns the Standard deviation of daily returns of the total portfolio, the Average daily return of the total portfolio, Sharpe ratio and finally Cumulative return of the total portfolio.
Part 3 – Using the portfolio analyzer, find the optimal portfolio. I went with a naive brute force approach. More on this later.
Part 4 – Create a chart that illustrates the value of your portfolio over the year and compares it to SPY.

HW2
Assignment two also had four parts to process.
Part 1 – Get familiar with the event matrix in QSTK.
Part 2 – Create an event study with given parameters.
Part 3 – Create your own event study.
Part 4 – Compare event study outputs to make sure they match the expected result.

HW3
Assignment three has two parts
Part 1 – Create a market simulator. The starting cash is passed via command file and the orders.csv contains the Year, Month,Day, Symbol, BUY or SELL and Number of Shares
An example line: 2008, 12, 3, AAPL, BUY, 130
The simulator calculates the total value of the portfolio for each day using adjusted closing prices and prints the result to the file values.csv.
Part 2 – Create a portfolio analysis tool. The application plots the price history over the trading period. Your program also outputs Standard deviation of daily returns of the total portfolio,
Average daily return of the total portfolio, Sharpe Ratio and Cumulative return of the total portfolio. (Sound familiar?)

HW4
Assignment four was broken down into three parts
Part 1 – Revise the event analyzer to output a series of trades based on events. Instead of putting a 1 in the event matrix, the output is to a file
Part 2 – Feed that output into the market simulator.
Part 3 – Report the performance of the strategy in terms of total return, average daily return, standard deviation of daily return, and Sharpe Ratio.

HW5
Assignment five contains three parts.
Part 1 – Implement Bollinger bands as an indicator using 20 day look back.
Part 2 – Output the indicator value in a range of -1 to 1.
Part 3 – Implement your own indicator and have it report in a range of -1 to 1.

HW6
Assignment six contains three parts.
Part 1 – Implement Bollinger bands as an indicator using 20 day look back.
Part 2 – Create an event study with the signal being Bollinger value for the equity today <= -2.0, Bollinger value for the equity yesterday >= -2.0 and Bollinger value for SPY today >= 1.0.
Part 3 – Use the indicator you created as the part 2 of the homework 5 and create an event study to find potentially interesting results.

Assignment seven uses the HW6 code to tie the project all together as I alluded to earlier
Part 1 – Implement Bollinger bands as an indicator using 20 day look back.
Part 2: Now create an event study with the signal same as in assignment six.
Part 3: Revise your event analyzer to output a series of trades based on events; Instead of putting a 1 in the event matrix, output to a file. Same as assignment four.
Part 4: Feed that output into your market simulator. Just like assignment four.
Part 5: Report the performance of your strategy in terms of total return, average daily return, STDDEV of daily return, and Sharpe Ratio for the time period. As seen in assignment one, three and four.