Optimizing Portfolio Construction Using Artificial Intelligence

Chan Kok Thim, Yap Voon Choong, Eric Seah @ Seah Hock Han

International Journal of Advancements in Computing Technology, Volume 3, Number 3, April 2011

Optimizing Portfolio Construction Using Artificial Intelligence

*1

Chan Kok Thim,

2

Yap Voon Choong,

3

Eric Seah @ Seah Hock Han

*1, Corresponding Author

Multimedia University, ktchan@mmu.edu.my

2

Multimedia University, vcyap@mmu.edu.my

3

Sime Darby Berhad, eric.seah@simedarby.com

doi:10.4156/ijact.vol3. issue3.16

Abstract

This research paper aims to enhance the practicability of Artificial Intelligence using Neural

Network (NN) in the actual market. This paper generalizes the standard Markowitz Theory’s Efficient

Frontier to mimic and optimise the portfolio construction, and develops a neural network heuristic to

better understand the mechanism of how Artificial Intelligence can construct optimal portfolio and

provide advantages to all levels of investors.

Keywords:

ANN, Finance, Portfolio

1. Introduction

Artificial Intelligence works like the part of our brain with agents to communicate with each other

and work their performances to the optimal level or at least increases the chances of success. Artificial

Neural Network [1] seeks to optimize and simulate human brains that go beyond what the normal

human can do. No doubt, the ultimate goal is to ease the human’s burden with greater effect. Artificial

Neural Network (ANN) is one of the fields from Artificial Intelligence which is actually a machine or

program that can mimic the actions of humans [2]. ANN is basically intended to mimic the mechanism

of the human brain [3]. As complex as our human neural system, which includes our brain cells, spinal

cords, the nerves system and etc. The replica of human system has artificial neurons and is the reactor,

processor and communicator of the information through connectionist that formulated into a very

complex system.

It is hoped that this study will provide higher level of understanding not just in Modern Portfolio

Theory by Harry Markowitz [4], but more in-depth knowledge in the field of Artificial Neural Network.

The objective is to examine the critical success factors of Artificial Neural Network in the field of

finance, specifically in Portfolio Management, Construction and Optimization. In addition, this paper

seeks to research the practicability of Artificial Intelligence and Neural Network in the Malaysian

capital market.

The application is to improve and open up human’s perception in portfolio investment. This is to

show that portfolio investment can produce optimum results and at the same time, with Artificial

Neural Network, we can see how the power of computing can generate complex formulas and

programming codes beyond the capability of the human’s mind.

2. Literature review

Artificial Neural Network as mentioned is one of the body of Artificial Intelligence that duplicates

the hu man brains and seek to optimize what normal humans can do. In this section, we will touch on

the details of the structure within a neural network. This will provide an opportunity to the human to

understand more about our own brain and the machine that is design to work for us. It is pertinent to

capture the future behavioural patterns as to identify the creditworthy cardholders who are profitable

with low risk [5] similar to our portfolio of stocks.

One of the basics of Artificial Neural Network [6] will be divided into three main parts as illustrated

in Figure 1 below which shows the normal structure of how Artificial Neural Network can replicate the

biological neural network.

- 168 -

Figure 1. Basic Structure of Artificial Neural Network

Source: Wikipedia/Artificial Neural Network (2010)

In our model of Neural Network, the Input Layers will usually be the layer where inputs are feed on

the Hidden Layers. In other words, raw information is feed to the hidden layers to perform their task,

and in fact, hidden layers can be far complicated that we can see now. The hidden layer is like our

brain, when we speak or communicate with someone, a signal will be sent to your brain. The hidden

layer will process before deciding the appropriate action to be taken. As in the hidden layer, this can be

represented by cell body that will capture the neurons and process according to what we think. Usually

the output layers, as always, is something that we see as a result, but it is important to note that it is as

complex and complicated as a human mind, as similar to Artificial Neural Network as well.

Figure 2. Image of Biological Neural Network

ANN and genetic algorithms that derived from the corresponding simulation of biology can be used

for prediction [7]. In Figure 2, you can see the image from the operation and inputs, hidden and output

