Вы находитесь на странице: 1из 61

1.

INTRODUCTION
To predict the future, has always been a goal or dream of humanity; however humans have
always been terrible at it1. Predicting the price movements for crypto currency or bit coin is a
relatively similar to predicting stocks or the price of USD going up or down. However, unlike a
company with physical buildings and people working in it, bit coin is purely digital and therefore
very difficult to understand when and why the price would change. With no physical entity and
the way bit coin works, most of the effect on the price is based on how the world feels about it.
For this reason, understanding people is one way to help predict bit coins future. A sentiment
analysis on different kind of social media to get a better understanding of how people feel
humans are terrible at predicting, even with information at their hand. For this reason, by using a
machine learning algorithm, the algorithm will try to predict the future price based on the
information given to it. Prediction of mature financial markets such as the stock market has been
researched at length .

Bitcoin presents an interesting parallel to this as it is a time series prediction problem in a


market still in its transient stage. Traditional time series prediction methods such as Holt-Winters
exponential smoothing models rely on linear assumptions and require data that can be broken
down into trend, seasonal and noise to be effective . This type of methodology is more suitable
for a task such as forecasting sales where seasonal effects are present. Due to the lack of
seasonality in the Bitcoin market and its high volatility, these methods are not very effective for
this task. Given the complexity of the task, deep learning makes for an interesting technological
solution based on its performance in similar areas. The recurrent neural network (RNN) and the
long short term memory (LSTM) are favoured over the traditional multilayer perceptron (MLP)
due to the temporal nature of Bitcoin data.

1.1 AIM &OBJECTIVES

The aim of this project is to investigate with what accuracy the price of Bitcoin can be
predicted using machine learning and compare parallelisation methods executed on multi-core
and GPU environments.

1
 Verify empirical results with available experimental facilities.
 Comparative analysis based on the experiment with proposed algorithm and
benchmark algorithms.
 Experimental validation of the predictive performance on near-future price of
Bitcoin.

CHALLENGES

 The confidence intervals are too large to be meaningful.


 The overall history of Bit coin price has been a strong uptrend, so most
algorithms tend to just bit coin price upward into the foreseeable future.

1.2 PROBLEM DESCRIPTION

The goal is to be able to predict if the bit coin price change would increase or decrease
and by how much, however this goal can be accomplished in many ways. How often does it need
to be able to predict? Whether it predicts every minute, 10 minutes or hourly will all decide the
time frame the data set will be collected in. If predictions are 10 minutes, then all social media in
a 10 minute timeframe will be used to predict, however if it is 1 hour, then 1 hour worth of data
will be collected to predict etc.

In all, how often to predict would be based on the amount of data gathered in a day, the
more data gathered the smaller timeframe, however according to they concluded that the shorter
the frame, the more influence sentiment value had which is something to take into consideration
as well. However news and social network messages takes time to get around. A longer time
frame would help on that, since messages and news has to be written and when it reaches people,
they also have to open and read it.

2
2. SYSTEM ANALYSIS

2.1 EXISTING SYSTEM

There are many approaches people have taken to try to tackle intra-day and high-speed
trading. Just like in stock, forex , commodity, and options trading, these are coupled with
highly-efficient bots and systems that perform the trades automatically. Humans are a problem in
this situation. Bitcoin presents an interesting parallel to this as it is a time series prediction
problem in a market still in its transient stage. Traditional time series prediction methods such as
Holt-Winters exponential smoothing models rely on linear assumptions and require data that can
be broken down into trend, seasonal and noise to be effective. This type of methodology is more
suitable for a task such as forecasting sales where seasonal effects are present. Due to the lack of
seasonality in the Bitcoin market and its high volatility, these methods are not very effective for
this task.

DRAWBACK IN EXISTING SYSTEM

 If you lose the offline wallet, the coins are lost forever
 It is still not yet accepted by a lot of businesses as a means of making payment.
 Online coins can be hacked. Once hacked coins are lost for life.

EXISTING ALGORITHM

 Basiyean classification algorithm


 Recurrent neural network (RNN)

2.2 PROPOSED SYSTEM

It focuses only on the closing price of the bit coin to develop the predictive model. It does
not take into consideration the other economic factors such as news about bit coin, government
policies, and market sentiments into account which could be the future scope of the project to
predict the price with much more accuracy. The prediction is limited to the past data. The ability
to predict on streaming data would improve the performance and predictability of the model.

3
The study involves only the comparison between ARIMA and LSTM. Comparing with
more machine learning models would confirm the result. The model developed using LSTM
have more accuracy than the traditional models which prove deep learning model, in our case
LSTM(Long Short-Term Memory) is evidently effective learner on training data than ARIMA
with the LSTM more capable for recognizing longer-term dependencies. The study is done using
the daily price fluctuations of the bit coin which triggers the study to further investigate in future
the predictability of the model using hourly price fluctuations.

ADVANTAGES

 Total Bit coin passing through


 Net Bit coin flow (received minus sent)
 number of transactions
 closeness centrality
 The transactions are decentralized. Unlike the centralized transactions associated with
cash and card transactions, bitcoin transactions are carried out via decentralized private

PROPOSED ALGORITHM

 ARIMA (Auto Regressive Integrated Moving Average)


 Root Mean Square Error

2.3 BITCOIN CRYPTOCURRENCY

The first decentralized crypto currency was created in 2009 called Bitcoin2. In 2010 price
for one bit coin never reached above one dollar3, but in May 2018 it was the one with the highest
market cap of around 149 billion dollars with a little more than 17 million bit coins in
circulation4. This makes one bit coin worth around 8700 dollars (Market cap / circulation).
Bitcoin is a digital currency, which can be used to buy or trade things electronically, however
what makes it different from normal currency is the decentralization of the system by using
blockchain technology5. By being decentralized, it has no single entity controlling the network
but instead maintained by a group of volunteers running on different computers around the
world.

4
Physical currency such as USD can have unlimited supply of currency, if the government
decides to print more, which can change the value of the currency related to others. However, the
increase of Bitcoin circulation is heavily guarded by an algorithm, which allows only a few
Bitcoin to be created every hour by miners until it reaches a total cap of 21 million bitcoins6.

The decentralization of the system in theory allows for anonymity, since there are no
bank or centralized entity to confirm and validate transactions that are happening. In practice
however, when a transaction is made, each user uses their identifier, known as addresses during
the transaction. These addresses are not associated with a name, but because the transaction must
be transparent because of the way decentralization of the system works, it is possible for
everyone to see it.

Disadvantage of the system is that, in case of losing the address, forgetting it or wanting
to reverse a transaction, because there is no authority involved, it is not possible to do anything
about it.

WEB SITES

To a degree any websites that has information related to bit coin can be written here, but
most important type of sites would be major media outlets and different government sites of
different countries for any change on regulations.

INTERNET FORUMS

Bitcointalk.org is created by one of the founder of bit coin, and is one of the biggest
forums on bit coin, however many smaller ones exist as well, whom dedicates themselves to
news and information on bit coin. These sites are mostly guaranteed to have users who are
interested and understand bit coin, which mean most posts will be made by educated users on the
topic and be related to bit coin.

5
PRICE COLLECTION

To obtain prices on bit coin, sites like Bitcoin exchange exists where it is possible to
buy or sell bit coins. Since every sites have different prices on the bit coin, it is not possible to
guarantee that the biggest site is the one with the cheapest price. According to article27 the top 3
most recommended is Coin base, for being the biggest, Gemini Exchange for low fees and
Changelly since they have lesser known crypto currencies.

