Portfolio Selection and Management Using Power BI
Portfolio Selection and Management Using Power BI
Portfolio Selection and Management Using Power BI
Acknowledgements...............................................................................................................................3
ABSTRACT..............................................................................................................................................4
Chapter 1: Introduction.........................................................................................................................5
1.1 Previous Research..................................................................................................................5
1.2 Limitations in Existing research..............................................................................................6
1.3 Aims and Objectives of the thesis..........................................................................................6
Chapter 2: Literature Review.................................................................................................................7
2.1 ROLE OF PORTFOLIO MANAGAMENT SYSTEMS.....................................................................7
2.2 VARIOUS APPROACHES FOR STOCK PRICE PORTFOLIO SELECTION AND MANAGEMENT......8
2.2.1 Fundamental Analysis....................................................................................................8
2.2.2 Technical Analysis..........................................................................................................9
2.3 ROLE OF BUSINESS ANALYTICS IN DATA MANAGEMENT.......................................................9
2.4 PORTFOLIO DECISION ANALYSIS..........................................................................................10
2.5 TIME SERIES FORECAST AND MODELLING...........................................................................10
2.5.1 Stock prices as time-series data...................................................................................11
Chapter 3: Data Collection...................................................................................................................11
Chapter 4: Research Methodology......................................................................................................12
4.1 PROPOSED SYSTEM..............................................................................................................12
4.2 TECHNICAL SPECIFICATIONS................................................................................................13
4.3 METHODOLOGY...................................................................................................................14
4.3.1 Setting up the environment.........................................................................................15
4.3.2 Importing data into Power BI Desktop.........................................................................16
4.3.3 Data Modelling and Writing DAX functions.................................................................19
4.3.4 Data Visualizations.......................................................................................................21
Chapter 5: Data Analysis......................................................................................................................21
Chapter 6: Results................................................................................................................................22
Chapter 7: Conclusion..........................................................................................................................23
Critical Reflection.................................................................................................................................24
APPENDICES.........................................................................................................................................25
REFERENCES........................................................................................................................................31
List of Figures
FIGURE 1 POWER BI ARCHITECTURE 10
FIGURE 2 STOCK PRICE DATA ON YAHOO FINANCE 12
FIGURE 3 GENERAL OVERVIEW OF THE PROPOSED RESEARCH METHODOLOGY (BANNER ID) 15
FIGURE 4 DATA IMPORT OPTIONS IN POWER BI DESKTOP 18
FIGURE 5 DATA IMPORTED IN POWER BI WITH DATA VALIDITY AND ERROR PERCENTAGE 18
FIGURE 6 CHANGING DATA TYPES TO REFLECT THE CORRECT TYPES OF DATA 18
FIGURE 7 CHANGED COLUMN NAMES AND REMOVED UNWANTED COLUMNS 18
FIGURE 8 RELATIONSHIP BETWEEN THE TABLES IN POWER BI DESKTOP 18
FIGURE 9 TOP COMPANIES BY EPS 19
FIGURE 10 TOP COMPANIES BY MARKET CAP 19
FIGURE 11 PORTFOLIO MANAGEMENT SYSTEM IN POWER BI 21
FIGURE 12 DATA IMPORTED IN POWER BI WITH DATA VALIDITY AND ERROR PERCENTAGE 21
FIGURE 13 TABLE 1 21
FIGURE 14 TABLE 2 21
FIGURE 15 TABLE TOP MARKET CAP 21
FIGURE 16 HIGHEST STOCK PRICE, %CHANGE AND P/E RATIO 21
FIGURE 17 TOP COMPANIES BY EPS 21
FIGURE 18 TOP COMPANIES BY MARKET CAP 21
FIGURE 19 TABLE CONTAINING STOCK INFORMATION 21
FIGURE 20 SLICER WITH STOCK PRICES 21
FIGURE 21 PORTFOLIO MANAGEMENT SYSTEM IN POWER BI 21
FIGURE 22 FILTERING RESULTS BASED ON SELECTION 21
Acknowledgements
This research has been a great learning experience to me, along with an opportunity to
demonstrate my skills and use the knowledge that I have gained from my course Course
name. It has helped me in gaining the hands on experience for the concepts that I have
studied theoretically during my course.
For this research opportunity and providing all the tools, resources, guidance and support to
me to complete this research, I would like to thank my college UNIVERSITY NAME.
Next, I would like to thank Costas full name for dedicating his time to help and guide me in
this research work. He guided me through his invaluable feedbacks and constant
suggestions on how to plan the research and complete it within the planned timeframe and
within the scope. I appreciate his willingness to take time from his schedule to provide
constructive feedbacks to me.
I would like to thank my supervisor Raja full name whose constant support, motivation,
knowledge on the subject matter and guidance helped and inspired me to complete this
research on time and within the acceptance standards of the University. His time and efforts
in providing me feedbacks on all the previous reports and drafts is much appreciated. It
would not have been possible to complete this report without his assistance.
ABSTRACT
Stock market investments have been a popular way of earning more profits but the
fluctuations in stock market make it difficult for the investors and portfolio managers to
manage their stock market investments. It is very difficult to create a portfolio in the first
place with real time data, let alone maintain one to show the updated prices and trends.
There are many different ways which have been proposed to create a portfolio management
system such as Machine learning algorithms, Azure Machine Learning services, etc. as well
as the traditional financial methodologies. Most of the tools that allow the portfolio tracking
and stock market analysis are either paid or have limitations of use. This research will focus
on analysing the patterns and perform future predictions for the trends and movements
identified in stock market and maintain a portfolio of all the invested stocks using traditional
financial methodologies and power BI. In this research, the stock price analysis and portfolio
management has been proposed using an interactive dashboard app in Microsoft Power BI
Desktop. Power BI is a relatively easy and more efficient tool to perform this research due to
its ability to forecast future trends using AI tools and large range of effective visualization
tools. Data collection process for the research included the collection of quantitative data
for the companies such as their financial statements for the last 5 years including profit loss
summary and the stock price summaries of the companies including the opening and closing
price of the stocks on a particular day. This data was cleaned and modelled in Power BI
using Data transformation, DAX operations and Data modelling algorithms. Effective
visualizations will be created using Power BI Artificial Intelligence modules and these
visualizations will be analysed to conclude the research and provide results for the research.
The resulted dashboard app will allow the users to manage their portfolio and also compare
the stock prices of various companies and make investment decisions accordingly. The
proposed system will be tested and modified to reflect higher accuracy.
Chapter 1: Introduction
For a long period of time, the creation, selection and management of Stock market Portfolio
Management system has remained the most interesting topic of research amongst the researchers
from the fields of computer science, Mathematics and finance all around the globe. There are a
number of existing research papers and thesis which focus on evaluating the situation of the stock
market and proposing different models for portfolio management and tracking systems using many
different technologies which include modern statistical technologies such as Machine leaning as well
as traditional financial technologies such as calculating the expected returns by using standard
deviation. The research model that gained the most popularity amongst all in this field was the one
Markowitz presented in his paper on Portfolio Selection in 1952. No other research paper has gained
this much success in this area since then. Any investment made in stock market can be assessed in
the terms of risks and returns and these returns can be maximized by working on minimizing the
given level of associated risk (Markowitz, 1952). However, many other factors and attributes need to
be assessed along with risk and returns simultaneously and these attributes can significantly affect
the decision to purchase a stock (Peykani et al., 2020). Financial summary of the companies, the rate
of investment (ROI), rate of returns, profit/loss summary, debts, rate of liquidity, etc. might be some
of these attributes amongst others.
In a paper on Investment Analysis and Portfolio management of top 10 stocks in India amid market
turmoid in COVID-19, Supriya Singh (Singh, 2018) also made use of risk and returns along with the
optimal weight of the stock to create an optimal portfolio. The effect of diversification while
performing the investment analysis was also explored in this paper.
In a research thesis by Wang and Ren (2018) on hedging theory of modern portfolio management,
linear regression and linear mean variance model is used to calculate the optimal hedge ratio in
portfolio management.
In a paper on Portfolio decision analysis: Recent developments and future prospects, Liesio, Salo &
Keisler (2020), the authors conducted a survey on 148 articles on Portfolio Decision Analysis and
found out that there is a significant improvement in the methods of solving complex problems and
the level of sophistication in case of methodology used has also increased in the last few decades.
In another paper on Optimization of multiple satisfaction levels in portfolio decision analysis, the
authors Barbati and Greco (2017) proposed an approach to help the decision maker in controlling
the choice of good evaluations that would lead to a better portfolio of projects. The research made
use of interactive multi-objective optimization and Dominance based rough set approach (DRSA) in
portfolio decision analysis. The results of the research showed higher number of projects that
attained the presented satisfaction levels.
Vijh, Chandola, Tikkiwal and Kumar (2020), in their paper on Stock Closing Price Prediction using
Machine Learning used Artificial Intelligence and Random forest techniques to predict the closing
stock price of five companies on the next day. The research demonstrated a comparative analysis
between Artificial Neural Networks (ANN) and Random Forest (RF) and concluded that ANN provides
better predictions when compared to RF.
Vaezi and Sadjadi (2019) also presented a thesis on A portfolio selection model based on the
knapsack problem under uncertainty. The thesis proposed a method to determine the number of
shares for each asset and used knapsack based portfolio selection algorithm to characterize
expected returns, prices and budgets. The proposed model proved to be maximizing the returns of
investment by associating the risks involved, budget cardinality and ceiling constraints amongst
other parameters.
Another article on Predicting stock prices using Machine Learning by Katherine Li (2022)
demonstrated the use of technical analysis and Simple MA and Exponential MA techniques to predict
stock prices and utilized Long Short Term Memory (LTSM) to build a predictive model and compare
its performance by technical analysis. The research worked on the stock price of the company Apple
and tried to predict its stock price using the proposed model.
These references show that there has been significant research in this field and also, significant
growth in the ways in which stock market predictions are done and portfolios are created and
managed. Many different approaches have been provided by the researchers to effectively predict
the stock prices and manage the stock portfolio including machine learning, artificial intelligence,
random forest, Knapsack, Long Short Term Memory (LSTM) and many more.
In the research by Liesio, Salo & Keisler (2020), possibilities such as Decision Analysis (DA), decision
aid, etc. were not explored. These options could add to the understanding of mathematical structure
of human decision as well as social science of the management of human organizations. In Barbati
and Greco’s thesis (2017), the focus was more on the point of view of the decision maker and
making their experience better instead of trying to achieve more suitable results on the
management of portfolio. Markowitz’s (1957) thesis lacked the inclusion of some important
attributes such as the financial summary containing the profit/loss details, sales and purchase
details, the debts and investments by the company, rate of return, etc. Whereas, Vijh’s (2020) deep
learning model for stock prediction could have provided better results if it considered the role of
financial news and articles also along with the other financial parameters such as the traded volume,
profit and loss statements of the company, the closing price of stocks, etc. Vaezi and Sadjadi’s thesis
(2019) did not take into consideration class constraint and chance constraints and the inclusion of
risk measurement factors such as variance and Value-at-Risk (VaR). Katherine’s article on Predicting
stock prices using machine learning did not incorporate sentiment analysis on news and social media
regarding the stock market and given stock of interest. Similarly, there are other research works as
well which lacked some of the important parameters for stock price analysis and portfolio selection
and management.
The classical machine learning algorithms such as Linear Regression, Random Walk Theory, Moving
Averages, Moving Convergence/divergence, etc. along with the linear models such as Autoregressive
Moving Averages, Autoregressive Integrated Moving Averages, etc. have been presented evaluated
and explored in the previous research works for the prediction of stock prices (Vijh et al., 2020).
These technologies and algorithms proposed in these research papers used for the calculation of the
predicted stock prices and for the selection and management of portfolio are very complex. Less
research has been done in the related field using Business Analytics and intelligence solutions such
as Power BI. Most of the papers and online articles explore the use of machine learning and
advanced statistical tools to calculate the predicted stock market price.
The analysis of the patterns and performing future predictions for trends and movements in the
stock market based on the current values will be the focus of this research thesis. This research will
also include the maintenance of portfolio of the invested stocks and other stocks in the market
which have the potential of providing profits using Microsoft Power BI Desktop and traditional
financial methodologies.
To perform literature review and study of previous research thesis, online articles and books
to identify the gaps in the related field and to understand how the Portfolio tracker can be
created and visualized using Power BI dashboards and reports.
To analyse the stock price movements and trends of different companies and identifying and
listing the top companies with top stock prices and building the stock portfolio management
tracker using Power BI dashboard app.
To write and build machine learning linear regression algorithms for predicting and
forecasting the future trends in stock prices using python programming language.
To analyse the visualizations created in Power BI dashboard and conclude results by
comparing the predicted results with the actual real time data from the original data source.
To help the users in decision making for stocks investment in companies through user-
friendly visualizations and help them manage their stock portfolio in an easy and effective
way
Chapter 2: Literature Review
In investment management, the two main fields of study are the selection of portfolio and the art of
optimizing it (Peykani et al., 2020). The investment and stocks market is very volatile and is very
difficult to predict and it is equally important to understand the trends for the investors. Accurate
stock price prediction is very challenging due to multiple factors such as political factors, global
economic conditions, unexpected events and a company’s financial performance and so on (Li,
2022). All the prediction aspects such as physical and psychological factors combine to make share
prices volatile and very difficult to predict with a high degree of accuracy (Singh, 2018). Let us first
try to understand what a stock market portfolio is and what different methodologies to create an
effective and profitable portfolio are there.
It is very important to build a portfolio management system which can properly distribute the shares
amongst various assets. To propose a conservative approach to create a portfolio, it is required to
re-evaluate the qualified stocks in another phase to assign the amount of investment in each stock
after filtering the undesirable stocks and detecting the most desirable ones (Peykani et al., 2020).
One other factor to consider is that the parameters are highly uncertain in nature. The nature of the
stock market is highly volatile and is considered as non-linear. Accurate stock price prediction is
extremely challenging because of multiple (macro and micro) factors, such as politics, global
economic conditions, unexpected events, a company’s financial performance, and so on (Li, 2022).
Financial time series prediction is known to be a notoriously difficult task due to the generally
accepted, semi-strong form of market efficiency and the high level of noise (Shen and Shafiq, 2020).
Even after considering the difficulties of efficiently predicting stock prices, many papers have been
presented in the related field. All these papers proposed entirely different methods and technologies
to effectively predict stock market prices and creating and managing a portfolio based on the
predictions. Let us explore some of the ways presented by other research works which can solve this
problem of stock market portfolio selection and management.
2.2 VARIOUS APPROACHES FOR STOCK PRICE PORTFOLIO SELECTION
AND MANAGEMENT
As presented in section 1.1 and 1.2, many research works have tried to identify the solutions to the
problem of predicting stock market prices for various companies’ stocks and these papers have
further used these predictions for effectively creating or selecting a portfolio of stocks with
maximum profits. These papers also evaluate methods to manage this portfolio of stocks to guide
the investor or portfolio manager in gaining maximum profits out of their investments. In this
section, we will try to compile some of these methodologies and approaches for answering the
questions related to portfolio creation and management.
When it comes to stock predictions, there are basically two main types of analyses that can be
performed on the data for efficient stock predictions. These approaches are: fundamental analysis
and technical analysis. Both these approaches are extremely opposite to each other.
The advancement in technology such as Artificial Intelligence and Machine Learning has led to the
growth of analytics and data analysis technologies as well. The Business Analytics has been used by
organizations to derive valuable information from the collected big data. For a long time, businesses
have been relying on Business Intelligence (BI) to deliver insights about their businesses and analyse
their business performance. Now, these technologies have been extensively used to provide
valuable insights and significant analysis in various other fields as well. With the advancement of
technologies, cloud, and business analytics, there has also been an advancement in the emergence
and use of business intelligence tools. Through its automating power, the technology allows the
important human resources to focus on more important and complex processes and strategies.
In Power BI data analytics, the flow that is being followed for analysis is as follows:
Figure 1 Power BI Architecture
1. The first and foremost constraint that need to be considered is the budget constraint or the
resources constraint. Due to the unavailability of resources, many decision opportunities can
not be considered.
2. Choosing an alternative into the portfolio is expected to produce some positive benefit
which can be tangible or intangible but it will often be multidimensional mixing both kinds of
benefits (Liesiö et al., 2021).
3. The value of selecting a portfolio varies in a systematic manner. Depending on the context,
two projects simultaneously may produce more or less value than the sum of the value of
doing both the projects individually and also, these may cost more or less than the sum of
the cost of these projects individually (Liesiö et al., 2021).
2.5 TIME SERIES FORECAST AND MODELLING
Time series is a collection of data points collected at constant time intervals which are analysed to
determine the long term trend so as to forecast the future or perform some other form of analysis
(Jain, 2020). The time series forecasting depends on time even in the case of linear regression model.
Most of the time series models have some sort of seasonality trends along with the increasing and
decreasing trends. The time series can also be stationary and any Time series can be said stationary
if its properties such as mean, variance, etc. which are the statistical properties remain constant over
time. But not all Time series are stationary and assuming that it is while developing any model is not
correct. Time series modelling involves working on time (years, days, hours, minutes) based data, to
derive hidden insights to make informed decision making (Srivastava, 2020). The time series analysis
and modelling are very powerful tools for forecasting and predictions. These models are considered
as more useful when the data available is serially correlated. Most of business houses work on time
series data to analyse sales number for the next year, website traffic, competition position and much
more (Srivastava, 2020). Some of the time series modelling techniques are stationary series, random
walk, dickey fuller tests of stationarity, rho coefficient, etc. Any time series is said to be a stationary
series if the mean of the series is a constant, the variance of the series is not a function of time and if
the covariance of the ith and i+1th terms is not a function of time.
The first step in the research was to collect the data for analysis. For this purpose, we went through
many online websites and read online articles to determine which data source will be most suitable
for this research and is available easily publicly. Most of the data sources were very credible and did
not provide the latest real time updates in the stock price fluctuations. These sources could not be
used for the research because of their false data and this would make the system inefficient. I found
three different online sources which could be used for this research which were Reuters, Money
Control and Yahoo Finance. Out of these three options, I went with Yahoo Finance. I found Yahoo
Finance as the most credible free source for the data collection for this research. The data on Yahoo
Finance is updated every second and shows the exact price of stocks at a given time on the stock
market which is what was required for this research. The website provided us with the dynamic data
required for this analysis so that when the data on the website changes, the same will be reflected in
our dashboard as well. Below is an example of sample stock data present on Yahoo Finance:
The data on Yahoo Finance is live data and is changing every second. Since the focus of this research
was on developing a power BI dashboard which can most accurately analyse the stock data and
present predicted results, we only worked on the fetched set of data to train the Power BI
dashboard to work more accurately and then predicted the stock price for these companies using
the trained model.
The initial data from Yahoo Finance contained columns and fields such as the Name of the company,
last price, market time, change, %change, volume, market cap, intraday high/low, 52 week range
and day chart. It was not possible to import this data into Microsoft Power BI in the current format
because some the columns contained graphs and spark lines. This data would not meet the data
validation criteria in Microsoft Power BI and additional columns needed to be removed. Therefore,
while importing this data into, some of the columns were got rid of.
When this data was imported into Power BI, the columns that were kept and imported were
company name, change, %change, last price, EPS, 52 week high, 52 week low, Market cap and serial
number. The columns such as intraday high/low, day chart, market time and 52 week range were
discarded and instead, 52 week high, 52 week low, serial number, EPS, etc. were added to make the
data more credible and suitable for analysis.
Since it was not possible to copy and clean this data in MS-Excel because that would make the data
static and there was no way to keep the data continuously updated in Excel and clean it. Similarly, if
we store this data in any Structured Query Language (SQL) based Database also, it would not allow
us to work on dynamic data which will get refreshed after every second. To avoid this issue, some
method was required by which the data can get refreshed with changing values on the internet
dynamically. Therefore, the best way was to import the data directly into Power BI and clean it in
Power BI itself during the data validation step. For this, the data was imported into Power BI and the
columns were renamed and removed as per the requirements. Once the data was ready, the next
steps of data modelling and visualization were performed.
Chapter 4: Research Methodology
4.1 PROPOSED SYSTEM
Over the years, researchers have focused on the analysis of issues and problems related to stock
price along with the efforts to analyse the transactions in stock market such as volume burst risks,
which has made the research domain for stock analyses even broader and is a proof that the area
still has high research potential (Shen and Shafiq, 2020). With the advancements in Artificial
Intelligence and Machine Learning algorithms, new technologies and tools were used to propose
models which could be used a training model for efficiently predicting stock prices of the companies
by combining AI and ML together. These models prove to be success and can provide stock market
predictions with higher accuracy than other techniques. Moreover, these technologies are also
relatively easier to explore and are still growing, which means that there is a chance of building an
even more efficient system for portfolio selection and management. But in this research, we will
deviate from these technologies and use even more simple technologies such as Power BI, MS Excel
and Python programming language to do the same task as is being done by these more advanced
technologies. Even though Power BI is much simpler than these advanced technologies and
algorithms, it can prove to be as efficient in portfolio selection and management as any other
technologies.
In this research, the focus of the research is to propose and build a stock price prediction model
using Power BI and Python programming language. Power BI is a visualization tool which is perfect to
generate meaningful insights and beautiful dashboard from raw and messy data. Power BI also has
the potential to make future forecasts and predictions using its in-built Artificial Intelligence
modules. Since the stock market data is volatile and can be very unpredictable and messier at times,
Power BI can prove to be very useful and successful in harnessing this data and turning it into
meaningful insights and predictions using its Artificial Intelligence modules. Microsoft Power BI is
recognised as a leader in Gartner’s 2020 Magic Quadrant for Analytics and Business Intelligence
Platforms (Sin, 2020). Python, on the other hand, provides the advantage of machine learning
algorithms which can be very easily implemented using python code in a very simple manner.
Combining these two technologies can providing a system which can be as efficient as any other
model built with the combination of Artificial Intelligence and Machine Learning.
The following diagram demonstrates a rough idea of the steps and the research methodology
incorporated in this research.
Figure 3 General overview of the proposed research methodology (Banner ID)
As demonstrated in the figure above, the data was fetched from online sources and imported into
Power BI for analysis. The data was first cleaned in Microsoft Power BI and then DAX functions and
data transformations were used to transform this data into more valuable and meaningful insights.
Then using this data, user friendly visualizations were created for easy and better understanding of
the user.
The proposed stock market price prediction app in this research contains various sections and graphs
to represent various types of analysis performed on the data. The app contains a list of the top 10,
top 20 and top 30 stocks at the moment which have the highest profit ratio a compared to their
original prices. The app contains a scrolling bar at the top which provides the current real-time price
of the stocks for all the companies along with its predicted price at the closing time at the end of the
day for current day. It also provides visualization and information for the top stocks on the basis of
differentiation of the stocks by EPS, highest profit ratio, top companies by market cap, highest stock
price, highest positive change ratio, and highest P/E ratio. There is a search option where all the
company names are provided to filter out the details for that company and retrieve information for
only the selected companies. These selected companies can be one or more. If no filtering is done,
then all the companies are shown on the dashboard. There is a table at the bottom of the dashboard
which contains information about all the companies which are a part of this dashboard. It contains
information such as the company name, the last stock price of the company, the change percentage
for the last stock price to the current stock price, market cap in crores, EPS information, the 52 week
high and 52 week low for the stock price of the company. This table can be used to create a portfolio
of stocks based on the highest stock prices and highest positive change percentage. Once the
portfolio is created, the search option can be used to only filter out the table to show the stocks of
only the selected companies which will contain the companies present in the portfolio only.
The data is imported from an online source from Yahoo Finance website. The data source for this
data is the online website only. This gives a huge advantage to the app by providing and fetching the
real time data from the online source and updating the dashboard accordingly with real time prices
of the stocks for given companies. By refreshing the dashboard, it can update the app with latest
real-time information. This will allow the users to keep an eye on the latest price of their stocks and
maintain their portfolio with stocks with highest and positive profit ratios. The app is very easy to
use for the user as well.
This thesis makes use of and implements the business analytics and forecasting methods using
Microsoft Power BI to analyse the data fetched from a stock price website. The features, usability
and benefits of the proposed system includes the following:
Fetching real time data from reputable online sources such as Yahoo Finance.
Loading and displaying the data in the form of visualizations and tables to provide insights
which can prove to be profitable to the user using Microsoft Power BI platform.
Obtaining meaningful insights on the stock price prediction and displaying the current and
latest data on the dashboard
Using advanced business analytics and business intelligence technologies such as Artificial
Intelligence and Machine Learning by integrating them with advanced analytics tools such as
Microsoft Power BI and python programming language.
Improving the stock price predictions through the use of advanced tools and technologies
Allowing the user to select and create a portfolio of companies with highest profits in the
stock prices
Allowing the users such as stock investors or portfolio managers to manage their portfolio of
stocks using an easy and efficient user interface
Python, on the other hand, is a very powerful and most widely used programming language now a
days. It is an object oriented programming language which is used in almost every field from
robotics, to software development to business analytics and analysis. We will use python to exploit
its capabilities to implement machine learning algorithms in this research.
The table given below consists of the technologies used in this research along with their technical
specifications and latest versions which are used in this research:
Table 1 Technology stack and specifications
4.3 METHODOLOGY
This research was intended to work on the stock data as well as the financial statements of various
companies, therefore, quantitative data such as the financial summaries for the last 5 years to
calculate and analyse the profit and loss and stock price summary was collected including the
opening and closing price of stocks. Similar research analyses have been presented by many other
researchers in the past using many different methodologies such as machine learning algorithms,
azure cloud, etc. Most of these technologies and tools allow stock price analysis effectively and help
in portfolio tracking also but they are either paid or have limitations (Kapadia, 2018). Power BI
Desktop was used to create a dashboard to analyse the profit/loss summary of the companies and
perform the stock market analysis. Microsoft Power BI is a relatively easier and more convenient and
effective tools to perform this research due to its ability of forecasting future trends using its AI
modules and larger range of effective visualization tools. Microsoft Power BI is recognized as a
leader in Gartner’s 2020 Magic Quadrant for Analytics and Business Intelligence Platforms
(ChangYueSin, 2020). The data was collected from online source named Yahoo Finance for analysis.
This data included the financial statements of the company to know if the business is facing profit or
loss, top 10 stocks market capitalization, the opening and closing stock prices for companies in the
past few months, EPS information and the real time price of the stocks for various companies.
The initial thought was to store this data into MS-Excel first and then cleaning it before importing it
into Power BI. But this would not allow us to analyse the data in real time. The data stored in MS-
Excel would be old data and analysis would be done on this old data which would not be as efficient
as working with the real time data fetched directly from the online sources. Hence, the data was
directly imported from Yahoo Finance into Power BI, providing the advantage of working with real
time data instead of storing it in secondary sources which would not give the benefit of analysing the
real time data. The final predicted results by the dashboard app were compared with the actual
stock price of the companies for a particular day with the original online source of the data Yahoo
Finance, to test the credibility and efficiency of the presented model.
The Power BI Desktop application helped in creating a dashboard app which was highly interactive
and user-friendly as well as highly efficient and predicted all the correct results. Due to effective
visualizations, it became very easy to analyse the stock movements and see which stock is doing
better and can be profitable. This makes it easier for the investors and portfolio managers in making
investment decisions and invest in the top companies. The easy analysis of the profit and loss in the
stock market and the ups and downs in the stock prices will help the user in determining which stock
to invest in. For future work in continuation to this research, the profitability and market analysis
along with the growth analysis of the companies can also be performed using the financial
statements for the companies.
The following sections explain the steps used in the implementation of this research in a more
detailed manner:
Power BI Desktop free version can be downloaded from this website. After downloading the tool, it
was installed on the desktop and was ready to now create dashboards and visualizations.
Next step was to install Python. Downloading python consists of three main steps: download python
and install binaries, run the installer and add python to PATH variables in environment variables.
Python binaries were downloaded from the official Python website:
https://www.python.org/downloads/windows/
The latest version 3.10.6 was downloaded from this website. After it was downloaded, the python
installer was run. Customized installation was selected for this step. Under the advanced options,
the checkbox for Add python to environment variables was selected. After the installation
completed, the next step was to add the python to PATH environment variables. After doing this, we
verified the python installer by running the python command in the command prompt.
The final step was to download and install an Integrated Development Environment (IDE) for writing
and running the python code to test before writing it in the Power BI. Pyspark was downloaded from
the official Anaconda Website: https://www.anaconda.com/. After successful download, it was
installed on the local desktop and after installation, all the environment variables were setup and all
the required libraries were installed in the IDE.
After all the environment was setup, we were ready to move ahead with the data source selection
and setting up the data source in Power BI desktop.
1. Launch Power BI desktop on the computer. Click on Get Data on the Home tab. This contains
a list of all the possible options to import data from into power BI application. The list
contains options such as MS-Excel, SQL Server, Text/CSV, Web, Blank query, etc. We selected
the web data source from this option. Paste the URL for Yahoo Finance in the dialogue box
that opens. Click on next and the data will be imported into the power BI desktop from the
online source, that is, Yahoo Finance. The website URL used for this step is:
https://finance.yahoo.com/trending-tickers
2. The data was loaded into the power BI. After this, click on the table format to import the
data in tabular manner. This feature of power BI is very strong as it automatically converts
the web data or any kind of data into tabular format without having to do complex scrapping
or data transformation operations on the given data set.
The following screenshot displays all the options that are available in Power BI Desktop to
import data from various sources:
3. The next step is to apply transformations on it to remove any errors or null values and to
apply correct data types for the given columns. The imported data looked like the figure 3.4
below. The accuracy of the data is displayed as the validity, whereas any errors in the data is
displayed as the error percentage and null value percentage. For this data, most of the rows
were error free and did not have null values. Therefore, there was not much to be done at
this stage.
Figure 5 Data imported in Power BI with Data Validity and error percentage
4. The next step was to assign the correct data type to the columns. Sometimes, while
importing the data from external sources into Power BI, there are data type mismatch
issues. This is mainly because external sources such as MS-Excel or web sources do not
provide a very wide range of data types. The limited data types are, therefore, merged into
categories. Whereas, when we import this data into Power BI, we need to first segregate the
data into their correct respective data types to before starting to work on it. If this step is
not performed, the data will not have correct data types and later, we will face issues while
applying transformation operations or DAX functions to the data. Therefore, in this step, we
assigned correct data types to all the columns present in the data.
1. The next step after importing the data into Power BI will be the data modelling. Data
modelling includes making relationships between data objects, determining cardinalities like
1 to many, many to many, 1 to 1, etc. (Microsoft Power BI Community, 2021). Data
modelling makes sure that the results obtained are correct by ensuring that the data upon
which the analysis is done is correct and has the correct format. The relationship between
columns should be correctly specified. In this step, we analysed the data and checked if
there was a need of any additional columns or table in the data to complete the
relationships and predict correct results. For this research, we had three main tables that we
worked with. The first table contained the company name, change percentage, 52 week
high, 52 week low, last price of the stock and the market cap. The second table contained
fields such as change, change percentage, company name, EPS, last price of the stock and
serial number. The third table called Top Market Cap contained fields such as Rank EPS, Rank
market cap, selected top n EPS, selected top n companies, Top N, Top values, Total EPS and
Total Market cap. The relationship between these tables is shown in the below figure:
2. In the next step, we will start writing the transformation operations and DAX functions for
the data. Data Analysis Expression is a collection of functions, operators, and constants that
can be used in a formula, or expression, to perform advanced calculations and queries on
data in related tables and columns in tabular data models (Microsoft, 2021). Writing DAX
functions is one of the difficult tasks in Power BI. The DAX functions should be correct and
should provide correct and expected output. If the functions are not properly written, we
may end up getting different, unwanted and even wrong results and outputs. Power BI
comes with its own set of Data Analysis Expression (DAX). The results of these DAX
expressions or functions can change or have a significant impact on the context or
explanation of the data. These DAX functions have the similar syntax as that of Excel
functions so that they are easy to write and follow and can be easily understood by anyone
who sees it. The general DAX formulas are simple mathematical expressions written to
derive suitable results. We first analysed the data to conclude which columns can be used
for predictions and which columns contain the possible data trends. Some of the DAX
functions that we wrote for this research are as follows:
Once the DAX operations were performed, it was time to display our results in the form of
graphs and charts. So, the next step was to create visualizations. The visualizations needed
to be simple and user-friendly and expressive. The visualizations such as graphs and charts
should be selected in such a way that it explains what is happening in the data accurately.
So, the selection of right kind of graphs and charts is very important. The colour theme also
needs to be accurate and should not be too bright or too dull. It should make the dashboard
look impressive and expressive. This is the easiest step while creating a power BI dashboard
in terms of implementation. However, it can be the most difficult part in terms of making the
dashboard expressive and user friendly. The user experience with the dashboard matters a
lot and needs special focus when working on it. Data Visualizations help in making the
analysis of data easy by anyone who looks at it and providing important insights related to
the data by demonstrating the data trends using graphs and charts. In our dashboard app,
the data visualizations used were Artificial intelligence (AI) driven. These AI driven visuals are
automatically provided in the Power BI desktop. One only needs to drag and drop the
visualization they want to use in their apps.
Since the stock market data is volatile, difficult to interpret and understand, we used simple
and very basic visualizations for our dashboard to make it easy to understand on the first go.
Final step was the portfolio creation and management. Before going for the portfolio
creation, we first tested the accuracy of our power BI dashboard app. For this purpose, we
compared the results predicted by our app with the actual stock price for those stocks on
the closing of that day. After checking the accuracy and improving it to predict the most
accurate prices, we moved ahead to create the portfolio. To create the portfolio, we studied
the predicted results and see which stocks are doing the best in the market and are
predicted to close at the highest values for the day. Also, we analysed the financial
statements also and the financial summary for these top performing stocks and filter out the
even best options to invest in.
The final app which was created using Power provided 90% accurate results to us with 10%
error margins due to the volatile nature of the stock market. This app will be user friendly
and will help the users to create the portfolio with the best options to invest in and manage
that portfolio. Currently, the application is working only with the real time data for stock
prices of various companies and providing predictions for the change in the stock price of
these companies based on the current trends.
Chapter 5: Data Analysis and Results
After all the analysis and formatting of the dashboard, we were presented with an application which
could provide us with the current real time stock price values of various companies. The dashboard
was now ready for the analysis and testing the accuracy of the dashboard by comparing the
predicted stock price with actual stock price from the online sources such as Yahoo Finance. Data
analysis for the research was done using Power BI dashboard that was created during the
implementation process. The dashboard provided enough information to analyse and derive results
from the analysis. Let’s have a quick analysis of the results and see what our dashboard presented.
The dashboard was named as Portfolio Management System. The dashboard contained two graphs
depicting the top 10, top 20 and top 30 stock prices according to their profits by EPS and by Market
Cap. At the time of creation, the top 10 companies by Market Cap were recorded to be Reliance,
TCS, HDFC Bank, Infosys, HUL, ICICI Bank, SBI, HDFC, Bajaj Finance and LIC India. The top 10
companies by EPS, however, were Info Edge, Shree cements, Page Industries, Ultra Tech, Nestle,
Bajaj, Hindustan Aeron, Bajaj Holdings, L&T Infotech and Maruti Suzuki. The highest stock price was
calculated to be of Page Industries which was 49,800. Highest positive change percentage in the
stock prices was calculated to be of Hindalco which was 4.41% and the highest PE ratio was
11,894.40 which belonged to TCS.
When we matched this data with the data from Yahoo Finance, the results matched for all the
values, showing that the results calculated by our dashboard were correct and the system is reliable.
This kind of analysis can be done using our Portfolio Management System app using Power BI.
The research proposed and built a dashboard app to effectively and efficiently predict stock prices of
various companies and select and manage a portfolio of these stocks. Stock market prediction is very
difficult and many different approaches have been presented by various researchers in this field.
Some techniques based on neural networks such as Artificial Neural Network (ANN), Convolutional
Neural Network (CNN), Recurrent Neural Network (RNN) and deep neural networks like Long Short
Term Memory (LSTM) also have shown promising results (Vijh et al., 2020). An interactive Portfolio
Management System was created as a part of this research using Microsoft Power BI and Python
programming language. The project used advanced data analysis tools using Power BI and Python to
solve the problem of stock portfolio management. The stock data was collected from online sources
to be imported into Power BI and perform analysis on it. The results came out to be highly
acceptable and efficient. The built app could predict the stock price with 90% accuracy which is equal
to the results presented by other similar research papers using the complex technologies and
algorithms for same purpose.
The results also demonstrated that Power BI can be an effective tool for building portfolio
management systems and can provide significant results which can help the investors despite the
volatility and fluctuations in the market. The dashboard design was extremely simple and user
friendly. It contained all the fields and sections which can be useful to the users. The dashboard is
easy to understand and operate. The project also validated the use and importance of the using
Power BI in performing data analysis and analytics for any business.
Some of the results from the implementation are shown in the figures below:
Figure 11 Portfolio Management System in Power BI
This research thesis can also be used a guide on how to use advanced business intelligence and data
analytics tools such as Power BI to select and manage a portfolio of stocks by anyone who is working
on similar research topics. The research thesis provided a detailed set of steps which can be
performed to design an effective stock market analysis dashboard and portfolio management system
using Power BI.
Due to the lack of time and other constraints, the research could only implement the stock price
analysis of the stocks and predict future price of the stocks using limited information only. As
described in the literature review section, there are many factors that impact the fluctuations in a
stock price. These include the financial summary of the company as well. The initial plan was to
incorporate the financial analysis in this research as well. However, due to time constraints, that part
could not be implemented in this research. Future work for this research or continuation of this
research can include that part and perform the financial analysis of the company and include the
financial summary in this analysis report as well.
Chapter 7: Conclusion
Accurate stock price prediction is extremely challenging because of multiple (macro and micro)
factors, such as politics, global economic conditions, unexpected events, a company’s financial
performance, and so on (Li, 2022). The stock market was predicted to be volatile at the beginning of
2022 with a rise in inflation. All the prediction aspects such as physical and psychological factors
combine to make share prices volatile and very difficult to predict with a high degree of accuracy
(Singh, 2018). As the market fluctuates, investors need visibility into how their portfolios are
performing (Visualize portfolio performance and risk with Microsoft Power BI, 2022).
This research focuses on providing best stock marketing solutions to anyone who wants to invest in
stock market or compare the movements in one stock with other popular stocks. Analyzing stock
price movements in real time can significantly help the users in decision making about their
investments. This research focuses on analysing the patterns and trends in stock price fluctuations of
various companies’ stocks and perform future predictions for the trends and movements identified
in stock market and maintain a portfolio of all the invested stocks using traditional financial
methodologies and power BI.
Critical Reflection
The research thesis focused on topics like Data Analytics, Business Intelligence, Portfolio
management systems, stock market analysis, etc. I gained a lot of perspective on these topics while
implementing this research and writing this thesis paper. Stock market data is highly volatile and
performing this analysis on such a data was very difficult as well as a learning opportunity for me.
These topics were taught in the coursework and the learnings from there helped me a lot in this
research. I got to practice the things that had learnt practically on new tools such as Microsoft Power
BI. Through this research, I got more perspective on how these advanced business intelligence tools
can be used to create and manage a portfolio of stocks. I had already learnt and used tableau before
and had some knowledge on the implementation of the tool for data analysis. For this research,
therefore, I decided to explore Microsoft Power BI, which was comparatively easier to use and gave
the same analysis opportunities and results.
The topic selection was one of the difficult and confusing tasks for me. I had the liberty to choose
from a lot of topics related to the analysis which could be performed using Microsoft Power BI. I
went through a lot of previous research work and literature and decided to move forward with the
topic of portfolio management system. I found out that many different approaches were proposed
by the researchers in their thesis and research papers to solve the problem of maintaining a complex
portfolio management systems. This motivated me even more to try and find out an easy and
equally efficient solution to this problem. For this research, I went through the concepts related to
this topic that I had learnt in my coursework once again and tried to accumulate as much knowledge
as possible through online sources and books. Through this research, I aimed to learn more on how
to implement logics using Power BI and also, my previous knowledge of data analysis tools such as
tableau helped me in understanding Power BI more quickly.
This research also provided me the opportunity to learn how to write a thesis paper. From creating
the specification form to completing the final interim report for the research, it was a great learning
experience for me. I learnt how to frame a research question based on the problem that we are
working on. I learnt how to write an effective and concise abstract for the research, how to decide
the aims and objectives of our research and how to justify the work that we are doing. Along with
the implementation, the report writing part is also equally important. The work being performed is
of no worth if one does not know how to explain and present it properly to others. Therefore,
writing an effective research thesis was equally important for this research. It also taught me to
effectively prepare a research plan and follow it rigorously to complete the research on time.
The implementation part of the research was also very educative and knowledgeable. I learnt a lot
about stock market and learnt how to handle and keep control on volatile and continuously changing
data in a large amount. Stock market analysis and portfolio management are also very sensitive
topics and require lesser error margins because any wrong analysis and prediction can lead to big
losses to the clients or the users using the application. I learnt about the situational damages in case
of failures of the system and tried to mitigate as many issues as I could in this research. I also
encountered many issues and problems while working on this research and learnt how to handle the
issues and mitigate the problems through this research.
APPENDICES
Figure 12 Data imported in Power BI with Data Validity and error percentage
2. Table 1 in Power BI
Figure 13 Table 1
3. Table 2 in power BI
Figure 14 Table 2
8. Table in Power BI Dashboard containing all the required information about the stocks.
11. Displaying results in the table based on the selected company. For example, in the below
screenshot, the selection filtered the results for Adani Green company.
Figure 22 Filtering results based on selection
REFERENCES
Barbati, M., Greco, S., Kadziński, M. and Słowiński, R. (2018) Optimization of multiple satisfaction
levels in portfolio decision analysis. Omega. Vol.78, pp.192-204.
Hu, W., Xie, H., Nakas, M., Shi, W. and Wang, M. (2022) Power BI for Impacts Analysis on Cost of
Living Caused by Industry Prevalence in Smart Cities [Online]. Ieeexplore.ieee.org. Available:
https://ieeexplore.ieee.org/document/8906533 [Accessed 17 Aug 2022].
Kapadia, S. (2018). How to use Power BI for Stock Market Analysis? [online] Money Excel - Personal
Finance Blog. Available at: https://moneyexcel.com/use-power-bi-stock-market-analysis/ [Accessed
25 Jul. 2022].
Liesiö, J., Salo, A., Keisler, J.M. and Morton, A. (2021). Portfolio decision analysis: Recent
developments and future prospects. European Journal of Operational Research, 293(3), pp.811–825.
doi:10.1016/j.ejor.2020.12.015.
Li, K. (2022). Predicting Stock Prices Using Machine Learning. [online] neptune blog. Available at:
https://neptune.ai/blog/predicting-stock-prices-using-machine-learning [Accessed 21 Jul. 2022].
Negi, A. (2021). Profundity Of Business Analytics & it’s Purview In India. International Journal of
Research and Analytical Reviews (IJRAR), [online] 08(04). Available at:
https://www.ijrar.org/papers/IJRAR21D1003.pdf [Accessed 24 Jul. 2022].
Peykani, P., Mohammadi, E., Jabbarzadeh, A., Rostamy-Malkhalifeh, M. and Pishvaee, M.S. (2020).
A novel two-phase robust portfolio selection and optimization approach under uncertainty: A
case study of Tehran stock exchange. PLOS ONE, 15(10), p.e0239810.
doi:10.1371/journal.pone.0239810.
Salo, A., Keisler, J. and Morton, A. (2011) Portfolio Decision Analysis: Improved Methods for
Resource Allocation [Online]. University of Strathclyde. Available:
https://pureportal.strath.ac.uk/en/publications/portfolio-decision-analysis-improved-methods-
for-resource-allocat [Accessed 11 Aug 2022].
Sharda, R., Asamoah, D. and Ponna, N. (2013). Business analytics: Research and teaching
perspectives. Information Technology Interfaces (ITI), Proceedings of the ITI 2013, [online] 35.
doi:10.2498/iti.2013.0589.
Singh, A. (2018). Stock Prices Prediction Using Machine Learning and Deep Learning Techniques (with
Python codes). [online] Analytics Vidhya. Available at:
https://www.analyticsvidhya.com/blog/2018/10/predicting-stock-price-machine-learningnd-deep-
learning-techniques-python/ [Accessed 21 Jul. 2022].
Shen, J. and Shafiq, M. (2020) Short-term stock market price trend prediction using a
comprehensive deep learning system. Journal of Big Data. Vol.7 (1).
Sin, C. (2020) How to Use Power BI for Stock Market Analysis - The Babylonians [Online]. The
Babylonians. Available: https://www.theancientbabylonians.com/how-to-use-power-bi-for-stock-
market-analysis/. [Accessed 3 Aug 2022].
Srivastava, T. (2020) Time Series Analysis | Time Series Modeling In R [Online]. Analytics Vidhya.
Available: https://www.analyticsvidhya.com/blog/2015/12/complete-tutorial-time-series-
modeling/?utm_source=blog&utm_medium=stockmarketpredictionarticle [Accessed 4 Aug 2022].
Vaezi, F., Sadjadi, S. and Makui, A. (2019) A portfolio selection model based on the knapsack
problem under uncertainty. PLOS ONE. Vol.14 (5), p.e0213652.
Vijh, M., Chandola, D., Tikkiwal, V. and Kumar, A. (2020) Stock Closing Price Prediction using
Machine Learning Techniques. Procedia Computer Science. Vol.167, pp.599-606.
Visualize portfolio performance and risk with Microsoft Power BI. (2022). Bloomberg Professional
Services. [online] 22 Apr. Available at: https://www.bloomberg.com/professional/blog/visualize-
portfolio-performance-and-risk-with-microsoft-power-bi/ [Accessed 22 Jul. 2022].