PLEASE REFER TO THE ATTACHED FILES AS THE CORE OF OUR SUBMISSION (attached files)

Please contact any of us at our emails if there is any issue reviewing the submission, speciaally accessing the attached files where almost all the work regarding our submission is found. The attached files should be a rar file named "AI Hack - Urganitsados.rar", containing the report in html and various juyter notebooks with the code, as well as an image.

[email protected]

[email protected]

[email protected]

Many thanks,

Urganitsadós

Introduction

In this challenge we have decided to work with the crypto dataset. Working with such a dataset, the most obvious yet rewarding goal is price forecasting. A successful strategy that would predict the price (or even it's direction) consistently with an accuracy of over 50% would theoretically be profitable in the long run and if used smartly, able to get someone a one way trip to the Bahamas. The threshold for a strategy to be profitable must be some percentage points over 50% due to the fact that to perform the trades, the exchange where one operates will take a commission. The exact theoretical percentage for profitability depends on exchange commission and how much we are expecting to win/lose per each successful/failed trade.

Data exploration

The first step has been to explore the available data and decide the direction towards which to orient the challenge. A preliminary exploration shows that we have available the data corresponding to a month of ohlcv spot, futures and perpetual futures data with the resolution of up to a minute (corresponding to various pairs and exchanges), as well as the aggregated exchange rate and order book data for the same periods.

When deciding how to tackle the available data, and to simplify a bit the options, we have decided to focus only in the ohlcv data, and drive our insights from those datasets. The tradeoff with this decision is that we might be missing some insights that could be given when the order books are very unbalanced with a relatively large bid or ask book, but since the available corresponds to only a fraction of the book, we have deemed the time and effort that could be spent into extracting information from those not worth it.

Another dataset that we will not consider is the aggregated exchange rates. This could be used in case we wanted to perform some sort of arbitrage, identifying price unbalances in specific exchanges vs the aggregated price that would tend to correct giving for parity trading opportunities (taking advantage of the fact that the price of an asset will tend to compensate and equalize among all exchanges).

We will be considering the remaining three datasets, corresponding to ohlcv data for spot, futures and perpetual futures. After loading the data, a first simple processing step will be taken, converting the timestamp to the right format and using it as the index for our dataframes.

We can explore what we have available in those datasets:

  • Open, high, low and close prices during the time period
  • Trading volume during the period
  • Price, understood as the weighted price in the interval. This won't be as insightful as the bigger definition opened by ohlc, so won't be considered
  • Count, understood as the number of trades in the period
  • Instrument, exchange, pair, corresponding to information about which pair and in which exchange the observation refers to

The first thing to tackle is that those datasets contain information for multiple pairs and exchanges. Chances are that different trading pairs will behave different, and since we will eventually run a model for price prediction, it will be much better to work with a single pair for a single exchange.

We can observe that we have many combinations available, since for example, analyzing the spot data we find that we have 12 different exchanges and 10 different pairs. However, we would not necessarily expect all the 120 possible combinations to contain data, since a pair might not be listed in a specific exchange. Additionally there could be the case where for a pair-exchange combination, we have very poor quality of data with a lot of missing observations.

Observing the results, we see that only 60 of the 120 possible pair-exchange combinations contain data, and from those there are many with significantly small number of observations, corresponding to a combination of missing data and distance between observations bigger than a minute.

For the sake of simplicity, due to the time constrains and the choice of models, we would like to work with subsets of the data that contain observations spaced regularly.

A first, simple model

As a first approach to perform some prediction from the dataset, we will shape the problem as a simple classification task to decide whether the price goes up or the price goes down after n periods. For this purpose, we will need to attach to the dataset a binary column which corresponds to one value (True or 1) if the price is up after n periods and another value (False or 0) if the price is down after n periods.

A classification task such as this can be tackled with many traditional machine learning models. What we will use as features are a set of technical indicators, calculated based on the available data. In this scenario, we will potentially end up with a relative large number of features, and therefore models such as K-nearest neighbors might not perform satisfactorily due to the fact that a large number of features will decrease the quality of the analysis.

A model which performs well when there are many features in the target dataset is the random forest. This is the first model that we will be running, and while we won't expect a remarkable accuracy from it, a random forest can be used to select what could be the best features to use in a more complex model.

To accomplish this, we will run for different pairs and exchanges a model which will do the following:

  • Data will be split in train, validation and test
  • The model will run a random tree for various maximum tree depths and select the tree depth with the best validation accuracy to be used in the random forest
  • Diverse random forest models will be used, having each a different number of estimators.
  • To have an idea about how good the model is, the random forest that performs the best with the validation set will be used to predict price direction in the test set.

Building a LongShortTermMemory (LSTM) neural network from previous insights

After identifying the most promising technical indicators via random forest, we sought to build a neural network that would use those as its main features.

Among the different options, we decided to build an LSTM neural network. Compared to standard NN archytectures, LSTMs have feedback connections, making them ideal for analysing time-series of this kind and allowing the model to capture the time dependecny of the dataset.

Built With

Share this project:

Updates

Submission history