Explore trading oportunities in Argie bonds using machine learning algorithms.
Machine learning library adopted for the implementation
pip install -U scikit-learn
Import Python package to re-sampling imbalanced datasets
pip install imblearn
Libraries used to create visualizations
pip install matplotlib
pip install seaborn
In order to explore trading opportunities, decided to transform a time series problem into a classification problem. To do so, we first had to create the features. We thus calculated several technical analysis indicatos such as the MACD, RSI and the Bollinger Bands and many trading signals based on the critical. Moreover, we defined the labels by attaching a "Buy" (1) label to those entry points that offered a possitive return five days ahead, and a "Sell" (0) to the rest of the occasions. Take a look at our problem.
Another problem we had to face is the fact that our dataset is imbalanced. Should we run the classification models without solving this problem before hand, we would have trained the parameters incorrectly. The model would be more prone to spotting one label than the other, thus running the risk of making wrong trading decisions.
Having solved that problem, we decided to run both a Random Forest Model (RF) and a Adaboost classifier model (AB). RF use a modified tree learning algorithm that selects, in each candidate division, a random subset of variables. This process is sometimes called feature bagging. AB takes a weak base model and tries to make it strong by retraining it on the misclassified samples.
As we can see from the results, the Random Forest Model shows a higher AUC than the AB model, higher specificity and precision scores.
However, RF shows lower recall. This means that the model identify buying opportunities on many ocations. Further feature engineer is recommended in this case.
Notice that the model should have been run using zero coupon rate bonds. They are not easy to calculate for Argentinean bonds. Bearing this in mind, we attempted to turn a time series problem into a classification problem we wanted and check how data fits RF and AB models chosen.
- "How My Machine Learning Trading Algorithm Outperformed the SP500 For 10 Years", Tomiwa, https://shorturl.at/gqzT9
- Fork this project
- Create your feature branch
- Commit your changes
- Push to the branch
- Create a new Pull Request