These social platforms and other data sources will be looked upon and analyzed to see
which would fit best to gather data to use for predicting bit coin prices. Although each platform
has their own demographic, many of them are overlapping, this could be a problem if multiple
platforms were used, giving duplicate data rather than more data. Facebook has the potential of
giving the most data, however since the main demographic probably do not know or use Bitcoin,
it might be mostly data which does not influence Bitcoin price. Twitter and Reddit on the other
hand might have less data to obtain, however more specialized knowledge of the users might
lead to some changes in the Bitcoin price. Telegram being the extreme of them all, with the least
users, but with the highest expertise.

6
3. SYSTEM REQUIREMENT

3.1 HARDWARE REQUIREMENTS

 System : Dual core processor.

 Hard Disk : 80 GB.

 Monitor : 15 VGA Color.

 Ram : 2 GB.

3.2 SOFTWARE REQUIRMENTS

 Operating system : Windows 7 / 8

 Coding Language : Mat lab

 Platform : Math works Simulator

 Tools : Simulink

7
4. SOFTWARE INTRODUCTION
4.1 MATLAB
MATLAB (matrix laboratory) is a multi-paradigm numerical computing environment and
fourth-generation programming language. A proprietary programming language developed by
MathWorks, MATLAB allows matrix manipulations, plotting of functions and data,
implementation of algorithms, creation of user interfaces, and interfacing with programs written
in other languages, including C, C++, C#, Java, Fortran and Python.
Although MATLAB is intended primarily for numerical computing, an optional toolbox
uses the MuPAD symbolic engine, allowing access to symbolic computing abilities. An
additional package, Simulink, adds graphical multi-domain simulation and model-based design
for dynamic and embedded systems.
In 2004, MATLAB had around one million users across industry and academia.
MATLAB users come from various backgrounds of engineering, science, and economics.

4.2 HISTORY
Cleve Moler, the chairman of the computer science department at the University of New
Mexico, started developing MATLAB in the late 1970s. He designed it to give his students
access to LINPACK and EISPACK without their having to learn Fortran. It soon spread to other
universities and found a strong audience within the applied mathematics community. Jack little,
an engineer, was exposed to it during a visit Moler made to Stanford University in 1983.
Recognizing its commercial potential, he joined with Moler and Steve Bangert. They rewrote
MATLAB in C and founded MathWorks in 1984 to continue its development. These rewritten
libraries were known as JACKPAC. In 2000, MATLAB was rewritten to use a newer set of
libraries for matrix manipulation, LAPACK.
MATLAB was first adopted by researchers and practitioners in control engineering,
Little's specialty, but quickly spread to many other domains. It is now also used in education, in
particular the teaching of linear algebra, numerical analysis, and is popular amongst scientists
involved in image processing.

8
4.3 MATLAB FUNCTIONS
 A function is a group of statements that together perform a task. In MATLAB, functions
are defined in separate files. The name of the file and of the function should be the same.
 Functions operate on variables within their own workspace, which is also called the local
workspace, separate from the workspace you access at the MATLAB command prompt
which is called the base workspace.
 Functions can accept more than one input arguments and may return more than one
output arguments.
 The first line of a function starts with the keyword function. It gives the name of the
function and order of arguments. In our example, the mymax function has five input
arguments and one output argument.

4.3.1 ANONYMOUS FUNCTIONS


 An anonymous function is like an inline function in traditional programming languages,
defined within a single MATLAB statement. It consists of a single MATLAB expression
and any number of input and output arguments.
 You can define an anonymous function right at the MATLAB command line or within a
function or script.
 This way you can create simple functions without having to create a file for them.

4.3.2 PRIMARY AND SUB-FUNCTIONS


 Any function other than an anonymous function must be defined within a file. Each
function file contains a required primary function that appears first and any number of
optional sub-functions that comes after the primary function and used by it.
 Primary functions can be called from outside of the file that defines them, either from
command line or from other functions, but sub-functions cannot be called from command
line or other functions, outside the function file.
 Sub-functions are visible only to the primary function and other sub-functions within the
function file that defines them.

9
4.3.3 NESTED FUNCTIONS
You can define functions within the body of another function. These are called nested
functions. A nested function contains any or all of the components of any other function.
Nested functions are defined within the scope of another function and they share access to the
containing function's workspace.

4.4 PRIVATE FUNCTIONS


 A private function is a primary function that is visible only to a limited group of other
functions. If you do not want to expose the implementation of a function(s), you can
create them as private functions.
 Private functions reside in subfolders with the special name private.
 They are visible only to functions in the parent folder.

4.5 GLOBAL VARIABLES


 Global variables can be shared by more than one function. For this, you need to declare
the variable as global in all the functions.
 If you want to access that variable from the base workspace, then declare the variable at
the command line.
 The global declaration must occur before the variable is actually used in a function. It is a
good practice to use capital letters for the names of global variables to distinguish them
from other variables.

4.6 FEATURES OF MATLAB


 It is a high-level language for numerical computation, visualization and application
development.
 It also provides an interactive environment for iterative exploration, design and problem
solving.

10
 It provides vast library of mathematical functions for linear algebra, statistics, Fourier
analysis, filtering, optimization, numerical integration and solving ordinary differential
equations.
 It provides built-in graphics for visualizing data and tools for creating custom plots.

 MATLAB's programming interface gives development tools for improving code quality
maintainability and maximizing performance.
 It provides tools for building applications with custom graphical interfaces.
 It provides functions for integrating MATLAB based algorithms with external
applications and languages such as C, Java, .NET and Microsoft Excel.

11
5. SYSTEM STUDY

5.1 FEASIBILITY STUDY

The feasibility of the project is analyzed in this phase and business proposal is put forth
with a very general plan for the project and some cost estimates. During system analysis the
feasibility study of the proposed system is to be carried out. This is to ensure that the proposed
system is not a burden to the company. For feasibility analysis, some understanding of the major
requirements for the system is essential.

Three key considerations involved in the feasibility analysis are

 ECONOMICAL FEASIBILITY
 TECHNICAL FEASIBILITY
 SOCIAL FEASIBILITY

5.1.1 ECONOMICAL FEASIBILITY

This study is carried out to check the economic impact that the system will have on the
organization. The amount of fund that the company can pour into the research and development
of the system is limited. The expenditures must be justified. Thus the developed system as well
within the budget and this was achieved because most of the technologies used are freely
available. Only the customized products had to be purchased.

5.1.2 TECHNICAL FEASIBILITY


This study is carried out to check the technical feasibility, that is, the technical
requirements of the system. Any system developed must not have a high demand on the available
technical resources. This will lead to high demands on the available technical resources. This
will lead to high demands being placed on the client. The developed system must have a modest
requirement, as only minimal or null changes are required for implementing this system.

12
5.1.3 SOCIAL FEASIBILITY

The aspect of study is to check the level of acceptance of the system by the user. This
includes the process of training the user to use the system efficiently. The user must not feel
threatened by the system, instead must accept it as a necessity. The level of acceptance by the
users solely depends on the methods that are employed to educate the user about the system and
to make him familiar with it. His level of confidence must be raised so that he is also able to
make some constructive criticism, which is welcomed, as he is the final user of the system.

