AI News, Bitcoin price forecasting with deep learning algorithms

Bitcoin price forecasting with deep learning algorithms

Disclaimer: All the information in this article including the algorithm was provided and published for educational purpose only, not a solicitation for investment nor investment advice.

You can read more about these types of NN here: The dataset we are using is available here: Bitcoin Historical Data The first thing we do is importing all the necessary python libraries.

Now we want to preview the head of the dataset to know the structure of the data: Out[3]: We want to transform the data to get the average price grouped by the day and to see usual datetime format (not a timestamp as above).

We want to train our model on the data from January 1, 2016, until August 21, 2017, and to test the model on the data from August 21, 2017, until October 20, 2017.

Now we are splitting our data into the train and test set: We want to estimate some parameters of our data because this can be useful in the further model designing.

Predicting Cryptocurrency Prices With Deep Learning

If you were to pick the three most ridiculous fads of 2017, they would definitely be fidget spinners (are they still cool?

So, while I may not have a ticket to the moon, I can at least get on board the hype train by successfully predicting the price of cryptos by harnessing deep learning, machine learning and artificial intelligence (yes, all of them!).

it’s a particular type of deep learning model that is well suited to time series data (or any data with temporal/spatial/structural order e.g.

If you wish to truly understand the underlying theory (what kind of crypto enthusiast are you?), then I’d recommend this blog or this blog or the original (white)paper.

I also don’t want to rely on static files, as that’ll complicate the process of updating the model in the future with new data.

As such, the training data may not be representative of the test data, undermining the model’s ability to generalise to unseen data (you could try to make your data stationary- discussed here).

Before we take our deep artificially intelligent machine learning model to the moon, it’s worth discussing a simpler model.

The most basic model is to set tomorrow’s price equal to today’s price (which we’ll crudely call a lag model).

This is how we’d define such a model in mathematical terms: Extending this trivial lag model, stock prices are commonly treated as random walks, which can be defined in these mathematical terms: We’ll determine μ and σ from the training sets and apply the random walk model to the Bitcoin and Ethereum test sets.

As pointed out on that other blog, models that only make predictions one point into the future are often misleadingly accurate, as errors aren’t carried over to subsequent predictions.

No matter how large the error, it’s essentially reset at each time point, as the model is fed the true price.

Luckily, we don’t need to build the network from scratch (or even understand it), there exists packages that include standard implementations of various deep learning algorithms (e.g.

close_off_high represents the gap between the closing price and price high for that day, where values of -1 and 1 mean the closing price was equal to the daily low or daily high, respectively.

We build little data frames consisting of 10 consecutive days of data (called windows), so the first window will consist of the 0-9th rows of the training set (Python is zero-indexed), the second will be the rows 1-10, etc.

We’ve normalised some columns so that their values are equal to 0 in the first time point, so we’re aiming to predict changes in price relative to this timepoint.

That layer has been shaped to fit our inputs (n x m tables, where n and m represent the number of timepoints/rows and columns, respectively).

Now, we just need to specify the number of neurons to place in the LSTM layer (I’ve opted for 20 to keep runtime reasonable), as well as the data on which the model will be trained.

That number below the code represents the model’s mean absolute error (mae) on the training set after the 50th training iteration (or epoch).

We could just cram in hundreds of neurons and train for thousands of epochs (a process known as overfitting, where you’re essentially predicting noise- I included the Dropout() call in the build_model function to mitigate this risk for our relatively small model).

Furthermore, the model seems to be systemically overestimating the future value of Ether (join the club, right?), as the predicted line near always runs higher than the actual line.

Our fancy deep learning LSTM model has partially reproducted a autregressive (AR) model of some order p, where future values are simply the weighted sum of the previous p values.

The bad news is that it’s a waste of the LSTM capabilities, we could have a built a much simpler AR model in much less time and probably achieved similar results (though the title of this post would have been much less clickbaity).

Moving back to the single point predictions, our deep machine artificial neural model looks okay, but so did that boring random walk model.

Like the random walk model, LSTM models can be sensitive to the choice of random seed (the model weights are initially randomly assigned).

The LSTM model returns an average error of about 0.04 and 0.05 on the bitcoin and eth prices, respectively, crushing the corresponding random walk models.

On the other hand, I’m sure it wouldn’t be hard to improve our LSTM model (gratuitously adding more layers and/or neurons, changing the batch size, learning rate, etc.).

If that’s the positive spin, then the negative reality is that it’s entirely possible that there is no detectable pattern to changes in crypto prices;

Analyzing Ethereum, Bitcoin, and 1200+ other Cryptocurrencies using PostgreSQL

With trade volumes reaching billions of dollars a day and market caps hitting tens of billions of dollars, it’s no wonder that cryptocurrencies fuel the gold rush of the modern day.

Bitcoin has had a pretty nice run since then (although taking a small dip recently): Using PostgreSQL, we’ve queried BTC’s prices at 2-week intervals, analyzing the rates for USD exchanges.

Here we calculate daily returns using the power of PostgreSQL window functions: As a relatively new market, bitcoin prices are notably subject to volatile fluctuations.

When looking at trade volumes by currency, we noticed something interesting: The year 2014 saw a minor jump for Bitcoin rates in China, presumably caused by the devaluation of the yuan and weakening domestic stock market.

(And what we found shows how you can’t just rely on quantitative data when trying to understand this market.) In early 2017 the People’s Bank of China began reinforcing regulations and legal liabilities for risky cryptocurrency exchanges.

(Taking advantage of Postgres JOINs and some fancy filters): In its first year, ETH surpassed any yearly BTC growth rate in all of BTC history — a hefty 530% surge in average closing price from the previous year marked a good start.

A clear progression is apparent in the steep uprise within the last six months and trends reflect a massive growth for the coin when quoted in all currencies, except BTC.

Here’s a look at that same day, but counting the number of new currencies with data each day: When we query each of the currencies by their first set of data (to track its “age”), it’s clear that the market is not simply for investors, but also for creators of these digital assets.

(Of course, these dates reflect when our data source first had price data for the currencies, which may not correspond to the ICO.) There are so many cryptocurrencies that it becomes hard to separate the good ones from the noise.

(To do that, we again use a window function to calculate daily returns, and then use the TimescaleDB last function to find the cryptocurrency with the highest return for that day.) Our output for the last three months shows a numeric lead by AMIS (168x on 6/15), which appears as the cryptocurrency with the top increase for 15 distinct days.

However, if we look more closely at AMIS’ rates, we realize that this high increase is also due to high fluctuation rates: AMIS tends to drop back to a closing price of zero after each increase.

Likewise, the cryptocurrency YOVI appears 3 times in our list of daily leads but has a similarly unreliable trend like AMIS: While both trends are rather unstable, they show more promise than ETH’s down-sloping first year (2015): (Repeat Disclaimer: TimescaleDB does not endorse any of these cryptocurrencies and is not liable for investments that you make / losses you may incur.) Here we drew some conclusions from public cryptocurrency datasets, highlighting the power of both PostgreSQL and TimescaleDB.

Bitcoin Trading - Getting historical trade data

This video covers where you can get historical trading data for Bitcoin. In this video, we use BTCUSD, but you can use any rate. Data: ...

How to Predict Stock Prices Easily - Intro to Deep Learning #7

We're going to predict the closing price of the S&P 500 using a special type of recurrent neural network called an LSTM network. I'll explain why we use ...

Make predictions with an artificial neural network using Keras

In this video, we demonstrate how to make predictions on test data with a Keras Sequential model. Follow deeplizard on Twitter: ..

Data Science 101 - 5 mins to build your housing property price prediction model on Azure (I)

In under 5 minutes, learn how to import the raw data, set up workflow and test your training data against real data set on Azure Machine Learning Studio.

Image preparation for CNN Image Classifier with Keras

In this video, we demonstrate how to organize images on disk and setup image batches with Keras so that we can later train a Keras CNN on these images.

Coding With Python :: Learn API Basics to Grab Data with Python

Coding With Python :: Learn API Basics to Grab Data with Python This is a basic introduction to using APIs. APIs are the "glue" that keep a lot of web applications ...

Data augmentation with Keras

In this video, we demonstrate how to use data augmentation with Keras to augment images. Follow deeplizard on Twitter: Follow ..

Python for Machiine Learning - Part 32 - Predictions with Simple Linear Regression 3

''' Topic to be covered - Simple Linear Regression Scenario - We have the Years of Experience and the Salary with us. We will train the model using ...

January 2018 Data Post 5: Country Risk Update

As globalization becomes the norm for both companies and countries, we are faced with a challenge. Even developed market companies derive portions of their ...

Market data of any cryptocurrency (Bitcoin, Ether, ...) into Excel (Macro included)

The macro in the very first comment below lets you import all types of market information for any cryptocurrency/token into Excel, e.g. current price, volume, ...