layers are interconnected. And that is how ANN [1] can be grown exponentially with research inputs

which will turn into outputs for further action.

2.1. Artificial Neural Network in Portfolio Management

Portfolio is a set of multiple assets that are combined by investors with the target to diversify.

Diversification will minimize the risk and maximizing returns of the investor when investing in a

portfolio. The assumption of putting more stocks without having to study the significance of each stock

and their relationship among each other will cause fatal results on the expected return. Many will move

on with carefully selected stocks with more implications on Markowitz’s work [8], which will not

follow the Gaussian Distribution and thus, ignoring the theory of efficient markets. As ANN works as

an essential tool on optimization, one of the key benefits apart from their learning behaviour will be the

programming or their hidden layer that can be programmed to optimise results. In addition, many

studies had also resulted that information can be tapped with various environment, much more than a

human can remember in-line during the decision making. In fact, the simulation engine inside an ANN

can work numerous investing strategies, from the collection of how the greats had done, like Warren

Buffett, George Soros, Alan Greenspan and etc., and with that, optimizing their strategies, putting

together a competitive system that will result at a situation the survivor of them all [9]. But computing

- 169 -

a machine to have followed how investor’s behaviour react is something very subjective and take a

long time and effort, still, the effort to replicate their winning strategies is possible using Neural

Network.

In addition to portfolio optimizing to get the best return, which in the statement cleared the

assumption of MPT. The reason is because a clear point of optimizing in the language programmed

will be to set priority on earnings seconded by risk. This states another benefit of using NN as we can

select our own optimal level whether in profit sense or minimizing risk of our portfolio. The variability

of neural network applications also sets another challenge that is to be able to self-correct from

previous mistakes. As we all know that humans will tend to neglect the losing side of us, and will still

give it a try, while NN will have objective-oriented stricken concept. The principle is ANN has

stronger foundation with learning skills and improvement is self-learned. We are able to monitor their

performances from time to time. And this gave an idea to Zimmermann, Neunier and Grothmann [10]

to use Black/Litterman approach [11] for a feed-forward neural network to work on a Error Correction

Neural Network (ECNN) that characterise the mistakes made previously and enhanced it by utilizing

the mistakes done. That feed-forward NN refers to one of the neural networks that work on a single

connection line, but unlike recurrent neural network, the communication process only goes one way.

With more creations on enhancing the portfolio theory, this includes making the theory profitable,

and by means of profitable is not experimenting in the lab but put it in the actual market. The beauty

Markowitz’s Portfolio Theory [8] is that, by using just mean and variance as a parameter, the theory

can work perfectly well and show remarkable output. On the positive side, researchers focus on these

two parameters and inclusive of the model’s skewness to work on the construction of a portfolio which

will match the preferences of investors based on their forecast alongside with the trading strategies in it

[12]. With that, this construction takes the mean-variance-skewness of the model relationship as part of

the main objectives to resolve many unclear works and provide a higher level of return [13]. Although

many of the models were made to prove a theory, there are others who work well in the real capital

market and have been part of the usage of the program or software to be adapted in the software. But

the slack problem of the software is that, it can be profitable for the creator, but costly to the buyers, as

many patches needed to be done to make sure the algorithm did not grow exponentially and making

sure that the neural network should learn the right thing. This is simply because, in a human mind,

what we were induced as a bad thing, we will try to erase and do not follow it, but doesn’t apply the

same for a machine. We may wonder, that the algorithm should have a level to deter bad judgement,

but simply, the machine evolves with us thus even there is a bad signal; it will be as new to us just as to

them.

On the other hand, it will be on the selection process of a portfolio. The selection of a portfolio may

seem easy as mentioned, but is one of the most tedious processes in reality. It is not like selecting fruits,

differentiating the bad from the good ones and to have known which the best asset is. The process of

selecting good assets for your portfolio, can be pronounced as a vague or ambiguous statement,

because what do you mean by ‘good’? Thus, in this operation of selecting the most preferred portfolio

that gives you the best return with minimal risk is through heuristic process. Heuristics means

