0% found this document useful (0 votes)
9 views

Genetic Algorithm Based Optimization For Efficient Investment

Uploaded by

Myra
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views

Genetic Algorithm Based Optimization For Efficient Investment

Uploaded by

Myra
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

Genetic Algorithm-Based Optimization for Efficient

Investment
Sarvesh Tanwar
Manu Bhargav AIIT
AIIT Amity University
Amity University Noida,India
Noida,India [email protected]
[email protected]

Abstract—This work investigates how Genetic Algorithms is not out of the ordinary. Knowing whether stock prices
(GAs) might be used to optimize investment strategies with will rise or fall the following day is necessary in order to
the goal of enhancing financial market decision-making. make financial investments in the stock market. Therefore,
Inspired by natural selection and genetics, genetic algorithms the goal of this study is to forecast whether a stock's peak
provide a potent optimization tool to tackle the intricacies of price will rise or fall the next day. We are attempting to
investment portfolio management. The traditional method of forecast the stock prices of eight distinct firms in this
making investment decisions frequently depends on historical research. We forecast whether the highest price of each
data and static models, which might not fully reflect the company will increase or decrease the following day. There
dynamic nature of financial markets. In contrast, a dynamic are only two classes involved, making it a classification
and adaptable framework that can change over time is offered problem. As a result, we have made every effort to simplify
by genetic algorithms. Their flexibility in handling shifting the issue. Chien-Feng [1] looks for connections between
market conditions and optimizing investment portfolios is a Monday and Friday stock price movements in the stock
result of their adaptability. The study commences with market. Prices have been seen to increase more regularly
delineating the essential concepts of Genetic Algorithms and on Fridays than on any other day. Additionally, compared
their appropriateness in resolving intricate optimization to other days, Mondays have seen the least amount of price
issues. After that, it explores the particular difficulties
increases. Searches for a cross-correlation between price
involved in making investing decisions, highlighting the
and volume changes were conducted by Lauri Nyman [2].
necessity of flexible tactics in the face of volatile markets. The
Volumes are required to move the stock price in order for
creation of a model based on genetic algorithms with the goal
it to alter. Two significant empirical findings were
of optimizing investment portfolios is part of the study
obtained. The first shows a power law cross-correlation in
process. As input parameters, the model takes into account
market patterns, risk tolerance levels, and important financial
the logarithmic changes in price and volume, whereas the
data. A number of simulations and back testing exercises are
second shows that the logarithmic changes in volume and
used to evaluate how well the Genetic Algorithm performs in price follow the same cubic law.
terms of increasing investment returns and lowering risks.
According to Chien-Feng [1], financial insolvency can be
predicted using a genetic algorithm. We have also
attempted to forecast the stock using a comparable method.
Keywords—machine learning, finance, investment,
This might even be used to forecast stock prices. Important
decision-making, genetic algorithms, selection, optimize
traits have been predicted and extracted using the genetic
I. INTRODUCTION method [1-4]. Many analyses of the variables influencing
Stock price forecasting has never been an easy undertaking. stock prices and the financial market have been conducted.
It has been noted that a company's stock price is not always There are various methods for forecasting stock prices.
influenced by the state of the national economy. It is no Feature selection or the extraction of the best characteristics
longer closely associated with the nation's or a specific are two methods for reducing complexity. As the
region's economic growth. Predicting stock prices has complexity goes down, this method will help us predict
therefore become considerably more challenging than it stock prices more accurately. This research employs a
was previously. These days, a variety of factors, such as revolutionary way to anticipate the greatest price. We
news about companies, political developments, natural attempt to determine the relationship weights between each
disasters, etc., can influence stock prices. The stock prices attribute and the stock price prediction. Each organization
have experienced rapid fluctuations due to the efficient
utilizes a total of six qualities. For this reason, we employ
processing of data from these events through enhanced
technology and communication systems. As a result, a six connection weights—one for every attribute. The
significant number of financial institutions must purchase contribution of every element to the price prediction of
aas well as sell equities as quickly as possible. Therefore, a stocks is defined by each connection weight value. For
few hours or even a few days between buying and selling instance, it is possible that the volume attribute makes a
greater contribution than the other attributes.

XXX-X-XXXX-XXXX-X/XX/$XX.00 ©20XX IEEE