5.2 INTRODUCTION TO DEEP LEARNING


Deep learning, a class of machine learning techniques that are used to extract features
from data, and CNN ( Convolutional Neural Network), a type of artificial neural network that
has been extended across space using shared weights, have been found suitable for computer
vision tasks . At the beginning, researchers experimented with small datasets. With the lowered
cost of expensive processing hardware, increasing chip processing capabilities and increasing
number of data existing online, it was possible to implement deep neural networks in larger data
sets and in real-life scenario data sets as well.
Deep learning (also known as deep structured learning or hierarchical learning) is
part of a broader family of machine learning methods based on learning data representations, as
opposed to task-specific algorithms. Learning can be supervised, semi-supervised or
unsupervised Deep learning architectures such as deep neural networks, deep belief networks and
recurrent neural networks have been applied to fields including computer vision, speech
recognition, natural language processing, audio recognition, social network filtering, machine
translation, bioinformatics, drug design and board game programs, where they have produced
results comparable to and in some cases superior to human experts.Deep learning models are
vaguely inspired by information processing and communication patterns in biological nervous
systems yet have various differences from the structural and functional properties of biological
brains (especially human brain), which make them incompatible with neuroscience evidences.

13
Deep Learning Development Lifecycle

5.3 DEEP LEARNING METHODS

In the past, deep learning was not a growth item due to hardware constraints. However,
nowadays, there is a lot of information that can be learned, also, GPU parallel processing
technology became processing a lot of information in real time, and hardware performance is
better than before so that the deep learning technology can be applied to various fields such as
computer vision field, image recognition. The models of deep running that are mainly studied are
CNN (Convolution Neural Network) and RNN (Recurrent Neural Network) . CNN is an
excellent way to extract high-level abstraction features from images or to process texture
information, and has proven to be excellent in object recognition in 2012.

CNN has been applied to various fields such as video and speech recognition in an effort
to express and learn large amounts of data in the form of meaningful data. RNN is a kind of
artificial neural network. When inputting the data, the value of the hidden layer is stored in the
neural network and calculated as the next input value, which is good for modeling the time series
information. Traditional RNNs use Long Short-Term Memory (LSTM) as an alternative to long-
term retention and information memorization problems. Therefore, LSTM RNN is a deep
learning model that solves the vanishing gradient problem of existing RNN model.

14
A support vector is an optimal hyperplane that can distinguish two types of data given in
a feature space. CRF (Conditional Random Field) is not referring to a single sequence, but by
referring to previous and subsequent states to determine the current state. HMM (Hidden Markov
Model) and MEMM (Maximum Entropy Markov Model).HMM is modeled under the strong
independent assumption of Markov assumption. This has the advantage that it is easy to model
the real problem, but the current hidden state is affected by the current observation state. The
model to solve this is the maximum entropy model. However, MEMM also has a label bias
problem.

5.4 Deep Learning Innovation

Deep Learning is one of the recent innovations in artificial intelligence. It extends the
power of neural models by using more hidden layers. Usually, the typical neural networks utilize
shallow learning algorithms which are less complicated. Deep Learning, however, amplifies the
neural network by optimizing the neural model. It does this by adding multiple layers between
the input and output. The deep feed forward network, one of the Deep Learning techniques, is
the chosen technique for our study. In deep feed forward network, the goal is to approximate a
function and maps it into a group.

Neural network information flows from the evaluated function to the define function and
finally to the output. Feed forward network forms the basis of other Deep Learning networks
such as convolutional networks, which are considered as a particular type of feed forward
network. While deep learning is said to be data intensive, it can also be fine-tuned to work on
smaller datasets as we have done in our study. however, acknowledge that we still have not fully
exploited the capabilities of deep learning. Due to the number of hyper parameters deep learning
has plus the presence of other deep learning techniques, the research area for deep learning is
still fertile.

DATA WHICH COULD AFFECT BITCOIN PRICES

One of the most difficult tasks is to understand, during the process of this research, what
information is just noise (makes more harm to the prediction than if it left out) and what
information has a lot of impact on the bit coin price.

15
This information can be gathered from different social network platforms, but which
depends on the people that the sentiment score is aiming for. Sentiment data can also be gathered
from global news, that not necessary has to affect the whole world, but has a big enough impact
for people to notice. Lastly is the technical data, such as price of the bit coin or how many were
sold etc.

In the world of economics, they believe that the psychology affects the investors' decision
also known as Animal Spirit36. This means that negative and positive emotions of the investors
can have influence on the price. The confirms this with happy investors is more likely to take
more risk making the bit coin increase, because of them being more likely to buy it.

Related but not completely the same is the media coverage of the bit coin, the investors
can be more comfortable with their bit coin and that will result in the price increasing, however
the opposite is also true with bad publicity, they might sell their bit coins in fear of it dropping,
resulting in it dropping.

Positive and negative media news and personal emotion is related however not the same,
as they are data collected different ways (read more in 3.4). Another way to look at it, is that a
person has their emotions however it can be affected or changed based on good or bad news.

However with the internet today, the news of people's feelings can be spread out
extremely quickly through social networks (read more in 3.4) such as Twitter, Reddit, Facebook
etc. This means that not only does news on a national or global scale have a big effect on people,
but friends or celebrity can have big impact on their emotions as well.

16
6. SYSTEM DESIGN

6.1 SYSTEM ARCHITECTURE

17
6.2 SYSTEM ARCHITECTURE DIAGRAM

Encrypt data

Gateway
Switche
s
Attacks

Payment details (coin Elements) Third


Attacks Party

Users

Identify
elements

18
6.3 UML DIAGRAM

UML is simply another graphical representation of a common semantic model. UML


provides comprehensive notification for the full life cycle of object oriented development.

ADVANTAGES

 To represent complete system (instant of only the software portion) using object oriented
concept.
 To establish a explicit coupling between concept and executable code.
 To take into account the scaling factors that are inherit to complex and critical system.
 To creating a modelling language usable by both humans and machines.

UML DEFINES SEVERAL MODLES FOR REPRESENTING SYSTEM

 The class model captures the static structure.


 The state model expresses the dynamic behaviour of object.
 The use case model describe the requirements of the user.
 The interaction model represent the scenarios and message flow.
 The implementation models shows the work units.

USE CASE DIAGRAM

Use case diagrams overview the usage requirements for system. They are useful for
presentations to management or projects stakeholders, but for actual development you will find
that use case provide significantly more values because they describe “the meant” of the actual
requirements.

A use case describes a sequence of action that provide something of measurable value to
an action and is drawn as a horizontal ellipse.

19
6.4 USER

Registration

View Product

Payment

Coin Element

File decrypt

20
6.5 SEQUENCE DIAGRAM

A sequence diagram is an interaction diagram that shows how processes operate


with one another and in what order. It is a construct of a Message Sequence Chart.

21
6.6 CLASS DIAGRAM

A class diagram is a type of static structure diagram that describes the structure diagram
that describes the structure of a system by showing the system’s classes their attributes,
operations (or methods) and the relationship among objects.
The classes in a class diagram represent both the main elements, interactions in the application
and the classes to be programmed.

22
6.7 ACTIVITY DIAGRAM

Activity diagram are graphical representations of work flow of step wise activities and
actions with support for choice, iteration and concurrency. The activity diagram can be used to
describe the business and operational step by step work flows of components in a system .
Activity diagram consist of initial node, activity final node and activities in between .

