There's been an undeniable frenzy and debate over the role of cryptocurrencies in the future of the global economy, which has led to extreme surges in the exchange rates of the hundreds of coins on the market, especially bitcoin and ethereum, among others. Additionally, these currencies have fluctuated in value with unprecedented volatility, making them high-risk-high-reward-type investments. This attribute of cryptocurrencies gives way to the success of automated trading algorithms, as they are capable of analyzing acute trends and making predictions with extremely high frequency.
What it does
Our machine learning algorithm analyzes the market every 2 minutes and makes a prediction on whether it should buy, sell or hold. The algorithm then decides how much it should invest/sell based on the magnitude of the prediction vector.
How we built it
We built the model using Keras with a TensorFlow backend. The model was trained with mean squared error as the loss function. We experimented with a variety of optimization functions such as
Adam. We settled with Adam as it provided the most accurate model.
Challenges we ran into
Preparing Training Data
The first step of this project involved gathering data to use to train our model. As our project aimed to conduct high frequency trading, we had to take many data points within a short period of time. However, this was prone to heavy bias as a result of sudden spiking. To mitigate this, we took the average of several data points over the span of a minute and fed the results into the model.
We ran into several challenges when developing the network. We had initially planned to use a convolutional neural network, however we later decided that a LSTM (long short-term memory) network would be a better fit because information persist between iterations, allowing the model to consider past trends for its predictions.
Another challenge we faced was long training times. Without a model, it was very difficult to proceed with the development of other areas of the project. We offloaded the computationally expensive process of training the model to a remote desktop with a significantly more powerful GPU to reduce training times. To retrieve the model, we used Keras' ability to export a model to an
.HDF5 file. This also provided the additional benefit of allowing multiple people to work with the latest model at the same time.
After developing a trained model, we needed an algorithm to determine whether to buy/sell/hold at a particular instance. We initially tried buying and selling at equal increments, however, we found that this algorithm did not react quickly enough to sudden changes, and therefore suffered losses due to delayed reaction. To solve this, we broke the problem down logically and found that the best model would sell a large amount in the case the value was predicted to decrease, and buy it back in smaller increments to mitigate over-correction.
Accomplishments that We're proud of
We are proud that we were able learn how to create and train an LSTM model within the time frame of this hackathon. Our team did not have previous knowledge of how to create such a model, making this critical step of the project especially challenging.
What we learned
We learned what an RNN and its advantages over a CNN in problems such as these. More specifically, we learned about the LSTM node and how it takes advantage of long-term dependencies to create a better model.
What's next for ProfitOverflow
We are looking to include more metrics to achieve a more accurate prediction model. Due to the fact that Bitcoin is largely driven by public opinion, we decided that sentiment analysis could serve as a viable metric. Data could be obtained from sources such as Twitter and r/bitcoin. Another goal for ProfitOverflow is to create another neural network that dynamically manages the amount that is bought/sold for each trade.