A. Genetic Algorithms a variety of Pareto-optimal solutions.
The genetic algorithm is a method to optimize real world
problems that we face which can be both restrained and GAs have been used to improve investment risk
unrestrained. It follows after the natural process of natural management techniques. Genetic algorithms were used by
selection and it is the prime driving factor of biological Menkveld and Zoican (2022) to optimize trading methods,
evolution. They are used to repititevely modify a highlighting the significance of adjusting to shifting market
population of unique solutions. Through multiple continous liquidity conditions for efficient risk management. The
generations, the population changes in a manner that it can application of GA-based investing methods in practice is
be called evolved or optimized. Genetic Algorithms can be examined in recent work. Using real-world datasets,
used to solve multiple problems related to optimization like researchers have shown that GAs outperform traditional
those having discontinous, ambiguous or nonlinear models and are effective at adjusting to market fluctuations
functions. (Zhang, Xin-Li, and Ke-Cun Zhang, 2009) [8]. Using
genetic algorithms, Petras Dubinskas and Urbšienė Laima
[10] created a feature transformation technique. By using
this method, the feature space's dimensionality is decreased
and unimportant variables that affect stock price prediction
are eliminated. In another study, Kyoung-jae Kim [4] used
genetic algorithms (GAs) for the prediction of stocks in the
industry by utilizing them to both simplify the feature space
and enhance the learning process. As a result, this method
improves the classifier's generalizability while decreasing
the complexity of the feature space. Additionally, Ajith
Abraham [3] created a hybrid intelligent system that
combines derivative-free optimization approaches, fuzzy
inference systems, neural networks, and approximation
reasoning. Although the technology shows promise as well,
it hasn't been compared to any other intelligent systems that
Figure i) Genetic Algorithms are now in use [12-14].

B. Objectives In order to improve prediction and financial decision-


The study aims to investigate and assess a new approach to making, recent research has investigated the integration of
stock price prediction that makes use of evolutionary GAs with machine learning approaches. This
techniques and genetic algorithms. In the study, the multidisciplinary strategy makes use of both paradigms'
advantages.
effectiveness of these two methods for prediction of stock
prediction is compared; the evolutionary strategies yield an
accuracy of 71.77%, while the genetic algorithm's greatest
performance is 73.87%. In order to determine whether III. METHODOLOGY
overfitting has occurred, the study uses two different A. Collection of Data and Pre-Processing
datasets for testing and training. The findings show that
The dataset utilized for this experiment is comprised of
overfitting has not occurred. The evolutionary algorithm is
information from the previous five years. The prediction
useful in solving mixed integer programming problems,
process includes a total of six attributes for each
where some elements can only have integer values.
organization. These consist of the volume, the greatest and
lowest prices, the opening and closing prices, the modified
II. LITERATURE REVIEW closing price, and so on. The eight companies that took part
in this initiative are Sony, Oracle, Google, Symantec,
A literature review on the use of genetic algorithms (GAs) Adobe, IBM, Apple, and Microsoft. We have made use of
to optimize investment strategies shows that there is a two datasets here for the purpose of this training and testing
growing corpus of studies investigating the efficacy of our model. The First dataset is used in order to calculate the
these algorithms in the complex and dynamic domain of connection weights for each characteristic that is utilized.
financial markets. Researchers have looked into a number We employed a dataset for the purpose of training to
of areas, such as risk management, adaptive decision- validate the result. We can therefore ascertain whether
making, and portfolio optimization. In the 1980s, Goldberg overfitting is taking place. The data actually showed that
and Holland's work established the groundwork for the use there was no overfitting.
of GAs in optimization issues. A multi-objective genetic
algorithm was presented by Chun-Hao[5] for portfolio
optimization that takes risk and return into account. Their B. Design of Genetic Algorithms
method proved to be effective in producing a variety of To achieve our goal of producing a profitable investment,
Pareto-optimal solutions. A multi-objective genetic we have decided to use genetic algorithms. As the depiction
algorithm was presented by Deb and Agrawal (1999) for of our problem statement makes use of floating or decimal
portfolio optimization that takes risk and return into point, therefore the connection weights for attributes are
account. Their method proved to be effective in producing also represented in the same manner. The fit utilized here
is the total amount of times the connection weights yield a IV. IMPLEMENTATION
valid stock price prediction. If it could predict the stock
price across 600 data points, then its fitness can be said to
be 600. There are 620 data entries that need to be predicted A. Function create_population
for each dataset. First, we make use of our training dataset Create and save stock prediction data in .xlsx format.
to get the accurate connection weight for every attribute,
and then we try to do prediction on the dataset that we have
separated for testing.

C. Parameter Tuning
The population size, crossover probability, mutation
probability, selection criterion, and termination point are Figure 2: Function create_data
the parameters that we take into account.
B. Function create_population
The various parameter combinations for all algorithms
Start a population with four genes in it. The functions
are listed as follows:-
create_data, create_genes, and calculate_fitness are all
contained in this function. The user determines the size of
The Genetic Algorithms are configured as follows:-
the population.
TABLE 1) PARAMETERS VALUES FOR GENETIC
ALGORITHMS

No. Parameters Values


1 Size of Population 100
2 Probability of Crossover 0.5
3 Probability of Mutation 0.013
4 Selection Roulette Wheel
5 Termination 1000 Generations

The Evolutionary Algorithms are configured as follows:-