pertaining to a trial-and-error method of problem solving used when an algorithmic approach is

impractical.

This might keep many wonder, how are we going to trial and error our portfolio, and how much

money can we invest in? Therefore, this places Neural Network as part of the process to simulate the

real market and to be the best on portfolio selection. One of the methods that were proposed in [14]

will be to use Hopfield Neural Network [15] and to study the groundwork. Having Hopfield Nets is

that it is capable of working on different classes of combinatorial optimization problem. This will set

apart how the optimization and selection process are given the ground rules, and most importantly, the

bounding and cardinality constraints can be rid off as studied by Chang [16] and Kellerer [17].

3. Data and Methodology

The data samples are taken from the FTSE Bursa Malaysia EMAS Index. The reason of adapting

this sample is that FTSE Bursa Malaysia EMAS Index is constructed based on Malaysia’s Top 30

Companies, Mid 70 Companies and 225 small capitalization companies. In other words, this 325

companies, but 324 to be exact (as one of the company namely Quill Capita, is not removed but is

having his shares halted) to represent the rest of the listed companies in Malaysia. In fact, with more

- 170 -

instruments that are listed out such as Islamic Bonds and Malaysian Government Securities (MGS), our

focus still remains on the equities.

The next section will discuss the relevant procedures to handle the sample that is using Microsoft

Excel, C++ and SmartFolio for computation and data analysis. The Microsoft Excel special tool

designed by Hanyang Financial Engineering Lab (Thomas Ho Company, 2003) is to create the

Efficient Frontier practised by Markowitz Modern Portfolio Theory. The C++ is used for the purpose

of randomly selecting companies as part of the learning process for Layer 1. The main reason of using

C++ is, it is much faster and will have no problem even having Matrix Multiplication of more than 20

variables (Excel can only do 40 variables per time). In addition, C++ coding is easily embeddable in

many other programs, like Matlab and Fedora for further research on Layer 2 and 3 in the future.

3.1. Sampling Procedures

Layer 1: Prototype (for the purpose of this research only)

1. Collection of data from Yahoo! Finance and to eliminate any outliers that existed

2. With the data that accounted 325 companies data will be used to compute the Efficient Frontier

using Microsoft Excel.

3. Next, to run a series of testing, as definitely we won’t be investing in 325 companies in our

portfolio thus we set a range using C++ to have random selection of stocks

4. C++ will random select the stocks and to our preference, as for the analysis in this model, there is

a range of 2 to 29 assets will be selected.

5. The random generation of stocks with the data will be pasted into the efficient frontier columns

and it will result in the graphs being created.

6. Graph is compared with the Efficient Frontier that has 325 Assets in Portfolio and Top 20 to

compare their performance. 325 of the assets.

7. A series of 50 run is being carried out for the purpose of getting the best model and to see the

effects.

8. Differencing the mean return and compare with the benchmark mean return.

Assumptions undertaken for the purpose of this paper:

Analysis is done on random generation program to select 20 stocks.

The number of trading days is 252

The weight on Risky Portfolio is fixed 0.7 or 70%, while Risk-Free Asset is fixed at 0.3 or 30% of

the actual portfolio

The series is run through a range of -0.5 to 2.0 set of Weight Proportion that may exist, with that,

the curve of Efficient Frontier can be seen. As mentioned above this is the q for the optimization

purpose, or ‘risk tolerant’ factor.

The risk free rate is adapted from Bursa Malaysia’s Malaysian Government Securities (MGS) as of

1

st

of April 2010, with the risk free rate of 2.57% or 0.0257

Microsoft Excel Efficient Frontier Construction

1. From the random generation of output that was produced by the C++ program made by the author

under the file out.txt, simply copy the whole file and paste it on a new worksheet.

2. From the pasting, you can see from the graphs area that will be resulted from the calculation that

we will describe further.

3. For investors analysis, the diagrams and the rest of the computation is done. But as for developers,

the calculation process will be described here. Upon getting the input for the time series of data,

the first calculation is to compute the returns.

4. Calculate the mean (average) of all the returns that Step 3 has calculated.