USER

23
7. SYSTEM IMPLEMENTATION

7.1 MODULES DESCRIPTION

7.1.1 DATASET

Before we build the model, we need to obtain some data for it. There’s a dataset on UCI
Machine learning repository that details minute by minute Bitcoin prices (plus some other
factors) for the last few years (featured on that other blog post). Over this timescale, noise could
overwhelm the signal, so we’ll opt for daily prices. The issue here is that we may have not
sufficient data (we’ll have hundreds of rows rather than thousands or millions). In deep learning,
no model can overcome a severe lack of data. 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. Instead, we’ll aim to
pull data from websites and APIs.

7.1.2 RULE-BASED FEATURES

Human experts with years of experience created many rules to detect whether a user is
fraud or not. An example of such rules is “bitcoin”, i.e. whether the user has been detected or
complained as coin prediction before. Each rule can be regarded as a binary feature that indicates
the coin price prediction likeliness.

7.1.3 SELECTIVE LABELING

If the coin price score is above a certain threshold, the case will enter a queue for further
investigation by human experts. Once it is reviewed, the final result will be labeled as Boolean,
i.e. coin or clean. Cases with higher scores have higher priorities in the queue to be reviewed.

The cases whose price score are below the threshold are determined as clean by the
system without any human judgment. Once one case is labeled as fraud by human
experts, it is very likely that the seller is not trustable and may be also selling other coin price;
hence all the items submitted by the same seller are labeled as coin price too. The bitcoin seller
along with his/her cases will be removed from the website immediately once detected

24
7.2 MACHINE LEARNING AND BITCOIN

Before you get started, let’s establish a couple of things. First, it’s nearly impossible to
accurately predict the value of a stock (and cryptocurrency) with a simple computer algorithm.

This is because there are so many factors that can affect the price of a stock that we
cannot account for. Think about this, for almost no apparent reason, the price of bitcoin rises and
surges. There is no mathematical variable or equation that we can use to predict these rises and
falls. Yes, there are some really advanced computer models for stocks which takes into account
many long-term factors, but nothing is going to give you 100% accuracy.

7.3 DEEP LEARNING MODELS

Appropriate design of deep learning models in terms of network parameters is imperative


to their success. The three main options available when choosing how to select parameters for
deep learning models are random search, grid search and heuristic search methods such agenetic
algorithms.

25
Manual grid search and Bayesian optimization were utilized in this study. Grid search,
implemented for the Elman RNN, is the process of selecting two hyper paramaters with a
minimum and maximum for each. One then searches that feature space looking for the best
performing parameters.

This approach was taken for parameters which were unsuitable for Bayesian
optimisation. This model was built using Visual studio in the Python programming language.
Similar to the RNN, Bayesian optimization was chosen for selecting LTSM parameters where
possible. This is a heuristic search method which works by assuming the function was sampled
from a Gaussian process and maintains a posterior distribution for this function as the results of
different hyper parameter selections are observed.

26
7.4 LSTM

In terms of temporal length, the LSTM is considerably better at learning long term
dependencies. As a result, picking a long window was less detrimental for the LSTM. This
process followed a similar process to the RNN in which autocorrelation lag was used as a
guideline. The LSTM performed poorly on smaller window sizes. Its most effective length found
was 100 days, and two hidden LSTM layers were chosen. For a time series task two layers is
enough to find nonlinear relationships among the data. 20 hidden nodes were also chosen for
both layers as per the RNN model.

The Hyperas library2 was used to implement the Bayesian optimisation of the network
parameters. The optimiser searched for the optimal model in terms of how much dropout per
layer and which optimizer to use.

7.5 SYSTEM STRUCTURE

27
8. SOURCE CODE

8.1 ALGOTRADING.M
1. %algo trading
2. %import prices and dateTime as column vectors from the csv sheet
3. %about 120 000 values
4. importcsv();
5. assert(length(prices) == length(askVolume));
6. assert(length(prices) == length(bidVolume));
7. prices = transpose(prices)
8. prices = prices(1:2:length(prices)); %turns 5s to 10s steps
9. askVolume = askVolume(1:2:length(askVolume));
10. bidVolume = bidVolume(1:2:length(bidVolume))
11. prices1 = prices(1:20000);
12. prices2 = prices(20001:40000);
13. prices3 = prices(40001:length(prices))
14. %#############################
15. %#step 1: creating intervals S_j
16. %#############################
17. %#create list of all 720*10s, 360*10s and 180*10s intervals
18. %#each item is (interval of prices, NEXT TEN SEC interval price change)
19. priceDiff = diff(prices);
20. validIntSize = length(prices1)-750; %valid interval size
21. interval720s = zeros(validIntSize,720+1);
22. interval360s = zeros(validIntSize,360+1);
23. interval180s = zeros(validIntSize,180+1);
24. for i = 1:validIntSize
25. interval180s(i,:) = [prices1(i:i+179),priceDiff(i+179)];
26. Int
27. erval360s(i,:) = [prices1(i:i+359),priceDiff(i+359)];

28
28. nterval720s(i,:) = [prices1(i:i+719),priceDiff(i+719)];
29. end
30. %#now we k-means cluster all 3 interval lists to get the 20 best patterns
31. %#for each of the interval lists
32. clusters = 20;
33. [~,kmeans180s] = kmeans(interval180s,clusters);
34. [~,kmeans360s] = kmeans(interval360s,clusters);
35. [~,kmeans720s] = kmeans(interval720s,clusters); %this one has difficulty

8.2 CONVERGING.M

36. %TODO for speed, use similarity instead of L2 norm for kmeans?
37. for i = 1:clusters
38. kmeans180s(i,1:180) = (kmeans180s(i,1:180) -
mean(kmeans180s(i,1:180)))./std(kmeans180s(i,1:180));
39. kmeans360s(i,1:360) = (kmeans360s(i,1:360) -
mean(kmeans360s(i,1:360)))./std(kmeans360s(i,1:360));
40. kmeans720s(i,1:720) = (kmeans720s(i,1:720) -
mean(kmeans720s(i,1:720)))./std(kmeans720s(i,1:720));
41. end
42. disp('finished clustering and normalizing');
43. %################
44. %#step 2: predicting average price change dp_j and learning parameters w_i
45. %#using Bayesian regression
46. %#
47. %#equation:
48. %#dp = w0 + w1*dp1 + w2*dp2 + w3*dp3 + w4*r
49. %###############
50. RegressorX = zeros(length(prices2)-750-1,4);
51. regressorY = zeros(1,length(prices2)-750-1);
52. for i= 750:length(prices2)-1

29
53. price180 = prices2(i-179:i);
54. price360 = prices2(i-359:i);
55. price720 = prices2(i-719:i);
56. %#average price change dp_j is given by bayesian regression
57. dp1 = bayesian(price180, kmeans180s,kmeans360s,kmeans720s);
58. dp2 = bayesian(price360, kmeans180s,kmeans360s,kmeans720s);
59. dp3 = bayesian(price720, kmeans180s,kmeans360s,kmeans720s);
60. r = (bidVolume(i)-askVolume(i))/(bidVolume(i)+askVolume(i));
61. regressorX(i-749,:) = [dp1,dp2,dp3,r];
62. regressorY(i-749) = prices2(i+1)-prices2(i);
63. end
64. %last parameter is regularization gamma, need to find a good value TODO
65. [theta, theta0] = train_regressor(regressorX, transpose(regressorY), 1);
66. disp('finished regression, ready to trade');
67. m = length(prices1) + length(prices2); %we want to take bid/ask data from right
index
68. %start trading with last list of prices
69. tic
70. [bank,error] = brtrade(prices3,
kmeans180s,kmeans360s,kmeans720s,theta,theta0,bidVolume(m:end),askVolume
(m:end));
71. toc
8.3 IMPORTCSVS.M