TABLE 2) PARAMETER VALUES FOR EVOLUTIONARY Figure 3: Function create_population


ALOGRITHMS

No. Parameters Values


1 Size of Population 100 C. Create genes_function
2 Probability of Using random numbers within the interval [-100,100], form
0.5
Crossover
the gene values. The regression coefficient is the random
3 Probability of
0.013 value result. Regression coefficients are formed with the
Mutation
4 Roulette Wheel only for the intention of producing reliable prediction outcomes.
Selection
initial population
5 Termination 1000 Generations

D. Model Evaluation
Using historical data, we will conduct extensive
simulations to evaluate the success of established
investment strategies. We are also evaluating the
algorithms in a variety of market circumstances and
benchmarking them against traditional investment
techniques. Figure 4: Create_genes function

E. Optimization and Evaluation


D. Create fitness_function
Establish mechanisms for continuous learning and strategy
adaption in investing. It is applied in situations where we Using a regression algorithm to create stock price
lack comprehensive knowledge about the input we are projections and account for errors, fitness values are
attempting to forecast. Every input will be divided into two determined.
main classes by this function. Thus, it can be applied to
issues involving binary classification.
1
𝑃(𝑡) = (1+𝑒 −1 ) (1)
Figure 8: Regeneration function

H. Decimal numbers
Figure 5: Calculate fitness function
Generating chromosomes as binary in 2’s complements
E. Crossover Function
Create new populations or people (offspring of the original
population) that share the same genes but are distinct from
the original population. The user's value crossover rate (cr)
determines how many people are generated.

Figure 9: Decimal number

I. Main program
Implementation of all functions

Figure 6: Crossover function

Figure 10: Main program


F. Selection function
Paying attention to fitness values will ensure that the best
population consistently passes.
V. RESULTS
In order to prevent the model from over-fitting, the
connection weights are computed using the training data
and tested on the testing data. It is evident from the data in
Tables 3 and 4 that over-fitting is not happening. The
fitness also shows how many times it was accurate in
predicting the stock price. There are six hundred and twenty
entries in every set. The ideal connection weights for each
algorithm's stock price prediction are displayed in Tables 1
and 2. The best fitness values assessed for each
organization are displayed in Table 3.
Table 4 demonstrates our high degree of
Figure 7: Selection function prediction accuracy for stock prices. The connection weight
can range from one to a million or even more than that,
G. Regeneration function which explains this. As our space search is limited, we have
Utilizing the selection results to create a new population. set the upper limitation for floating representation only at
1000.
Table 4 shows that there is no overfitting in the link weight
evaluation for any attribute. Testing data can actually make
predictions that are more accurate than training data in
certain situations. The best accuracy rates obtained by the
genetic algorithm and evolutionary approaches are 71.77%
and 73.87%, respectively.
Table 1: Using genetic Algorithms to get connection weights for all companies [15]

Company Open Price Closing Price Highest Price Lowest Price Volume Adjusted Closing
Name Price
Adobe 995 10 27 83 929 38
Apple 98 12 85 18 30 17
Google 89 12 18 15 87 21
IBM 87 5 39 44 71 23
Microsoft 121 135 223 138 218 148
Oracle 963 1 24 18 989 28
Sony 963 7 54 37 975 38
Symantee 976 8 23 18 55 2

Table 2: Using evolutionary strategies to get connection wrights for all the companies [15]

Company Name Open Price Closing Price Highest Price Lowest Price Volume Adjusted Closing Price
Adobe 804 36 767 18 601 727
Apple 309 20 116 8 158 111
Google 890 15 27 46 43 830
IBM 247 23 35 8 907 72
Microsoft 285 5 70 42 24 183
Oracle 842 1 769 7 103 281
Sony 856 9 861 44 854 42
Symantee 778 13 161 302 938 23
Table 3: The best fitness calculated for all the companies. [15]

Company Name Fitness Value calculated from Genetic Algorithms Fitness Value calculated from Evolutionary Strategies

Training Data Testing Data Training Data Testing Data


Adobe 446 455 451 433
Apple 458 438 461 446
Google 464 428 463 434
IBM 439 438 453 441
Microsoft 466 435 471 439
Oracle 448 450 435 445
Sony 411 432 420 440
Symantee 441 457 430 440

Table 4: Accuracy with which price of stocks was predicted for all the companies [15]

Company Name Fitness Value calculated from Genetic Algorithms Fitness Value calculated from Evolutionary Strategies

Training Data Testing Data Training Data Testing Data


Adobe 446 455 451 433
Apple 458 438 461 446
Google 464 428 463 434
IBM 439 438 453 441
Microsoft 466 435 471 439
Oracle 448 450 435 445
Sony 411 432 420 440
Symantee 441 457 430 440

VI. CONCLUSION AND FUTURE SCOPE