5. Daily mean and annual mean will be computed by multiplying the results from Step 4 with 252

(number of trading days per year)

6. Calculate the excess return by taking the stock returns you got from Step 2 minus by the mean.

7. Transpose the excess return matrix.

- 171 -

8. Matrix Multiply for the excess return matrix from step 6 with step 7 transposition of the excess

return matrix to get the variance covariance matrix

9. Calculate the Annualized VCM with multiplying 252 again.

10. Calculate the Risk-Free Return by taking the Expected Return from Annual Expected Return

minus by Risk Free Rate (2.57% for our study)

11. Derive the variable z of the matrix, from the Risk Free Return and Expected Return, Matrix

Multiply with the Variance Covariance Matrix.

12. Sum the whole z, and compute M by dividing the each value of z with the sum.

13. Compute E(Rm) by Matrix Multiplying M with the Expected Return

14. Compute the Variance as well by a series of double Matrix Multiplication, first to Matrix Multiply

with transpose of M with the Annualized VCM. Second Matrix Multiply the output with the

Annualized VCM again.

15. Square the root the variance to get the standard deviation of risk free return (denoted as m)

16. Repeat steps 13-15 for risky assets computation.

17. Insert the weight of how much investment for risky assets and risk-free assets. This study we put

risky assets with 70% while risk free assets with 30%

18. Calculate the expected return of portfolio by taking the weight of risky assets multiply the

expected return of risky assets (same for risk free assets as well)

19. Calculate the rest of the formulation with covariance, variance and standard deviation of the

portfolio with the function.

20. The efficient frontier will be computed, as the variation of the weight from the list of -0.5 to 2 will

produce multiple points of risk and return. And from there, you are able to see the graphs.

Using SmartFolio Analysis Tool

1. Using SmartFolio, the bonus package will show the platforms of how the model will work out the

analysis applying the neural network tool.

2. In the first page, click on the start new SmartBook

3. From the front page, click Data -> Import Data from Excel (data are randomly generated from the

program that I used)

4. You will be prompted with this window and press OK

5. From the front page, you will see the list of your data with date presented nicely. Go to

Initialization at the menu bar and click Portfolio Construction

6. Press on Edit List and you see the set of assets that was randomly generated and pasted on the list.

And what you do is simply ‘Select all’ and press OK.

7. From the data that was given, the portfolio construction is generated, and optimized according to

their level. As it differs from the previous one whereby our weight for Risky Assets is 70% and

30% on Risk Free Assets, this program will provide equal weightage to all the stocks (difference

between my tool and theirs)

8. From the front page, click on Analysis -> Efficient Frontier Construction, you will have a window

and a constraint button as below

9. Choose Prohibit Short Selling (as Malaysia we couldn’t do that) and Zero weight in Riskless Asset

and press OK

10. The efficient frontier will be presented graphically.

11. From there, click on the Menu Bar on Portfolio Summary and the results of analysis can be found

here and the weight of allocation of stocks.

4. Analysis and Discussions

The random generation program has used 20 companies as the default for this study. The benchmark

for the Top 20 Companies based on Market Capitalization chart from KLStock.com dated as of 1st of

April 2010 [18]. As seen from the analysis, we are going to compare the mean differentiation (as our

target is to have the highest return) of each dummy generation (which has 50 runs) and the margins

towards the benchmark. As such, we are having two benchmarks; the Top 20 Stocks and 325 Stocks in

KLSE.

As for the analysis that we have run through, includes the index and the performances in the

efficient frontier, as seen in the Top 20 efficient frontier of Figure 3. Below are some of the examples

- 172 -

of the analysis that were done and to compare how the companies performed graphically, refer to

Figures 3 to 5. With the below figures, the results generated by the model are compared with the

benchmark. The reason of putting two benchmarks is that, there are many varieties of investors who

may have different preferences for risks and returns.

Figure 3. Top 20 Efficient Frontier

Figure 4. Analysis 1 Efficient Frontier

Figure 5. Analysis 22 Efficient Frontiers