72. %% Import data from text file.


73. % Script for importing data from the following text file:
74. %
75. % C:\Users\Anvita\Documents\algotrading\okcoin5s.csv
76. %
77. % To extend the code to different selected data or a different text file,
78. % generate a function instead of a script.

30
79. % Auto-generated by MATLAB on 2015/03/06 15:29:20%% Initialize variables.
80. filename = 'C:\Users\Home\Desktop\BitCoin\okcoin5s.csv';
81. delimiter = ',';
82. %% Format string for each line of text:
83. % column2: double (%f)
84. % column3: double (%f)
85. % column4: double (%f)
86. % For more information, see the TEXTSCAN documentation.
87. formatSpec = '%*s%f%f%f%[^\n\r]';
88. %% Open the text file.
89. FileID = fopen(filename,'r');
90. %% Read columns of data according to format string.
91. % This call is based on the structure of the file used to generate this
92. % code. If an error occurs for a different file, try regenerating the code
93. % from the Import Tool.
94. dataArray = textscan(fileID, formatSpec, 'Delimiter', delimiter, 'EmptyValue'
,NaN, 'ReturnOnError', false);
95. %% Close the text file.
96. fclose(fileID);
97. %% Post processing for unimportable data.
98. % No unimportable data rules were applied during the import, so no post
99. % processing code is included. To generate code which works for
100. % unimportable data, select unimportable cells in a file and regenerate the
101. % script.
102. %% Allocate imported array to column variable names
103. prices = dataArray{:, 1};
104. askVolume = dataArray{:, 2};
105. bidVolume = dataArray{:, 3};
106. %% Clear temporary variables
107. clearvars filename delimiter formatSpec fileID dataArray ans;

31
8.4 BAYESIAN.M

108. %algo trading


109. %import prices and dateTime as column vectors from the csv sheet
110. %about 120 000 values
111. importcsv();
112. assert(length(prices) == length(askVolume));
113. assert(length(prices) == length(bidVolume));
114. prices = transpose(prices);
115. prices = prices(1:2:length(prices)); %turns 5s to 10s steps
116. askVolume = askVolume(1:2:length(askVolume));
117. bidVolume = bidVolume(1:2:length(bidVolume));
118. prices1 = prices(1:20000);
119. prices2 = prices(20001:40000);
120. prices3 = prices(40001:length(prices));
121. %#############################
122. %#step 1: creating intervals S_j
123. %#############################
124. %#create list of all 720*10s, 360*10s and 180*10s intervals
125. %#each item is (interval of prices, NEXT TEN SEC interval price change)
126. priceDiff = diff(prices);
127. validIntSize = length(prices1)-750; %valid interval size
128. interval720s = zeros(validIntSize,720+1);
129. interval360s = zeros(validIntSize,360+1);
130. interval180s = zeros(validIntSize,180+1);
131. for i = 1:validIntSize
132. interval180s(i,:) = [prices1(i:i+179),priceDiff(i+179)];
133. interval360s(i,:) = [prices1(i:i+359),priceDiff(i+359)];
134. interval720s(i,:) = [prices1(i:i+719),priceDiff(i+719)];
135. end

32
136. %#now we k-means cluster all 3 interval lists to get the 20 best patterns
137. %#for each of the interval lists
138. clusters = 20;
139. [~,kmeans180s] = kmeans(interval180s,clusters);
140. [~,kmeans360s] = kmeans(interval360s,clusters);
141. [~,kmeans720s] = kmeans(interval720s,clusters); %this one has difficulty
142. assert(length(prices) == length(askVolume));
143. assert(length(prices) == length(bidVolume));
144. prices = transpose(prices);
145. prices = prices(1:2:length(prices)); %turns 5s to 10s steps
146. askVolume = askVolume(1:2:length(askVolume));
147. bidVolume = bidVolume(1:2:length(bidVolume));
148. prices1 = prices(1:20000);
149. prices2 = prices(20001:40000);
150. prices3 = prices(40001:length(prices))
151. %#############################
152. %#step 1: creating intervals S_j
153. %#############################
154. %#create list of all 720*10s, 360*10s and 180*10s intervals
155. %#each item is (interval of prices, NEXT TEN SEC interval price change)
156. priceDiff = diff(prices);
157. validIntSize = length(prices1)-750; %valid interval size
158. interval720s = zeros(validIntSize,720+1);
159. interval360s = zeros(validIntSize,360+1);
160. interval180s = zeros(validIntSize,180+1);
161. for i = 1:validIntSize
162. interval180s(i,:) = [prices1(i:i+179),priceDiff(i+179)];
163. interval360s(i,:) = [prices1(i:i+359),priceDiff(i+359)];
164. interval720s(i,:) = [prices1(i:i+719),priceDiff(i+719)];
165. end
166. %#now we k-means cluster all 3 interval lists to get the 20 best patterns

33
167. %#for each of the interval lists
168. clusters = 20
169. [~kmeans180s] = kmeans(interval180s,clusters);
170. [~,kmeans360s] = kmeans(interval360s,clusters);
171. [~,kmeans720s] = kmeans(interval720s,clusters); %this one has difficulty

8.5 RIGHT INDEX.M


172. %start trading with last list of prices
173. tic
174. [bank,error] = brtrade(prices3,
kmeans180s,kmeans360s,kmeans720s,theta,theta0,bidVolume(m:end),ask
175. (m:end));
176. toc%algo trading
177. %import prices and dateTime as column vectors from the csv sheet
178. %about 120 000 values
179. importcsv();
180. assert(length(prices) == length(askVolume));
181. assert(length(prices) == length(bidVolume));
182. prices = transpose(prices);
183. prices = prices(1:2:length(prices)); %turns 5s to 10s steps
184. askVolume = askVolume(1:2:length(askVolume));
185. bidVolume = bidVolume(1:2:length(bidVolume));
186. prices1 = prices(1:20000);
187. prices2 = prices(20001:40000);
188. prices3 = prices(40001:length(prices));
189. %############################
190. %#step 1: creating intervals S_j
191. %#############################
192. %#create list of all 720*10s, 360*10s and 180*10s intervals
193. %#each item is (interval of prices, NEXT TEN SEC interval price change)
194. priceDiff = diff(prices);

34
195. validIntSize = length(prices1)-750; %valid interval size
196. interval720s = zeros(validIntSize,720+1);
197. interval360s = zeros(validIntSize,360+1);
198. interval180s = zeros(validIntSize,180+1);
199. for i = 1:validIntSize
200. interval180s(i,:) = [prices1(i:i+179),priceDiff(i+179)];
201. interval360s(i,:) = [prices1(i:i+359),priceDiff(i+359)];
202. interval720s(i,:) = [prices1(i:i+719),priceDiff(i+719)];
203. end
204. %#now we k-means cluster all 3 interval ists to get the 20 best patterns
205. %#for each of the interval lists
206. clusters = 20;
207. [~,kmeans180s] = kmeans(interval180s,clusters);
208. [~,kmeans360s] = kmeans(interval360s,clusters);
209. [~,kmeans720s] = kmeans(interval720s,clusters); %this one has difficulty

