Hello, dear friend, you can consult us at any time if you have any questions, add WeChat: daixieit


BU MET CS-677: Data Science With Python, v.1.1 

CS-677 Assignment: plot portfolio growth

Assignment


In this assignment you will write a generic script that plots your portfolio growth for several strategies including ”buy-and-hold” and ”true labels?. Recall that buy-and-hold means that you invest $100 in your stack at the beginning of week 1 and do not trade. As your stock varies in price, so does your portfo-lio. By constrast, ”true labels” strategy means that you trade according to the labels (”red” or ”green”) that you assigned ”manually”:

● a ”green” week means that is was a good week to be invested for that week (from the first to last trading day of this week, typically from Monday to Friday).

● a ”red” week means that it was not a good week to be invested but to keep money in cash (e.g. prices fell or there was too much volatility in the price).

In this course, we are implementing a number of machine learn-ing classifiers to predict labels. One way to compare our strate-gies is to compute elements of confusion matrices (e.g. True Positive, False Negative, etc.) Another way is to compare the growth (and volatility) of your (single stock) portfolio. In this assignment we will focus on comparing portfolio performance vs. buy-and-hold and true-labels portfolios.


Questions:

1. plot portfolio growth for ”buy-and-hold”, true labels and 3 nearest neighbor strategies (use optimal k that you com-puted and plot three graphs for kNN for p = 1, 1.5, 2) for year 2. Each of the 5 plots should be in different color. On X-axis is the week number and on the Y -axis is the value of your portfolio for a strategy. In the legend section of the graph, indicate for each strategy an average weekly portfolio value and volatility (standard deviation). In other words, if you have 52 weeks 1, . . . , 52 on X-axis, you com-pute the portfolio values P1, . . . , P52 at the end of weeks 1, . . . , 52 respectively. Then you compute the mean and stadard deviation of these values.

Hint: if you have a Pandas frame where column ’X’ contains week numbers and other columns containing portfolio values, then you can plot all your strategies using Pandas ”plot” method.