Having Top 20, Top 30, Mid 70 and best of 325 will provide good benchmarks to suit the

preferences of different portfolio managers. We can see that the benchmark is the best as of 1st April

2010, and there are no other portfolios selections that will supersede their performances. Thus, the

input layer of the model must be constantly fed with a large stream of inputs for better results.

We have used two methods for our analysis. First method is based on the graph that is to see the

graph and compare. It can entail the fastest and easiest because it is based on what we see as a picture

definitely paints a thousand words. The next analysis is to calculate to see the variations that exist

between the proposed analyses, individually and also, the mean of the benchmark. We used the mean

as an assessment on the return of the selected benchmark portfolio rather than risk. Thus, equipping

returns as the mean return is our main target for this study; the analysis will provide us the required

outputs.

In this model, the Neural Network layer will compute the variation and for risk as well to compare

the selected benchmark and the set of analysis. From this computation, the output will be randomly

generated by the Artificial Intelligence program. But all of this is in Layer 1 of the model which does

not entail much, as this output of Layer 1 will be fed into the other hidden layer to be computed further,

especially on the learning site.

- 173 -

In Figure 3, an average out of 50 Analysis made the mean return of all the analysis higher than the

mean return of the Top 20 stocks. The Top 20 stocks have a mean of 7.3083 as calculated, while the

mean return of the 50 Analysis is 9.2924. This implies that Random Generators’ portfolio stands a

chance to perform better than the Top 20 stocks in Malaysia. Apart from that, the variation is only

1.9842 and most of the randomly generate stocks will not run much of their return figures from the

mean. The variation is computed by taking each portfolio mean return minus the mean return of the

benchmark portfolio. Thus, using Artificial Intelligence that is able to provide random generation of a

benchmark indexes will produce better result that has over-performed the Top 20 Stocks in Malaysia

(based on Market Capitalization). This proves that in a portfolio, stocks with negative correlations tend

to perform better as observed in the analysis.

From the variation that 36 out of 50 analysis performed below the Top 20 stocks. This indicates

72% of the stocks that is randomly generated will tend to under-performed than the Top 20 stocks in

Malaysia. However, on the other hand, there are two analyses that performed extremely better than

Malaysian Top 20 that reached up to 220 points and 70 points better than the portfolio construction. As

from this random analysis that did not have any learning system, we hope to capture this idea in the

learning system for future analysis.

On the other hand, using an analysis tool the SmartFolio, that is readily applicable in the market to

further show the good extent of neural network and Artificial Intelligence capability, a run of 20

analyses was executed to get the results to compare the Top 10. From the SmartFolio, the mean return

for Top 10 stocks in Malaysia is 13.40% while the mean return of 20 non-bias random generated 10-

stocks portfolio is able to generate 28.43% mean return. A nearly double performance as compare to

the benchmark portfolio and only 16.43% variation of the each portfolio compare to the benchmark. As

this tool is mainly for assistance purpose, the number of stocks that underperformed the Top 10

Malaysian stocks is only 2 over 20. This means only 10% of the portfolio generally performed worst

than the Top 10 stocks.

One crucial limitation is that the SmartFolio would not be able to perform on the random generators

that the study did with certain algorithm designed by the authors. Another instance is the SmartFolio

(trial version) can perform only 16 stocks per portfolio. Perhaps, using multiconnect architecture

(MCA) with some modifications will increase the optimal performance thus, avoiding the Hopefield

neural network limitations [19].

5. Conclusion

The optimizing portfolio construction using artificial intelligence is an optimization process

embedding theories not just Modern Portfolio Theory but engineering and IT theories like Boltzmann

and Hopfield into the actual environment. This learning process adopted the theories and thus, making

the system flexible is another added advantage to the heuristic effects and a great leap forward.

Theories are made for us to know how things will happen and in fact, many theories on the surface

prove many points, but in real practice, are not able to perform to the optimum. With that, we added the

Random Generators program as part of the Layer 1 activity to demonstrate that Artificial Intelligence

can do a better job in selecting or constructing a portfolio. Thus, it is also important for us to