8.6 MAKEPOTS.M
210. % make plots and print out useful stats
211. function n = make_plots(prices, buy, sell, proba, bank, error)
212. n = length(prices);
213. sbuy = nan(n,1);
214. ssell = nan(n,2);
215. sbuy(buy) = prices(buy);
216. ssell(sell) = prices(sell);
217. fprintf('Error of prediction, on average: %d\n', error/n);
218. fprintf('Win rate: %d percent\nTotal profit: $%d \n', proba, bank);
219. fprintf('Percent profit(approx): %d\n', bank*100/prices(end))
220. % create plots of buy/sell points
221. % note: cannot plot when running on -nojvm flag
222. plot(1:n,prices,'blue');
223. hold on

35
224. plot(1:n,sbuy,'.red' ,'MarkerSize',20);
225. hold on
226. plot(1:n,ssell,'.green' ,'MarkerSize',20);
227. end

8.7 RANDDEPT.M

228. %**********************************************************
**********
229. % Script file for the initialization and run of the differential
230. % evolution optimizer.
231. %**********************************************************
**********
232. clc;
233. % F_VTR "Value To Reach" (stop when ofunc < F_VTR)
234. F_VTR = -1000000;
235. % _D number of parameters of the objective function
236. I_D = 5;
237. % FVr_minbound,FVr_maxbound vector of lower and bounds of initial
population
238. % the algorithm seems to work especially well if
[FVr_minbound,FVr_maxbound]
239. % covers the region where the global minimum is expected
240. % *** note: these are no bound constraints!! ***
241. FVr_minbound = [0 0 0 0 0];
242. FVr_maxbound = [1 1 1 1 1];
243. % FVr_minbound = [10 0.25 0.25];
244. % FVr_maxbound = [200 0.75 0.75];
245. I_bnd_constr = 0; %1: use bounds as bound constraints, 0: no bound

36
8.8 CONSTRAINTS.M

246. % I_NP number of population members


247. I_NP = 10*I_D; %pretty high number - needed for demo purposes
only
248. % I_itermax maximum number of iterations (generations)
249. I_itermax = 200;
250. % F_weight DE-stepsize F_weight ex [0, 2]
251. F_weight = 0.8;
252. % F_CR crossover probabililty constant ex [0, 1]
253. F_CR = 0.9;
254. % I_strategy 1 --> DE/rand/1:
255. % the classical version of DE.
256. % 2 --> DE/local-to-best/1:
257. % a version which has been used by quite a number
258. % of scientists. Attempts a balance between robustness
259. % and fast convergence.
260. % 3 --> DE/best/1 with jitter:
261. % taylored for small population sizes and fast convergence.
262. % Dimensionality should not be too high.
263. % 4 --> DE/rand/1 with per-vector-dither:
264. % Classical DE with dither to become even more robust.
265. % 5 --> DE/rand/1 with per-generation-dither:
266. % Classical DE with dither to become even more robust.
267. % Choosing F_weight = 0.3 is a good start here.
268. % 6 --> DE/rand/1 either-or-algorithm:
269. % Alternates between differential mutation and three-point-
270. % recombination.
271. I_strategy =2;
272. % I_refresh intermediate output will be produced after "I_refresh"
273. % iterations. No intermediate output will be produced

37
274. % if I_refresh is < 1
275. I_refresh = 0;
276. % I_plotting Will use plotting if set to 1. Will skip plotting otherwise.
277. I_plotting = 0;
278. %-----Problem dependent constant values for plotting----------------
279. if (I_plotting == 1)
280. FVc_xx = [-3:0.25:3]';
281. FVc_yy = [-3:0.25:3]';
282. [FVr_x,FM_y]=meshgrid(FVc_xx',FVc_yy') ;
283. FM_meshd = peaks(FVr_x,FM_y);
284. S_struct.FVc_xx = FVc_xx;
285. S_struct.FVc_yy = FVc_yy;
286. S_struct.FM_meshd = FM_meshd;
287. end
288. S_struct.I_NP = I_NP;
289. S_struct.F_weight = F_weight;
290. S_struct.F_CR = F_CR;
291. S_struct.I_D = I_D;
292. S_struct.FVr_minbound = FVr_minbound;
293. S_struct.FVr_maxbound = FVr_maxbound;
294. S_struct.I_bnd_constr = I_bnd_constr;
295. S_struct.I_itermax = I_itermax;
296. S_struct.F_VTR = F_VTR;
297. S_struct.I_strategy = I_strategy;
298. S_struct.I_refresh = I_refresh;
299. S_struct.I_plotting = I_plotting;
300. %**********************************************************
**********
301. % Start of optimization
302. %**********************************************************
**********

38
303. [FVr_x,S_y,I_nf] = deopt('objfun',S_struct);
304. myfunction.m
305. function f = myfunc(x,r)
306. g1=x(8);
307. g2=x(9)-x(10);
308. g3=x(10);
309. g4=x(7);
310. g5=x(9);
311. g6=x(2);
312. if(g1<=0||g2<0||g3<0||g4<0||g5>=1||g6<0)
313. f=10000;
314. else
315. t=length(r);
316. mu=x(1);
317. omega=x(2);
318. alpha=x(3);
319. alphaj=x(4);
320. alphaa=x(5);
321. alphaaj=x(6);
322. beta=x(7);
323. lamda0=x(8);
324. rho=x(9);
325. gama=x(10);
326. theta=x(11);
327. delta=x(12);
328. sigma=zeros(t,1);
329. lamda=zeros(t,1);
330. f3=zeros(t,1);
331. abxlong=zeros(t,1);
332. g=zeros(t,1);
333. xp=20;

39
334. % proba=zeros(t,1);
335. p=zeros(t,xp+1);
336. for i=1:t
337. % if i==13;
338. % i=13;
339. % end
340. E=0;
341. if i==1
342. abxlong(i)=0;
343. else
344. for j=0:xp
345. %¼ÆËãE
346. E=E+j*p(i-1,j+1);
347. end
348. abxlong(i)=E-lamda(i-1);
349. if(r(i-1)-mu<0)
350. g(i)=exp(alpha+alphaj*E+alphaa+alphaaj*E);
351. else
352. g(i)=exp(alpha+alphaj*E);
353. end
354. end
355. if(i==1)
356. lamda(i)=lamda0/(1-rho);
357. sigma(i)=omega;
358. else
359. lamda(i)=lamda0+rho*lamda(i-1)+gama*abxlong(i);
360. sigma(i)=omega+g(i)*((r(i-1)-mu)^2)+beta*sigma(i-1);
361. end
362. sums=0;
363. for j=0:xp
364. x1=1/(sqrt(2*pi*(sigma(i)+j*delta*delta)));