It appears that the new approach of utilizing evolutionary achieved with evolutionary techniques was 71.77%, while
techniques and genetic algorithms to anticipate stock with the genetic algorithm it was 73.87%. In five instances,
values will be successful. It was discovered that the the genetic algorithm outperformed the evolutionary
performance of the evolution and genetic algorithm techniques in terms of prediction accuracy. In every
approaches was nearly equal. The highest accuracy instance, the evolutionary method achieved an accuracy of
at least 70%. [6] Chen, Chun-Hao, and Ching-Yu Hsieh. “Actionable
Stock Portfolio Mining by Using Genetic Algorithms.”
To anticipate the stock prices, we employed two distinct Journal of Information Science & lEngineering 32.6
datasets. One serves the purpose of training the data, while (2016).
the second one is used for testing. This separation is
necessary in order to test whether or not over-fitting is [7] Sharma, D.K., Hota, H.S., Brown, K. et al. Integration
taking place. The findings indicate that there hasn't been of genetic algorithm with artificial neural network for
any overfitting. stock market forecasting. Int J Syst Assur Eng Manag
13 (Suppl 2), 828–841 (2022).
https://doi.org/10.1007/s13198-021-01209-5
A. Future Scope
[8] Zhang, Xin-Li, and Ke-Cun Zhang. “Using genetic
We can think about a lot of things in the future. To forecast algorithm to solve a new multi-period stochastic
stock prices, we must incorporate more characteristics. optimization model.” Journal of computational and
Given how similar the six used features are to one another, applied mathematics 231.1 (2009): 114-123.
we require more attributes that don't alter costs but are
distinct from one another. [9] Hou, Yuanfeng, Integrating Market Risk and Credit
For categorization, we can experiment with various Risk: A Dynamic Asset Allocation Perspective
activation functions. We can therefore use a different (November 2002). Available at SSRN:
function in place of the sigmoid function. https://ssrn.com/abstract=302648 or
http://dx.doi.org/10.2139/ssrn.302648.
This approach can be contrasted with other well-known [10] Dubinskas, Petras, and Laima Urbšienė. “Investment
stock price prediction algorithms, like support vector portfolio optimization by applying a genetic algorithm-
machines and neural networks. based approach.” Ekonomika 96 (2017): 66-78.

[11] Huang, JY., Tung, CL. & Lin, WZ. Using Social
REFERENCES Network Sentiment Analysis and Genetic Algorithm to
Improve the Stock Prediction Accuracy of the Deep
[1] Huang, Chien-Feng. “A hybrid stock selection model Learning-Based Approach. Int J Comput Intell Syst 16,
using genetic algorithms and support vector 93 (2023). https://doi.org/10.1007/s44196-023-00276-
regression.” Applied Soft Computing 12.2 (2012): 807- 9.
818.
[12] Kakkar, L., Gupta, D., Saxena, S., & Tanwar, S. (2019).
[2] Nyman, Lauri. “A Genetic Algorithm for Generating An analysis of integration of internet of things and
Optimal Stock Investment Strategies.” (2017) cloud computing. Journal of Computational and
Theoretical Nanoscience, 16(10), 4345-4349.
[3] Abraham, R.; Samad, M.E.; Bakhach, A.M.; El-
Chaarani, H.; Sardouk, A.; Nemar, S.E.; Jaber, D. [13] Gundaboina, L., Badotra, S., & Tanwar, S. (2022,
Forecasting a Stock Trend Using Genetic Algorithm March). Reducing resource and energy consumption in
and Random Forest. J. Risk Financial Manag. 2022, 15, cryptocurrency mining by using both proof-of-stake
188. https://doi.org/10.3390/jrfm15050188 algorithm and renewable energy. In 2022 International
Mobile and Embedded Technology Conference
[4] de Almeida, Bernardo Jubert, Rui Ferreira Neves, and (MECON) (pp. 605-610). IEEE.
Nuno Horta. “Combining Support Vector Machine with
Genetic Algorithms to optimize investments in Forex [14] Sable, S., Porwal, A., & Singh, U. (2017, April). Stock
markets with high leverage.” Applied Soft Computing price prediction using genetic algorithms and evolution
64 (2018): 596-613. strategies. In 2017 International conference of
Electronics, Communication and Aerospace
[5] Li, Q., Kamaruddin, N., Yuhaniz, S.S. et al. Forecasting Technology (ICECA) (Vol. 2, pp. 549-553). IEEE.
stock prices changes using long-short term memory
neural network with symbolic genetic programming. [15] Katoch, S., Chauhan, S.S. & Kumar, V. A review on
Sci Rep 14, 422 (2024). genetic algorithm: past, present, and future. Multimed
https://doi.org/10.1038/s41598-023-50783-0 Tools Appl 80, 8091–8126 (2021).
https://doi.org/10.1007/s11042-020-10139-6

You might also like