In this module, we'd be covering the concept of classification and utilize our skills to solve the following queries – (Stock Price = Close Price)
4.1 Import the csv file of the stock which contained the Bollinger columns as well. Create a new column 'Call' , whose entries are - 'Buy' if the stock price is below the lower Bollinger band 'Hold Buy/ Liquidate Short' if the stock price is between the lower and middle Bollinger band 'Hold Short/ Liquidate Buy' if the stock price is between the middle and upper Bollinger band 'Short' if the stock price is above the upper Bollinger band Now train a classification model with the 3 bollinger columns and the stock price as inputs and 'Calls' as output. Check the accuracy on a test set. (There are many classifier models to choose from, try each one out and compare the accuracy for each) Import another stock data and create the bollinger columns. Using the already defined model, predict the daily calls for this new stock.
4.2 Now, we'll again utilize classification to make a trade call, and measure the efficiency of our trading algorithm over the past two years. For this assignment , we will use RandomForest classifier. Import the stock data file of your choice Define 4 new columns , whose values are: % change between Open and Close price for the day % change between Low and High price for the day 5 day rolling mean of the day to day % change in Close Price 5 day rolling std of the day to day % change in Close Price Create a new column 'Action' whose values are: 1 if next day's price(Close) is greater than present day's. (-1) if next day's price(Close) is less than present day's. i.e. Action [ i ] = 1 if Close[ i+1 ] > Close[ i ] i.e. Action [ i ] = (-1) if Close[ i+1 ] < Close[ i ] Construct a classification model with the 4 new inputs and 'Action' as target Check the accuracy of this model , also , plot the net cumulative returns (in %) if we were to follow this algorithmic model