40
365. s1=(r(i)-mu+theta*lamda(i)-theta*j);
366. s2=2*(sigma(i)+j*delta*delta);
367. x2=exp(-s1*s1./s2);
368. x3=exp(-lamda(i))*(lamda(i)^j)/factorial(j);
369. sums=sums+x1*x2*x3;
370. end
371. f3(i)=log(sums);
372. %¼ÆËãµ±ÈÕʺó¸ÅÂÊ·Ö²¼
373. for j=0:xp
374. x1=1/(sqrt(2*pi*(sigma(i)+j*delta*delta)));
375. s1=(r(i)-mu+theta*lamda(i)-theta*j);
376. s2=2*(sigma(i)+j*delta*delta);
377. x2=exp(-s1*s1./s2);
378. x3=exp(-lamda(i))*(lamda(i)^j)/factorial(j);
379. p(i,j+1)=x1*x2*x3/sums;
380. end
381. % roba(i)=sum(p(i,2:end));
382. end
383. f=-sum(f3(2:end));
384. end
385. End
386. leftwin.m
387. % Function: I_z = left_win(S_x,S_y)
388. % Author: Rainer Storn
389. % Description: left_win(S_x,S_y) takes structures S_x and S_y as an

8.9 ARGUMENT.M
390. % he function returns 1 if the left structure of the input structures,
391. % i.e. S_x, wins. If the right structure, S_y, wins, the result is
392. % Parameters: S_x.I_nc (I) Number of constraints (must be the same
for x and y).

41
393. % _x.I_no (I) Number of objectives (must be the same for x and y).
394. % S_x.FVr_ca (I) Constraint array containing the constraint violation
values.
395. % If the value is 0 the constraint is met. If it is > 0 it is
396. % still violated.
397. % S_x.FVr_oa (I) Objective array containing cost values which are
supposed to be
398. % minimized.
399. % Return value: I_z (O) If S_x wins over S_y then I_z=1 else
I_z=0.
400. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
401.
402. function I_z = left_win(S_x,S_y);
403. I_z = 1; %start with I_z=1
404.
405. %----deal with the constraints first. If constraints are not met------
406. %----S_x can't win.---------------------------------------------------
407. if (S_x.I_nc > 0)
408. for k=1:S_x.I_nc
409. if (S_x.FVr_ca(k) > 0) %if constraint is not yet met
410. if (S_x.FVr_ca(k) > S_y.FVr_ca(k))%if just one constraint of S_x is
not improved
411. I_z = 0;
412. end
413. end
414. end
415. end
416. if (S_x.I_no > 0)
417. for k=1:S_x.I_no
418. if (S_x.FVr_oa(k) > S_y.FVr_oa(k))%if just one objective of S_x is

