A Quantum based Evolutionary Algorithm for Stock Index and Bitcoin Price Forecasting

Quantum computing has emerged as a new dimension with various applications in different fields like robotic, cryptography, uncertainty modeling etc. On the other hand, nature inspired techniques are playing vital role in solving complex problems through evolutionary approach. While evolutionary approaches are good to solve stochastic problems in unbounded search space, predicting uncertain and ambiguous problems in real life is of immense importance. With improved forecasting accuracy many unforeseen events can be managed well. In this paper a novel algorithm for Fuzzy Time Series (FTS) prediction by using Quantum concepts is proposed in this paper. Quantum Evolutionary Algorithm (QEA) is used along with fuzzy logic for prediction of time series data. QEA is applied on interval lengths for finding out optimized lengths of intervals producing best forecasting accuracy. The algorithm is applied for forecasting Taiwan Futures Exchange (TIAFEX) index as well as for Bitcoin crypto currency time series data as a new approach. Model results were compared with many preceding algorithms. Keywords—Quantum evolutionary algorithm; fuzzy time series; nature inspired computing; fuzzy logic; crypto currency; bitcoin


INTRODUCTION
Predicting unseen situations and future events hold immense importance and is a need of humanity.Forecasting is important in financial sector as the financial loss in investments can create hurdles for capitalists.Potential areas for forecasting include weather prediction, stock market forecasting, funds management; commodities price calculation, crime rate prediction, floods, droughts and earthquake prediction etc.A lot of research has been done in areas of forecasting and quantum computing.Zadeh [1] introduced fuzzy set theory and worked on its applications later on.Lee et al. [2] proposed algorithms for temperature and stock index prediction on the basis of fuzzy logical relation groups (FLRGs) and genetic algorithm (GA).Jilani and Burney [3], [4] and Jilani, Burney and Ardil [5], [6] proposed new fuzzy metrics for higher-order multivariate FTS forecasting for accidents data of Belgium.Huang et al. [7] formulated a forecasting algorithm on the basis of FTS and Particle Swarm Optimization (PSO), and applied it on enrolments data.Kuo et al. [8] presented a hybrid forecasting algorithm for TAIFEX index forecasting based on FTS and PSO.Jilani, Amjad and Mastorakis [9] presented a hybrid algorithm using GA and PSO for fuzzy time series prediction for TAIFEX index and KSE-100 index and got better results.Amjad, Jilani and Yasmeen [10] formulated a two phase fuzzy time series (FTS) forecasting model using GA and PSO.
Quantum Computing is new computing paradigm based on quantum-mechanical phenomenon like q-bits, superposition and entanglement etc. [11].Emergence of quantum computing techniques has given immense power to computations and thus these concepts are being applied to different domains and problems of computer science [12].Concept of Quantum mechanical computers was introduced in early 1980s [11] and the explanation of quantum mechanical computers was enacted in late years of 1980s [12].Enormous efforts are being made for evolution of quantum computers since inception of Quantum concepts in computing, as these computers are considered more powerful as compared to classical computers for variety of complex problems.Few renowned quantum algorithms include Shor's quantum factoring algorithm [13], [14] presented in 1998, and Grover's database search algorithm [15], [16] presented in mid 1990s.Efforts were made to combine evolutionary algorithms along with quantum computing concepts, which gave birth to quantum-inspired evolutionary computing for a classical computer, an area of Evolutionary Computing (EC) combined with principles of quantum mechanics such as standing waves, interference, coherence, etc. A. Narayanan and M. Moore [17], [18], presented the concept of interference included in a crossover operator.
Concept of crypto currency brought together principles of economics, cryptography and computer science by using encryption technologies for issuance of monetary units.Funds are generated and transferred by using encryption methods without intervention and monitoring of some central governing authority.In 2009, Bitcoin was released as open-source software by Satoshi Nakamoto.Bitcoin is the first peer to peer electronic cash system or crypto currency which revolutionized the concept of digital payment systems [19].For the prediction of price, studies by Garcia & Schweitzer [20] explain auto regression techniques.They identify two positive feedback loops leading to price bubbles.Similarly, Amjad & Shah [21] propose a theoretical framework and develop a real-time algorithm in order to achieve significant return value on the investment of Bitcoin.Moreover, research study by Kondor et al. [22] explains the Principal Component Analysis related to the block chain network data in order to identify correlation between changes in price exchange and principal variables.Crypto currency web data is used by Kim et al. [23] to predict price fluctuation of Bitcoin.Guo & Antulov-Fantulin [24] construct a temporal mixture model which is a more efficient time-series statistical model than the traditional approaches.www.ijacsa.thesai.orgJang & Lee [25] conducted a comparative study regarding the fluctuation of pricing of Bitcoin.