understand that Portfolio Construction is still subjected to human (behaviour) judgement, but the key

point is the system acts as a catalyst in making human’s decision faster, wiser and clever. Adapting this

ideal model, we can further optimize portfolio construction using heuristic process to learn together

with supersonic speed and better decision outcomes.

6. References

[1] Artificial Intelligence. In Wikipedia. Retrieved 11

th

January, 2010, from

http://en.wikipedia.org/wiki/Artificial_intelligence

[2] Artificial Neural Network. In Wikipedia. Retrieved 11

th

January, 2010, from

http://en.wikipedia.org/wiki/Artificial_neural_network

[3] D. Shanti, G., Sahoo, N., Saravanan, “Comparison of Neural Network Training Algorithms for

the prediction of patient’s post-operative recovery area”, Journal of Convergence Information

Technology, Vol. 4, No.1, pp 2432, 2009.

- 174 -

[4] H. Markowitz, “Portfolio selection.”, Journal of Finance, Vol. 7, pp. 77-91, 1952.

[5] I-Fei, Chen, “A Two-Stage Cardholder Behavioural Scoring Model Using Artificial Neural

Networks and Data Envelopment Analysis”, International Journal of Advancements in

Computing Technology, Vol. 3, No. 2, pp. 87-94, 2011.

[6] What is Neural Network? Retrieved on 22

nd

February 2010 from Webopedia website,

http://www.webopedia.com/TERM/n/neural_network.htm

[7] Cui Jian-ming, “Traffic Orediction Based on Improved Neural Network”, Journal of

Convergence Information Technology, Vo. 5, No. 9, pp. 85-89, 2010.

[8] H. Markowitz, “Mean-Variance Analysis in Portfolio Choice and Capital Markets”, Blackwell

Publishers, USA, 1987.

[9] D. Plikynas, “Portfolio Design and Optimization using Neural Network based Multi-Agent

System of Investing Agents”, In Proceeding of International Conference 20

th

EURO Mini

Conference, pp. 137-142, 2008.

[10] H.G. Zimmermann, R. Neuneier, R. Grothmann, “Active Portfolio-Management based on Error

Correction Neural Networks”, Siemens AG (Germany), 2002.

[11] F. Black, R. Litterman, R. “Global Portfolio Optimization", Financial Analysts Journal, pp. 28-

43, September 1992

[12] L. Yu, S.Y. Wang, K.K. Lai, “Neural network-based mean–variance–skewness model for

portfolio selection, Computers & Operations Research”, Vol. 35, Issue. 1, pp. 34-46, 2006.

[13] T. Lai, “Portfolio selection with skewness: a multiple-objective approach”, Review of

Quantitative Finance and Accounting, pp. 293-305, 1991.

[14] A. Fernández, S. Gómez, “Portfolio selection using neural networks”, Departament

d’Enginyeria Informàtica i Matemàtiques, Universitat Rovira i Virgili (Spain), 2005.

[15] J. Hopfield, “Neural networks and physical systems with emergent collective computational

abilities”, In Proceeding of the National Academy of Science, Vol. 79, pp. 2554-2558, April

1982.

[16] T.J. Chang, N. Meade, J. Beasley, Y. Sharaiha, “Heuristics for cardinality constrained portfolio

optimisation, Computers & Operations Research”, Vol. 27, pp. 1271-1302, 2000.

[17] H. Kellerer, D. Maringer, “Optimization of Cardinality Constrained Portfolios with a Hybrid

Local Search Algortihm”, In Proceeding of 4th Methaheuristics International Conference (Porto),

pp. 585-589, 2001.

[18] Bursa Malaysia Stock Guide (April 2010), Retrieved from KL Stock website,

http://www.klstock.com/top30-bursa-companies.php

[19] Emad I Abdul Kareem, Aman Jantan, “MCA: A Developed Associative Memory Using Multi-

Connect Architecture”, International Journal of Intelligent Information Processing, Vol. 2, No. 1,

pp. 49-62, 2011.

- 175 -

## Σχόλια 0

Συνδεθείτε για να κοινοποιήσετε σχόλιο