Trading AI
This is an exploration in the efficacy of different machine learning models for trading on the stock market. In particular, I trained multiple types of models using data from Yahoo Finance on three different commodities, gold, crude oil, and natural gas. After exploring many different models and selecting the best one, I created a trading script that connects to the Oanda trading API and executes trades based on the predicted price of the commoditiy based on the past price history. If the predicted value of the commodity is lower than the current value, it sells some of its shares, and if the predicted value is higher than the current value, it buys some shares. Here is a link to the GitHub repository. Below is the performance of the trading algorithm using the LSTM model on the real stock market (using fake money).

As you can see, the trading algorithm was able to make a profit in the short time that it was trading. However, this model was trading at a time when the market was very bullish, so it is unclear if the model would perform well in a bear market.
Throughout the testing of the different models, we compared their performance to a simple buy and hold strategy. Below are the results of these tests for different models.
LSTM with minutely, hourly, and daily data
Transformer
Deep reinforcement Learning (PPO)
LSTM with daily data
LSTM and PPO combined (promising but unreliable)
LSTM and PPO combined (poor results)
Transformer on multiple simultaneous commodities
After testing, the advanced LSTM model was used in the trading algorithm to trade on the real time stock market. The advanced LSTM model was chosen for its reliability, as some models had huge successes and catastrophic failures. Below is the trading algorithm running.