A. Quantum Bits (Qubits)
The tiniest entity in which a two-state Quantum computer stores information is called a quantum bit or Qubit [26].
Qubit is atomic unit of information storage in Quantum computer and can be in state -0‖ or state -1‖ or any superposition of the two.Bloch sphere representation of Quantum bits is given in Figure 1.The state of quantum bit can be characterized as where ⍺ and β are two complex values representing the probability amplitudes of respective states.α 2 represents the probability of qubit being in state -0‖ while β 2 represents probability of being in state -1‖.Thus the sum of probabilities must be equal to 1

⍺
(2) Fig. 1.A Quantum bit represented as a Bloch Sphere At any given time a Qubit may either be in state "0" or state "1" or a superposition of both the states.Qubit can be represented using a pair of complex values (α,β) like [ ]

B. Qubit Individual
A Qubit individual is a sequence of qubits with length m represented as where for i=1,2,…,m.
Initially, and values are generally set to √ for making equal probability of all qubits.
where is ith Qubit individual at time t.

D. Q-gate
Variation is produced in Qubit individuals using a rotation operator called Q-gate.Rotation is applied to each Qubit and their positions are updated keeping in view the constraint of normalization of probabilities i.e. ⍺ . The rotation operator used as Q-gate usually is where , i=1,2, … , m is rotation angle for each Qubit.Qgate is applied individually to each Qubit of every individual of population, which moves the Qubit either towards 0 or 1.Furthermore, there are operators other than rotation, which can be used as Q-gates such as NOT gate, controlled NOT gate, Hadmard gate etc.

E. Quantum Evolutionary Algorithm (QEA)
QEA was proposed by Kuk-Hyun Han in his Ph.D thesis titled -Quantum-inspired Evolutionary Algorithm‖ in 2003.Concepts of Quantum computing and evolutionary computing were combined in this algorithm.The proposed algorithm is given in Figure 2.

F. Fuzzy Time Series (FTS)
To deal with uncertain situations, Fuzzy logic and fuzzy set theory was coined by Zadeh [27].Later on Song and Chisom [28] introduced a time series to tackle fuzziness, called Fuzzy Time Series (FTS).A number of variants of FTS were produced and many researchers used FTS in different areas of application.Few basic concepts of FTS include fuzzy operations, fuzzy relations and fuzzy logical relationship groups [3], [4], [5].

