Now, it's time to take what you've learned about machine learning and apply it to new situations. For this optional assignment, you'll create an algorithmic trading bot that learns and adapts to new data and evolving markets. Be sure to give it your all -- as the skills you hone will become powerful tools in your FinTech tool belt.
In this Challenge, you’ll assume the role of a financial advisor at one of the top five financial advisory firms in the world. Your firm constantly competes with the other major firms to manage and automatically trade assets in a highly dynamic environment. In recent years, your firm has heavily profited by using computer algorithms that can buy and sell faster than human traders.
The speed of these transactions gave your firm a competitive advantage early on. But, people still need to specifically program these systems, which limits their ability to adapt to new data. You’re thus planning to improve the existing algorithmic trading systems and maintain the firm’s competitive advantage in the market. To do so, you’ll enhance the existing trading signals with machine learning algorithms that can adapt to new data.
You’ll combine your new algorithmic trading skills with your existing skills in financial Python programming and machine learning to create an algorithmic trading bot that learns and adapts to new data and evolving markets.
In a Jupyter notebook, you’ll do the following:
-
Implement an algorithmic trading strategy that uses machine learning to automate the trade decisions.
-
Adjust the input parameters to optimise the trading algorithm.
-
Train a new machine learning model and compare its performance to that of a baseline model.
As part of your GitHub repository’s README.md
file, you will also create a report that compares the performance of the machine learning models based on the trading predictions that each makes and the resulting cumulative strategy returns.
Download the following files to help you get started:
Note: The provided CSV file contains OHLCV data for an MSCI–based emerging markets ETF that iShares issued. Investments in emerging markets make up an important aspect of a well-diversified investment portfolio. This is because the included equities have potentially higher long-term returns, even though they carry more risk.
Use the starter code file to complete the steps that the instructions outline. The steps for this Challenge are divided into the following sections:
-
Establish a Baseline Performance
-
Tune the Baseline Trading Algorithm
-
Evaluate a New Machine Learning Classifier
-
Create an Evaluation Report
In this section, you’ll run the provided starter code to establish a baseline performance for the trading algorithm. To do so, complete the following steps.
Open the Jupyter notebook. Restart the kernel, run the provided cells that correspond with the first three steps, and then proceed to step four.
-
Import the OHLCV dataset into a Pandas DataFrame.
-
Generate trading signals using short- and long-window SMA values.
-
Split the data into training and testing datasets.
-
Use the
SVC
classifier model from SKLearn's support vector machine (SVM) learning method to fit the training data and make predictions based on the testing data. Review the predictions. -
Review the classification report associated with the
SVC
model predictions. -
Create a predictions DataFrame that contains columns for “Predicted” values, “Actual Returns”, and “Strategy Returns”.
-
Create a cumulative return plot that shows the actual returns vs. the strategy returns. Save a PNG image of this plot. This will serve as a baseline against which to compare the effects of tuning the trading algorithm.
-
Write your conclusions about the performance of the baseline trading algorithm in the
README.md
file that’s associated with your GitHub repository. Support your findings by using the PNG image that you saved in the previous step.
In this section, you’ll tune, or adjust, the model’s input features to find the parameters that result in the best trading outcomes. (You’ll choose the best by comparing the cumulative products of the strategy returns.) To do so, complete the following steps:
-
Tune the training algorithm by adjusting the size of the training dataset. To do so, slice your data into different periods. Rerun the notebook with the updated parameters, and record the results in your
README.md
file. Answer the following question: What impact resulted from increasing or decreasing the training window?Hint To adjust the size of the training dataset, you can use a different
DateOffset
value—for example, six months. Be aware that changing the size of the training dataset also affects the size of the testing dataset. -
Tune the trading algorithm by adjusting the SMA input features. Adjust one or both of the windows for the algorithm. Rerun the notebook with the updated parameters, and record the results in your
README.md
file. Answer the following question: What impact resulted from increasing or decreasing either or both of the SMA windows? -
Choose the set of parameters that best improved the trading algorithm returns. Save a PNG image of the cumulative product of the actual returns vs. the strategy returns, and document your conclusion in your
README.md
file.
In this section, you’ll use the original parameters that the starter code provided. But, you’ll apply them to the performance of a second machine learning model. To do so, complete the following steps:
-
Import a new classifier, such as
AdaBoost
,DecisionTreeClassifier
, orLogisticRegression
. (For the full list of classifiers, refer to the Supervised learning page in the scikit-learn documentation.) -
Using the original training data as the baseline model, fit another model with the new classifier.
-
Backtest the new model to evaluate its performance. Save a PNG image of the cumulative product of the actual returns vs. the strategy returns for this updated trading algorithm, and write your conclusions in your
README.md
file. Answer the following questions: Did this new model perform better or worse than the provided baseline model? Did this new model perform better or worse than your tuned trading algorithm?
In the previous sections, you updated your README.md
file with your conclusions. To accomplish this section, you need to add a summary evaluation report at the end of the README.md
file. For this report, express your final conclusions and analysis. Support your findings by using the PNG images that you created.
-
Use the started code provided to create the machine learning trading bot and host the notebook and the required files.
-
Include a
README.md
file with your conclusions as requested. -
Submit the link to your GitHub project to Bootcamp Spot.
© 2022 Trilogy Education Services, a 2U, Inc. brand. All Rights Reserved.