42
less
419. I_z = 0;
420. end
421. end
422. end
423. test.m
424. % testing on new December 2016 price data
425. dataArray = csvread('results.csv');
426. prices = transpose(dataArray(:,2));
427. askVolume = dataArray(:,3);
428. bidVolume = dataArray(:,4);
429. prices = prices(1:2:end);
430. askVolume = askVolume(1:2:end);
431. bidVolume = bidVolume(1:2:end);
432. % estimate transaction fee at %1
433. [error,jinzhi,bank,buy,sell,proba] = brtrade(prices,bidVolume,askVolume,
434. % set up plots
435. make_plots(prices, buy, sell, proba, bank, error);

8.10 MAIN.COM

436. function varargout = Main_Gui_D2D_Comm(varargin)


437. % MAIN_GUI_D2D_COMM MATLAB code for
Main_Gui_D2D_Comm.fig
438. % MAIN_GUI_D2D_COMM, by itself, creates a new
MAIN_GUI_D2D_COMM or raises the existing
439. % singleton*.
440. %
441. % H = MAIN_GUI_D2D_COMM returns the handle to a new
MAIN_GUI_D2D_COMM or the handle to
442. % the existing singleton*.

43
443. %
444. %
MAIN_GUI_D2D_COMM('CALLBACK',hObject,eventData,handles,...) calls
the local
445. % function named CALLBACK in MAIN_GUI_D2D_COMM.M with
the given input arguments.
446. %
447. % MAIN_GUI_D2D_COMM('Property','Value',...) creates a new
MAIN_GUI_D2D_COMM or raises the
448. % existing singleton*. Starting from the left, property value pairs are
449. % applied to the GUI before Main_Gui_D2D_Comm_OpeningFcn gets
called. An
450. % unrecognized property name or invalid value makes property
application
451. % stop. All inputs are passed to Main_Gui_D2D_Comm_OpeningFcn
via varargin.
452. %
453. % *See GUI Options on GUIDE's Tools menu. Choose "GUI allows
only one
454. % instance to run (singleton)".
455. %
456. % See also: GUIDE, GUIDATA, GUIHANDLES
457.
458. % Edit the above text to modify the response to help
Main_Gui_D2D_Comm
459. % Last Modified by GUIDE v2.5 20-Feb-2019 10:05:45
460. % Begin initialization code - DO NOT EDIT
461. gui_Singleton = 1;
462. gui_State = struct('gui_Name', mfilename, ...
463. 'gui_Singleton', gui_Singleton, ...
464. 'gui_OpeningFcn', @Main_Gui_D2D_Comm_OpeningFcn, ...

44
465. 'gui_OutputFcn', @Main_Gui_D2D_Comm_OutputFcn, ...
466. 'gui_LayoutFcn', [] , ...
467. 'gui_Callback', []);
468. if nargin && ischar(varargin{1})
469. gui_State.gui_Callback = str2func(varargin{1});
470. end

8.11 RUN.COM

471. close all;


472. clear all;
473. clc
474. warning off;
475. Main_Gui_D2D_Comm
476. trani reheser.com
477. function [theta, theta_0] = train_regressor(X, y, gamma)
478. % X is a matrix with d columns, one for each dimension of the
479. % feature vector, and n rows, one for each training example
480. % y is an n-length vector of training example values.
481. % gamma is a scalar regularization parameter (gamma = 0, no
regularization)
482. % theta is an n-length vector of feature weights,
483. % theta_0 is a scalar offset.
484.
485. % If the data can be fit perfectly, then X*theta + theta_0 = y, otherwise
486. % theta and theta_0 are chosen to minimize the sum of the squares of the
error
487. % plus gamma *(theta'*theta + theta_0^2). Here, the error is
488. % (y - (X*theta + theta_0)).
489. d = size(X,2);
490. n = size(X,1);

45
491. last_col = ones(n,1);
492. Xp = [X, last_col];
493. if gamma > 0
494. I_np1 = speye(d+1);
495. I_n = I_np1(1:end-1, :);
496. Xp = [Xp; sqrt(gamma)*I_n];
497. y = [y; zeros(d,1)];
498. end
499. end
500. theta_theta_0 = Xp \ y;
501. assert(length(theta_theta_0 ) == d+1);
502. theta = theta_theta_0(1:d);
503. theta_0 = theta_theta_0(end);

8.12 VECSIAM.M

504. %find the similarity between two vectors


505. assert(length(x)==length(y),'these vectors are different lengths!');
506. assert(~isempty(x),'need a larger vector');
507. num = sum((x - mean(x)).*(y-mean(y)));

46
9. SCREEN SHOTS

9.1 MAIN PAGE

9.2 INPUT DATASET

47
9.3 ENCODEING
9.3.1 CONVOLUTIONAL ENCODING DATA OUT

9.3.2 INPUT DATA OF BIT COIN VALUES

48
9.4 SELECTIVE LABELING

9.4.1 COIN RATE AND CURRENCY DETECTION

49
9.5 DEEP LEARNING BITCOIN

9.5.1 COIN VALUE LEARNING

50
9.6 LSTM

9.6.1 PREDICTION VALUE

51
9.6.2 DEEP LEARNING TO COIN

9.7 PREDICTION

52
9.7.1 ANALYSIS OF DATA

9.8 PERFORMANCE
9.8.1 ACCURACY RATE FOR BITCOIN

53
9.8.2 BITCOIN ANALYSIS RATE COMPARISON

9.8.3 ACCURACY RATE FOR LONG TERM PROCESS PREDICTION

54
10. SYSTEM TESTING

10.1 TESTING METHODOLOGIES


The following are the Testing Methodologies:
 Unit Testing.
 Integration Testing.
 User Acceptance Testing.
 Output Testing.
 Validation Testing.

10.1.1 UNIT TESTING

Unit testing focuses verification effort on the smallest unit of Software design that is the
module. Unit testing exercises specific paths in a module’s control structure to ensure complete
coverage and maximum error detection. This test focuses on each module individually, ensuring
that it functions properly as a unit. Hence, the naming is Unit Testing.
During this testing, each module is tested individually and the module interfaces are
verified for the consistency with design specification. All important processing path are tested
for the expected results. All error handling paths are also tested.

10.1.2 INTEGRATION TESTING

Integration testing addresses the issues associated with the dual problems of verification
and program construction. After the software has been integrated a set of high order tests are
conducted. The main objective in this testing process is to take unit tested modules and builds a
program structure that has been dictated by design.
1. TOP DOWN INTEGRATION
This method is an incremental approach to the construction of program structure.
Modules are integrated by moving downward through the control hierarchy, beginning with the
main program module. The module subordinates to the main program module are incorporated
into the structure in either a depth first or breadth first manner.

55
2. BOTTOM-UP INTEGRATION

This method begins the construction and testing with the modules at the lowest level in
the program structure. Since the modules are integrated from the bottom up, processing required
for modules subordinate to a given level is always available and the need for stubs is eliminated.
The bottom up integration strategy may be implemented with the following steps

 The low-level modules are combined into clusters into clusters that perform a
specific Software sub-function.
 A driver (i.e.) the control program for testing is written to coordinate test case
input and output.
 The cluster is tested.
 Drivers are removed and clusters are combined moving upward in the
program structure
10.1.3 USER ACCEPTANCE TESTING

User Acceptance of a system is the key factor for the success of any system. The system
under consideration is tested for user acceptance by constantly keeping in touch with the
prospective system users at the time of developing and making changes wherever required. The
system developed provides a friendly user interface that can easily be understood even by a
person who is new to the system.

10.1.4 OUTPUT TESTING

After performing the validation testing, the next step is output testing of the proposed
system, since no system could be useful if it does not produce the required output in the specified
format. Asking the users about the format required by them tests the outputs generated or
displayed by the system under consideration. Hence the output format is considered in 2 ways –
one is on screen and another in printed format.

56
10.1.5 VALIDATION CHECKING

Validation checks are performed on the following fields.

TEXT FIELD

The text field can contain only the number of characters lesser than or equal to its size. The text
fields are alphanumeric in some tables and alphabetic in other tables. Incorrect entry always
flashes and error message.

NUMERIC FIELD

The numeric field can contain only numbers from 0 to 9. An entry of any character
flashes an error messages. The individual modules are checked for accuracy and what it has to
perform. Each module is subjected to test run along with sample data. The individually tested
modules are integrated into a single system.
Testing involves executing the real data information is used in the program the existence
of any program defect is inferred from the output. The testing should be planned so that all the
requirements are individually tested.A successful test is one that gives out the defects for the
inappropriate data and produces and output revealing the errors in the system.

57
11. CONCLUSION

Deep learning models such as the RNN and LSTM are evidently effective for Bitcoin
prediction with the LSTM more capable for recognising longer-term dependencies. However, a
high variance task of this nature makes it difficult to transpire this into impressive validation
results. As a result it remains a difficult task. There is a fine line between overfitting a model and
preventing it from learning sufficiently. Dropout is a valuable feature to assist in improving this.
However, despite using Bayesian optimisation to optimize the selection of dropout it still
couldn’t guarantee good validation results.

Despite the metrics of sensitivity, specificity and precision indicating good performance,
the actual performance of the ARIMA forecast based on error was significantly worse than the
neural network models. The LSTM outperformed the RNN marginally, but not significantly.
However, the LSTM takes considerably longer to train. The performance benefits gained from
the parallelization of machine learning algorithms on a GPU are evident with a 70.7%
performance improvement for training the LSTM model.

58
12. FUTURE ENHANCEMENT

Looking at the task from purely a classification perspective it may be possible to achieve
better results. One limitation o is that the model has not been implemented in a practical or real
time setting for predicting into the future as opposed to learning what has already happened. In
addition, the ability to predict using streaming data should improve the model. Sliding window
validation is an approach not implemented here but this may be explored as future work.

59
13. BIBLIOGRAPHY

REFERENCES

1. S. Nakamoto, “Bitcoin: A peer-to-peer electronic cash system,” 2008.

[2] M. Bri`ere, K. Oosterlinck, and A. Szafarz, “Virtual currency, tangible


return:Portfoliodiversificationwithbitcoins,” Tangible Return: Portfolio Diversification
with Bitcoins (September 12, 2013), 2013.

[3] I. Kaastra and M. Boyd, “Designing a neural network for forecasting financial and
economic time series,” Neurocomputing, vol. 10, no. 3, pp. 215–236, 1996.

[4] H. White, “Economic prediction using neural networks: The case of ibm daily stock
returns,” in Neural Networks, 1988., IEEE International Conference on. IEEE, 1988, pp.
451–458.

[5] C. Chatfield and M. Yar, “Holt-winters forecasting: some practical issues,” The
Statistician, pp. 129–140, 1988.

[6] B. Scott, “Bitcoin academic paper database,” suitpossum blog, 2016.

[7] M. D. Rechenthin, “Machine-learning classification techniques for the analysis and


prediction of high-frequency stock direction,” 2014.

[8] D. Shah and K. Zhang, “Bayesian regression and bitcoin,” in Communication,


Control, and Computing (Allerton), 2014 52nd Annual Allerton Conference on. IEEE,
2014, pp. 409–414.

[9] G. H. Chen, S. Nikolov, and D. Shah, “A latent source model for nonparametric time
series classification,” in Advances in Neural Information Processing Systems, 2013, pp.
1088–1096.

[10] I. Georgoula, D. Pournarakis, C. Bilanakos, D. N. Sotiropoulos, and G. M. Giaglis,


“Using time-series and sentiment analysis to detect the determinants of bitcoin prices,”
Available at SSRN 2607167, 2015.

60
[11] M. Matta, I. Lunesu, and M. Marchesi, “Bitcoin spread prediction using social and
web search media,” Proceedings of DeCAT, 2015.

[12] ——, “The predictor impact of web search media on bitcoin trading volumes.”

[13] B. Gu, P. Konana, A. Liu, B. Rajagopalan, and J. Ghosh, “Identifying information in


stock message boards and its implications for stock market efficiency,” in Workshop on
Information Systems and Economics, Los Angeles, CA, 2006.

[14] A. Greaves and B. Au, “Using the bitcoin transaction graph to predict the price of
bitcoin,” 2015.

[15] I. Madan, S. Saluja, and A. Zhao, “Automated bitcoin trading via machine learning
algorithms,” 2015.

61

Вам также может понравиться