III. PROPOSED ALGORITHM FOR FTS FORECASTING USING QEA
Step 1: Define the universe of discourse Define universe of discourse for primary-factor X like U = [D min -D 1 , D max +D 2 ], where D min is minimum index value and D max is maximum index value from the historical data under consideration, and D 1 and D 2 are positive real numbers for extending universe of discourse [3] [4].
, where E min is the minimum value of secondary factor and E max is the maximum value of secondary factor from historical data under consideration, respectively, and E1 and E2 are two positive numbers used for extending universe of discourse for secondary factor.Also find out Range for both main and secondary factors [5].
Higher Education Commission (HEC) Pakistan www.ijacsa.thesai.org Step 2: Initialize QEA population Qubit is greater than 0.5, then append ‗1' to the string otherwise append ‗0'.In this way a string containing 11 binary bits will be obtained from Qubits individuals.Then convert that binary string into decimal number and add that number into minimum value of time series i.e.Dmin, to get a value in interval.If that value is exceeding the maximum value of time series i.e.Dmax then subtract a random number from it to bring it in universe of discourse.Finally sort all the interval values in ascending order.Step 4: Find forecast and store best values State the linguistic value A i for main factor, where i=1, 2,…, n, and n is the total interval count in universe of discourse for primary factor [3], [4], [5].
Similarly, state the linguistic term Bj for secondary factor where j=1, 2,…, m, and m is the total number of intervals present in universe of discourse V of secondary factor: Historical data is fuzzified as described below.
Determine the interval u i , 1≤ i≤ n, to which the value of the main-factor belongs.a) If the value belongs to interval u1, then it is fuzzified into 1/A 1 +0.5/A 2 , denoted by X 1 .
c) If the value belongs to un, then it is fuzzified into 0.5/An-1+1/An, denoted by Xn.
Determine the interval v j , 1≤ j≤ m, to which the value of the second-factor belongs.Build two factor nth-order FLRs based on primary and second factors from the fuzzified historical data obtained in above step.If the fuzzified data of primary factor for day i is X i , then create two factor kth-order FLRs from day i-k to day i as (( where 2≤ k≤ n and represent the fuzzified data values for primary-factor for days i-k,…, i-2, i-1 respectively; denote the fuzzified data values of secondary factor for days i-k,…, i-2, i-1, respectively.After that FLRs are divided into fuzzy logical relationship groups (FLRGs) based on the present states of FLRs [3].
For the determined FLRGs forecasted value is calculated using formula given below: Where is forecasted value at time k where as , are mid points of intervals in which value at time k lies in.
After finding the forecasted value determine then fitness value of each individual chromosome of the population.We have used Average forecasting error rate (AFER) and mean square error (MSE) as fitness values of each individual for our forecasting algorithm.
Based on fitness value, if fitness value of current lot of individuals is better than previous individuals than store these Qubit individuals separately, otherwise replace these individuals by previously best individuals.
Step 5: Apply rotation on individuals suing Q-gate Apply Quantum gate on individuals with angle θ.Initially value of θ is set to 0, but with each iteration, an increment of 0.01 is made.Q-gate is applied on all individuals and in this way a new population of individuals evolves out.
Step 6: Check stopping criteria or repeat www.ijacsa.thesai.orgCheck if the stopping criteria of algorithm are met or not.Stopping criteria may be the value of fitness function to reach to a specific point or the number of repetitions.If stopping criteria is not met then go to step 3 and repeat all further steps.

IV. EXPERIMENTAL RESULTS
We have used TAIFEX index and Bitcoin closing price historical data for experiment using our proposed algorithm.We have applied the suggested algorithm to the TAIFEX dataset for the duration of August 3, 1998 to September 30, 1998 where the TAIFEX index values are taken as the primaryfactor and the TAIEX index values are taken as the secondfactor.We have executed proposed method and compared obtained results for TAIFEX forecasting with existing method's results.Results obtained from our Novel Algorithm and the error criteria AFER and MSE are shown in Table 4. Table 2 shows best Qubits obtained after evolution for TAIFEX forecasting.Table 3 shows the best individual obtained after evolution for TAIFEX forecasting.
We have also applied the proposed algorithm for forecasting of Bitcoin closing prices.Data for Bitcoin prices has been obtained from coinmarketcap, an online source of crypto currency prices and their market capitalization.Obtained dataset comprise of historical data of 3 months for daily closing prices of Bitcoin from 22nd February 2018 till 22nd May 2018. .We have applied 2000 generations of evolution for Bitcoin forecasting.Forecasting results for Bitcoin forecasting are shown in Table 5.Table 6 shows best individual evolved after applying proposed algorithm for Bitcoin forecasting.Figure 5 shows comparison of actual and forecasted time series data for Bitcoin forecasting.V. COMPARISON WITH OTHER MODELS Our proposed model is unique in time series forecasting as it uses concepts of Quantum computing and evolutionary algorithms along with fuzzy logic.The proposed algorithm was compared to other models and we observed that it is producing better results than many predecessors.Forecast from proposed model is having AFER of 0.84% and MSE of 5252.28.Comparisons of forecasting results obtained from our algorithm for TAIFEX forecasting are shown in Table 7 and Table 8. Figure 3 shows comparison of actual time series data and forecasted data from our algorithm.Table 8 shows comparison of our forecasting result with various other algorithms' results also shown in Figure 4.

Huarng 2001b
Proposed method www.ijacsa.thesai.orgIn this research we have formulated a novel approach for FTS forecasting using Quantum concepts and Evolutionary Algorithms.The Quantum Evolutionary Algorithm is used in combination with FTS forecasting and used to adjust interval lengths for better forecasting values.The unique algorithm was applied on TAIFEX index forecasting and Bitcoin price prediction.TAIFEX index forecasting produced AFER of 0.8478 while Bitcoin prediction produced AFER of 0.96%.AFER of the proposed model for TAIFEX forecasting is better than many of its predecessors.The proposed method is unique in the sense that Quantum computing along with Genetic Algorithms and Fuzzy Logic has never been developed before.The methods provide a new dimension for economic and financial modeling where optimization in various models can be improved with respect to accuracy and computational complexity.
In future, we aim to apply QEA to various algorithms of forecasting and portfolio optimization for improving model efficiency.Moreover, it is aimed at applying Quantum computing concepts on different nature inspired algorithms for designing new and powerful approaches to optimization techniques.

Fig. 2 .Step 3 :
Fig. 2. Pseudo code of Quantum Evolutionary Algorithm QEA population comprises of 15 Qubit individuals and each Qubit individual has 11 Qubit.Number of Qubit individuals is because we will divide Universe of Discourse into 16 intervals, making use of Dmin and Dmax, while 11

TABLE IV .
FORECASTED TAIFEX VALUES

TABLE VII .
AFERS OF DIFFERENT FORECASTING MODELS

TABLE VIII .
FORECASTS FROM DIFFERENT FORECASTING MODELS AND PROPOSED MODELS