How Do You Forecast Mutual Fund Performance?

Mutual funds are key contributors to the globalization of financial markets and one of the main sources of capital flows to emerging economies. These funds as a medium-to-long term investment option are preferred as a suitable investment option by investors. In the present scenario with the economic slowdown and recession looming over the horizon a smart investor could navigate these storms and reap benefits. Mutual Funds are a suitable tool for a uniformed investor to have an exposure to the financial market. Thus, if invested wisely these funds could act as a great source of secondary income and therefore forecasting the trend and its analysis in different market situations would help in making better judgement.
Through the use of Machine learning various mathematical models and algorithms were tested so as to determine the one with the best performance metric compared to others for facilitating the forecasting.
The project also dwelled into the performance of funds from different categories in bull and bear phase so as to devise a better strategy for investing in aforementioned phases of the market.
The project was majorly carried out on Google Colab and the script used was Python.
LIST OF TABLES
| Table No | Table Title Page No |
| 1 | Mean absolute error of different funds with different models 24 |
| 2 | Rate of returns for Bear and Bull cycle 26 |
| 3 | Jensen’s Alpha of funds in bull and bear phase 29 |
| 4 | Treynor’s Ratio values of funds in bull and bear phase 29 |
| 5 | Sharpe Ratio values of funds in bull and bear phase 30 |
| 6 | Average Sharpe values 30 |
| 7 | Sortino Ratio values of funds in bull and bear phase 31 |
| 8 | Beta values of funds in bull and bear phase 33 |
| 9 | Standard Deviation of funds in bull and bear phase 33 |
| 10 | Downside Deviation of funds in bull and bear phase 34 |
LIST OF FIGURES
| Figure No | Figure Title Page No |
| 1 | Possible Hyper planes 14 |
| 2 | Hyper planes for 2D & 3D feature space 15 |
| 3 | Support Vectors 16 |
| 4 | NAV v/s Date (in years) 19 |
| 5 | NAV v/s CPI 20 |
| 6 | NAV v/s BSE Sensex Index 21 |
| 7 | NAV v/s 10 year Treasury Bond 21 |
| 8 | NAV v/s 5 year Treasury Bond 21 |
| 9 | NAV v/s Export 22 |
| 10 11 12 13 | NAV v/s Import 22 NAV distribution plot 22 5 year Treasury Bond distribution plot 23 10 year Treasury Bond distribution plot 23 |
1.1 Introduction to Mutual Funds
Financial markets have a vital role in the economic development of a country. They facilitate the allocation of scarce resources by transferring them from savers to borrowers, thereby accelerating investment activities in the economy. One of the most popular financial investments is mutual funds, which pool the savings of a large number of investors with a shared financial goal based on trust.
The money thus collected is invested in capital market instruments such as shares, debentures and other securities. Investors get the number of units based on the amount invested and the net asset value of the units. The income earned is shared among the investors in proportion to the number of units held by them.
A mutual fund is an investment that suits the needs of the common man. It is an indirect form of investment in the capital market that has the advantages of diversification, professional management, low-cost investment, liquidity and tax benefit. The primary objective is to provide better returns to the investor by minimizing the risk associated with capital markets.
1.2 Area of Work
This project involves the use of concepts learnt during our tenure in Engineering and applying them in the field of Finance. The project majorly revolves around 2 major spheres.
1. Finance: The project requires in-depth analysis of the financial market and its working. Various important economic factors and events lead to changes in condition and status of the stock market. By testing numerous hypothesis we are trying to find those links or factors which affects the financial sector.
2. Technical: We are going ahead with the Machine Learning approach from Data Science to support the hypothesis we presume. Various mathematical models and algorithms would be investigated and tested to find the best fit for predicting the net asset value. The project also dwells into the performance of funds from different categories in bear and bull phase of the market. The performance would be analysed using various predefined mathematical measures which in turn would help us in understanding the dynamics of these funds in different phases.
1.3 Motivation
Mutual Funds as mentioned above are key contributors to the economy of the emerging countries. Thus there lies a vast potential in exploring this field as it is bound to grow to exceptional levels. They are also one of the key investment tools in the field of investing.
The previous work in this field is not recent and with the ever changing financial landscape there is a need for new insights and analysis in this field. With the help of this project we would like to point out economic indicators which affect the growth of mutual funds. The second half of the project deals with the performance evaluation of these funds in bear and bull phase. We would like to discuss the possible explanations for outliers with exceptional performance in these phases with respect to other data points.
1.4 Objective
1) To identify the best possible mathematical model to forecast the net asset value. 2) To evaluate the performance of funds in bear and bull phase.
BACKGROUND THEORY
2.1 Introduction
Although on first glance it may seem that the investment in mutual funds and stock market seem similar but there are some starking differences in the pricing system. As opposed to a stock market where the price of a stock or share is issued by the company on its IPO, every mutual fund has its own net asset value which depends upon various factors such as assets and liabilities of a fund.
2.2 Net Asset Value (NAV)
NAV is an abbreviation for Net Asset Value. It defines the market value of the fund nit of the share.
NAV = (Assets – Liabilities) / Total number of outstanding shares
• The pricing system model of mutual funds for trading shares is quite different from that of the common equities or stocks. These stocks are public and are issued by the company for amongst masses and is listed on the stock exchange.
• Through an Initial Public Offering (IPO) a company issues some limited number of share as equity and this could be extended subsequently and then traded on the exchange market such as Bombay Stock exchange (BSE). The supply and demand of shares dictate the stock prices and are governed by market forces. The pricing system model is solely based on the demand created in the market.
• A Mutual fund’s worth is evaluated on the basis of parameters such as asset under management (AUM) and the total amount of money invested in the fund and the number of outstanding shares.
2.3 Economic Indicators
Economic Indicators are used to measure the overall health and state of the economy. They’re typically issued by government agencies in the form of a census or survey and investors care about them because they indicate the amount of
systematic risks in the system which affects the prices of securities and investments. For the purpose of our project we have identified 11 such factors which could prove detrimental in forecasting the net asset value of a fund.
1. Gross National Product (GNP): Gross national product is the estimate of the total income that is earned by a country’s factors of production regardless of where the assets are located. GNP is equal to GDP plus income earned from assets abroad minus income paid to foreign assets operating domestically. The income from abroad is the income earned by firms operating in foreign countries.
2. Gross Domestic Product (GDP): GDP is an estimate of the total market value of all finished goods and services produced in a country within a year. It measures how large the economy is. GDP is the sum of consumer spending, government spending, investments and net exports. GDP gives insights into a country’s economy and enables comparison with other countries.
3. Consumer Price Index (CPI): It is a measure that examines the rate of inflation. The consumer price index is measured by analyzing the price of the goods and services in a market basket. The market basket is a fixed set of goods and services whose prices are used to calculate changes in prices year on year. The goods and services in the basket vary by country due to differing consumption habits and also have different weightings. The CPI is calculated by dividing the current price of the market basket by the market basket of the base year, which is then multiplied by 100.
4. Narrow Money (M1): Narrow money is the money in forms that can be used as a medium of exchange, generally notes, coins and certain balances held by banks. In the United States, narrow money is classified as M1.
5. Broad Money (M3): Broad money is money in any form including bank and other deposits as well as notes and coins.
6. 10 Year Bond (Treasury note): The 10-year Treasury note is a debt obligation issued by the United States government with a maturity of 10 years upon initial issuance. A 10-year Treasury note pays interest at a fixed rate once every six months and pays the face value to the holder at maturity.
7. 5 Year Bond: The 5-year Treasury note is a debt obligation issued by the United States government with a maturity of 5 years upon initial issuance. A 5-year Treasury note pays interest at a fixed rate once every six months and pays the face value to the holder at maturity.
8. S&P BSE Index: The BSE Sensex is designed to measure the performance of 30 largest and financially sound companies across the sectors of India’s economy that are listed on the BSE. It is widely used as both, as a benchmark and an investable index. The 30 companies listed on the index covers more than 44% of total market capitalizations of the listed universe of BSE.
9. Net Export: Net exports is the amount by which the total exports of a country exceeds its total imports. Both exports and imports include physical goods, such as food, clothes, and automobiles, and services, like business consulting, travel, telemarketing, and government and military contracts. If a country’s total exports are greater than the total value of goods and services that it imports, net exports will be a positive number. If a country’s total exports are less than the value of the goods and services it imports, net exports will be a negative number.
10. Net Import: A net importer is a country or territory whose value of imported goods and services is higher than its exported goods and services over a given period of time. A net importer, by definition, runs a current account deficit in the aggregate; however, it may run deficits or surpluses with individual countries or territories depending on the types of goods and services traded, competitiveness of these goods and services, exchange rates, levels of government spending, trade barriers, etc.
6
11. Exchange Rates: An exchange rate is the value of one nation’s currency versus the currency of another nation or economic zone. Most exchange rates are free-floating and will rise or fall based on supply and demand in the market. Some currencies are not free-floating and have some restrictions.
2.4 Different phases of a financial market
The financial market is never stagnant and thus it could be classified into two phases termed as bear and bull. These terms indicate if the market is performing better compared to its recent past.
2.4.1 Bear Phase
A bear phase is characterized by extended periods of decline in the prices. Widespread distrust and pessimism towards the market accompanied by a decline of 20% or more from the recent peak are the key indicators of a prevailing bear phase. Cash flows and profits of companies are reflected on the stock price. With the eminent future looking bleak with little to no growth prospect and dashed expectations the prices of the stock can fall rapidly. Prolonged period of decreased or depressed prices of stocks generally stems from the herd behavior and fear amongst the investors so as to protect their investment from downside losses.
The most common perceived definition for bear market is that the stocks should fall at least 20% off from the recent high to define a bear territory. 20% as mentioned above is just an arbitrary number same as 10% is for an arbitrary number for benchmark. Bear markets could also be defined as a phase where the investors are more inclined towards aversion of risk. Bear markets tend to exist for long periods as investors pour their money on sure bets.
● Characteristics of bear phase
The bear market is mostly brought upon by sluggish or slow economy but there could be other reasons as well. The key indicators of a weak or slowing economy are considerable drop in the profits earned by business, unemployment, low disposable income and decrease in productivity. A bear market could also be triggered by any untimely intervention by the government. For instance, changes in the taxation laws or central fund rates can cause bear market. The onset of a bear market is also accompanied by drop in the confidence of the investor. Actions such as selling off shares in large amount to avoid losses may also lead to bear market.
2.4.2 Bull Phase
When the prices are on the rise and are also expected to continue the trend in the future this phenomenon is termed as bull phase. The key characteristics of a bull market are increase in the confidence of an investor, optimism and that the strong result should continue to perform in the same manner or even better. The trends of the markets are difficult to predict on a consistent basis. Variables such as psychological effects and market speculations make it even harder to predict.
Similar to that of bear market there is no defined metric to identify a bull phase. The most common definition identified everywhere is that when the stock prices increase by 20% after a drop of 20% and a second another 20% decline. This phase can only be recognized when it has happened thus making it even more difficult to predict. The most recent bull market occurred in the period 2016 – 2018. The S&P 500 increased significantly after a decline in the previous period. With the advent of COVID-19 pandemic major decline took place again after this good run.
● Characteristics of bull phase
These markets occur when there are positive signs such as strengthening of economy or when if it’s already strong. The key characteristics of a bull phase are a drop in unemployment, a strong domestic product (GDP) and most importantly increase in corporate profits. The confidence of investors tends to climb during a bull market period. The overall tone and demand for the stocks would be positive in the market.
There will be an increased amount of IPO activity in this period. The factors mentioned above are more easily quantifiable compared to others. It is difficult to evaluate the general tone of the market even though unemployment and corporate profits are quantifiable. For example there will be an increase in the demand and the supply would be weak. The investors would be eager to buy securities but then very few would be willing to part with it. During this phase the investors are more willing to get involved with the stock market in order to earn greater profits.
2.5 BSE S&P 500 Index
Bombay Stock Exchange Limited constructed a new index, christened BSE-500, consisting of 500 scrips w.e.f. August 9, 1999. While constructing this index the change in the pattern of the economy and market were considered.
BSE-500 index represents nearly 93% of the total market capitalization on BSE. BSE-500 covers all 20 major industries of the economy. In line with other BSE indices, effective August 16, 2005 calculation methodology was shifted to the free-float methodology.
2.6 Technical Indicators
8
Traders who follow technical analysis make use of these pattern based signals produced by the price, open interest of a security and volume. These financial tools are termed as technical indicators. By analysing historical data, technical analysts use indicators to predict future price movements.
2.6.1 MACD (Moving Average Convergence Divergence)
Moving Average Convergence Divergence (MACD) is a trend following momentum indicator that shows the relationship between two moving averages of a security’s price.
(MACD) =12-period EMA — 26-period exponential moving average (EMA)
MACD triggers technical signals when it crosses above (to buy) or below (to sell) its signal line. The speed of crossovers is also taken as a signal of a market is overbought or oversold. MACD helps investors understand whether the bullish or bearish movement in the price is strengthening or weaken
2.6.2 Stochastic Oscillator
A stochastic oscillator is a commonly used technical analysis indicator to help identify the so called overbought and oversold points in the market. It works by looking at the price momentum, which is the rate at which the price is changing.
%K= (H 14 − L 14) / (C − L 14) ×100
Where:
C = the most recent closing price
L14: the lowest price traded from the 14 previous trading sessions
H14: the highest price traded during the same 14-day period
%K: the current value of the stochastic indicator
It gives indication of the market being overbought or oversold by comparing the present price and the past price and in this comparison it takes into account the highest highs and the lowest lows across the period.
2.6.3 MACD Histogram
MACD-Histogram measures the distance between MACD and its signal line (the 9-day EMA of MACD). Like MACD, the MACD-Histogram is also an oscillator that fluctuates above and below the zero line. It anticipates signal line crossovers in MACD. Because MACD uses moving averages and moving averages lag price, signal line crossovers can come late and affect the reward-to-risk ratio of a trade. Bullish or bearish divergences in the MACD-Histogram can alert chartists to an imminent signal line crossover in MACD.
2.7 Performance Measure
2.7.1 Beta
It measures the systematic risk, or is used as a measure of volatility of a portfolio or a pool of securities and is then compared to the market as a whole.
Beta is used in CAPM (Capital Asset Pricing Model), which describes the relationship between systematic risk and expected return for assets, particularly stocks.
Beta coefficient (β) = Covariance (Re, Rm) / Variance (Rm)
Where:
Re=the return on an individual stock
Rm=the return on the overall market
Covariance=how changes in a stock’s returns arerelated to changes in the market’s returns Variance=how far the market’s data points spreadout from their average value
The swings in the market makes the security’s return respond to it. This activity is indicated by beta. It is defined as product of the covariance of market return and individual stock divided by variance of the overall market return for a specified amount of time.
2.7.2 Standard Deviation
The standard deviation is a statistic measure which indicates the dispersion of data points relative to its mean.
Standard Deviation= (∑ (xi−x) ^2 / (N-1)) ^ (0.5)
Where :-
xi=Value of the ith point in the data set
x=Mean value of the data set
n=Number of data points in the data set
Market and security volatility is measured by standard deviation. Thus making it an useful tool for investing and devising trading strategies. For example the standard deviation of an index fund is expected to be low as it mimics the benchmark index.
2.7.3 Downside Deviation
The returns that fall below a minimum threshold or minimum acceptable return (MAR) are measured by Downside deviation. A measure of risk-adjusted return called Sortino ratio is calculated using downside deviation. Sharpe ratio and Sortino ratio are quite similar with the former having standard deviation in the denominator in place of downside deviation.
All the deviations from the average are considered the same irrespective of the fact that they are positive or negative and treated in the same manner when making use of Standard deviation. The investors should be more concerned about negative divergences compared to positive ones, meaning downside risk is a bigger concern. This issue is resolved by downside deviation by focusing only on negative downside risk.
Investors who have different levels of minimum acceptable return and have a different risk profiles can make use of downside deviation as it would be tailored according to their needs. Thus making it a better option compared to standard deviation.
2.7.4 Jensen’s Alpha
The Jensen’s measure, or Jensen’s alpha, is the portion of the excess return that is not explained by the systematic risk. It is a measure that represents the excess return on a portfolio or investment, above or below that predicted by the capital asset pricing model (CAPM), given the portfolio’s or investment’s beta and the average market return.
Jensen’s Alpha = R(i) – (R(f) + B x (R(m) – R(f)))
Where:
R(i) = the realized return of the portfolio or investment
R(m) = the realized return of the appropriate market index
R(f) = the risk-free rate of return for the time period
B = the beta of the portfolio of investment with respect to the chosen market index
To accurately analyse the performance of an investment manager, an investor must look not only at the overall return of a portfolio but also at the risk of that portfolio to see if the investment’s return compensates for the risk it takes.
If the value is positive, then the portfolio is earning excess returns. In other words, a positive value for Jensen’s alpha means a fund manager has “beat the market” with their stock-picking skills.
2.7.5 Treynor’s Ratio
The Treynor ratio is a measurement of efficiency utilizing the relationship between annualized risk adjusted return and risk. Unlike Sharpe Ratio, Treynor’s Ratio utilizes “market” risk or beta instead of total risk or a standard deviation. A high Treynor’s ratio is indicative of a good performance. It is reliant on portfolio’s beta, which measures the sensitivity of the portfolio’s returns to movements in the market.
Treynor Ratio= (rp−rf) / βp
Where:
rp=Portfolio return
rf=Risk-free rate
βp=Beta of the portfolio
In essence, the Treynor ratio is a risk-adjusted measurement of return based on systematic risk. It indicates how much return an investment comprising of mutual funds, or exchange-traded fund, portfolio of stocks, earned for the total amount of risk bared.
A portfolio which has a negative beta result does not make much sense.
2.7.6 Sharpe Ratio
The Sharpe ratio measures the risk adjusted return for a stock or a portfolio. The higher the Sharpe ratio, the better is the performance.
Sharpe Ratio= (Rp−Rf) / σp
Where:
Rp=return of portfolio
Rf= risk-free rate
σp= standard deviation of the portfolio’s excess return
Risk adjusted returns are widely calculated using the Sharpe ratio. Returns can be saved if we add assets to a diversified portfolio which has very low correlations. This is stated in the Modern Portfolio Theory.
Sharpe ratio can be increased by adding diversification when in comparison with a similar portfolio with low level of diversification. For the above statement to be valid we have to make an assumption that the risk is equal to the volatility, although this isn’t unreasonable but it’s too niche for application in all sorts of investment.
It can also be used to evaluate a portfolio’s past performance and actual returns are used in the formula. Expected risk-free rate and expected portfolio performance can be used by an investor to calculate an estimated Sharpe ratio.
2.7.7 Sortino Ratio
The Sortino ratio is a variation of the Sharpe ratio that differentiates harmful volatility from total overall volatility by using the asset’s standard deviation of negative portfolio returns, called downside deviation, instead of the total standard deviation of portfolio returns.
The Sortino ratio takes an asset or portfolio’s return and subtracts the risk-free rate, and then divides that amount by the asset’s downside deviation.
Sortino Ratio= (Rp−rf) / σd
Where:
Rp=Actual or expected portfolio return
rf=Risk-free rate
σd=Standard deviation of the downside
The Sortino ratio is a useful way for investors, analysts, and portfolio managers to evaluate an investment’s return for a given level of bad risk. Since this ratio uses only the downside deviation as its risk measure, it addresses the problem of using total risk, or standard deviation, which is important because upside volatility is beneficial to investors and isn’t a factor most investors worry about.
METHODOLOGY
3.1 Introduction
For forecasting the net asset value of fund various mathematical models were considered. Support Vector Regression showed promising result with the least mean squared error. SVR lies in the category of supervised machine learning model.
3.2 Modelling
The first step required selecting features which affected the NAV value of the funds considerably. This was done by performing exploratory data analysis (EDA) as mentioned in the previous section.
The required data for these features was collected from various government sites. The data was pre-processed according to our requirement.
The data set was eventually split into two sets. The training set and test set with the test size being 0.1.
The data set consisted of a total of 72 number of data points.
For evaluation of models the metric used is mean absolute error.
3.3 Support Vector Machine (SVM)
The objective of the support vector machine algorithm is to find a hyper plane in an N-dimensional space (N — the number of features) that distinctly classifies the data points.
Figure 3.1: Possible Hyper planes
To separate the two classes of data points, there are many possible hyper planes that could be chosen. Our objective is to find a plane that has the maximum margin, i.e. the maximum distance between data points of both classes. Maximizing the margin distance provides some reinforcement so that future data points can be classified with more confidence.
3.3.1 Hyper planes and Support Vectors
Hyper planes are decision boundaries that help classify the data points. Data points falling on either side of the hyper plane can be attributed to different classes. Also, the dimension of the hyper plane depends upon the number of features. If the number of input features is 2, then the hyper plane is just a line. If the number of input features is 3, then the hyper plane becomes a two-dimensional plane. It becomes difficult to imagine when the number of features exceeds 3.
Figure 3.2: Hyper planes for 2-D and 3-D feature space
Support vectors are data points that are closer to the hyper plane and influence the position and orientation of the hyper plane. Using these support vectors, we maximize the margin of the classifier. Deleting the support vectors will change the position of the hyper plane. These are the points that help us build our SVM.
Figure 3.3: Support Vectors
3.3.2 Large Margin Intuition
In logistic regression, we take the output of the linear function and squash the value within the range of using the sigmoid function. If the squashed value is greater than a threshold value we assign it a label 1, else we assign it a label 0. In SVM, we take the output of the linear function and if that output is greater than 1, we identify it with one class and if the output is -1, we identify is with another class. Since the threshold values are changed to 1 and -1 in SVM, we obtain this reinforcement range of values ([-1, 1]) which acts as margin.
3.3.3 Cost Function and Gradient Updates
In the SVM algorithm, we are looking to maximize the margin between the data points and the hyper plane. The loss function that helps maximize the margin is hinge loss
Hinge loss function (function on left can be represented as a function on the right)
The cost is 0 if the predicted value and the actual value are of the same sign. If they are not, we then calculate the loss value. We also add a regularization parameter the cost function. The objective of the regularization parameter is to balance the margin maximization and loss. After adding the regularization parameter, the cost functions looks as below.
Loss Function of SVM
Now that we have the loss function, we take partial derivatives with respect to the weights to find the gradients. Using the gradients, we can update our weights.
Gradients
When there is no misclassification, i.e. our model correctly predicts the class of our data point, we only have to update the gradient from the regularization parameter.
Gradient update – no misclassification
When there is a misclassification, i.e. our model make a mistake on the prediction of the class of our data point, we include the loss along with the regularization parameter to perform gradient update.
Gradient update – misclassification
3.4 Identification of bear and bull phase
We have identified 3 technical indicators which would assist in identifying the phase of the market. The technical indicators are MACD, stochastic oscillator and MACD histogram.
The identification would be based on a point system. Where each indicator is assigned a value 1 if it changes its state and value 0 if it remains in the same state. The time axis is flagged if 2 or more indicators have value 1. Thus the time axis is divided into various sections accordingly based on the above rule.
The sections are then categorised as bear or bull based on the slope of the BSE S&P 500 index where a positive slope indicates bull state and a negative slope indicates bear state.
3.5 Performance Analysis
The performance analysis will be done by employing various measures. These measures are mathematical ratios which gives us various insights about the funds. They would be evaluated using Python and Microsoft Excel. The funds would be categorised on the basis of their portfolios into large, mid, small, debt and ETF. The evaluation would be done for bear and bull phase separately. The aim is to identify key characteristics in these respective phases.
3.6 Evaluation of Standard Deviation and Downside deviation
Standard deviation and downside deviation are one of the most sought after performance measures while evaluating a funds or a portfolios performance. The evaluation of these measures was done on Microsoft Excel.
For the evaluation of standard deviation, the daily NAV values of the fund in question were collected. The next step involved finding daily returns of these NAV values. Then standard deviation of the daily returns was calculated. The deviation now calculated is daily and not annualised. For comparing and interpreting the deviation daily deviation isn’t appreciated. Thus the daily standard deviations are multiplied by the total number of trading days in a year. The final value obtained is the annualised standard deviation.
Downside deviation is another measure which was calculated. It is similar to standard deviation but only those values which contribute to negative volatility are considered. For this the daily return column of the NAV values is amended. Only values which are above the average of the total returns in a period are considered. Then standard deviation of these values are calculated and multiplied by the total number of trading days which is 252. This gives us annualised downside deviation.
3.7 Tools Used
The model has been implemented on Google Colab using Python Script. The various libraries which were used are:
1. Pandas: It is an open source Python package that provides numerious tools for data analysis. It helps in organizing and manipulating the data by putting it in a tabular form.
2. Numpy: It is an open source numerical python library which contains multi-dimensional array and matrix data structures.
3. Scikit-Learn: It is a python module for machine learning. The sklearn library contains a lot of efficient tools for machine learning and statistical modelling including classification, regression, clustering and dimensionality reduction. Some examples are support vector machines, random forests, gradient boosting, k-means and DBSCAN, which are designed to interoperate with the Python numerical and scientific libraries NumPy and SciPy.
4. Seaborn: Seaborn is a library for creating more attractive and informative statistical graphics in python.
5. Matplotlib: It is a comprehensive library for creating static, animated, and interactive visualizations in Python.
RESULT ANALYSIS
4.1 Introduction
We looked into certain economic indicators which we believed had an impact on the financial market. To support our hypothesis we performed exploratory data analysis on each economic indicator. The indicators which passed this initial test were then used as features in various mathematical models forecasting the net asset value. Throughout the analysis report Net Asset value would be referred as NAV.
4.2 Exploratory Data Analysis (EDA)
4.2.1 Scatter Plots
● NAV v/s Date
20
Figure 4.1: NAV v/s Date (year)
This is a plot of NAV V/S Date on which they were recorded. For each year, data points from left to right denote January to December respectively. The fund used in this study is ICICI Prudential Bluechip Fund. The NAV in its entirety shows an increasing trend through the years. The Years 2017 and 2015 were remarkable in terms of growth whereas the year 2016 didn’t perform up to the expectations. This graph proves the fact that a patient investor would surely reap rewards if they could wait out the volatility of the market and stay invested for longer periods.
● NAV v/s CPI (Consumer Price Index)
Figure 4.2: NAV v/s CPI
This is a plot of NAV against Consumer Price Index (CPI). The data points in this graph align themselves to form a straight line with a steep slope, indicating that a small increase in the CPI value leads to large increase in the value of NAV. CPI has always been used to determine the inflation rate. In accordance with the theory Paradox of thrift an increase in the CPI value or inflation rates need not necessarily mean that the purchasing power of the money has gone down. A controlled increased in inflation rate indicates that the demand has increased in the country and thus in turn affect the productivity which helps the citizens to get more work and thus earn and save more.
● NAV v/s BSE Sensex Index
Figure 4.3: NAV v/s BSE Sensex Index
This plot is of NAV v/s BSE Sensex index. One of our null hypothesis was that there is no correlation between the benchmark index and the NAV value but this plot proves our null hypothesis right. The two features have a linear relation with slope almost equal to 1 thus indicating a strong correlation between them.
● NAV v/s 10 year Bond and NAV v/s 5 year bond
This is a plot of NAV against 10 and 5 year treasury bonds. This features were primarily chosen to establish a relation between the debt and equity market. From the plots we could observe that there is a hyperbolic curve formation. The yield rates of these bonds keep oscillating between two extreme values with majority of data points concentrated at 7.5%.
● Export and Import
Figure 4.6: NAV v/s Export Figure 4.7: NAV v/s Import
This is a plot of NAV against total export and import of goods. Since the data is calculated yearly we had to extrapolate the data to calculate these data for each month. We made an assumption that the import and export of goods is equal throughout the 12 months. After observing the plot we could see that there is no direct correlation between these 2 values because for a given import or export value there exists multiple values of NAV. Thus this feature has to be discarded for the prediction model.
4.2.2 Distribution Plots
1. NAV
23
Figure 4.8: NAV distribution plot
This is distribution plot for net asset value. The graph indicates that the mode for the fund chosen for study had an NAV value of 30.
2. 5 – Year Bond (Treasury Bond)
Figure 4.9: 5 year bond distribution plot
The mode of 5 year bond is around 8%. This asserts our assumption that although debt bonds are theoretically risk free investments there isn’t any scope of gaining exceptional returns and thus they can be used as a liquidity option in an investor’s portfolio.
3. 10 – Year Bond (Treasury Bond)
Figure 4.10: 10 year bond distribution plot
The same analysis applies to the 10 year bonds. The mode of 5 year bond is around 8%. This asserts our assumption that although debt bonds are theoretically risk free investments there isn’t any scope of gaining exceptional returns and thus they can be used as a liquidity option in an investor’s portfolio.
4.3 Accuracy of models
The performance metric used was mean absolute error and the various models tested for predicting the NAV values were
● SVR (Support Vector Regressor)
● LSVR (Linear Support Vector Regressor)
● RF (Random Forest Regressor)
● Linear Regression
● SGD (Stochastic Gradient Descent)
● MLP (Multi-Layer Perceptron)
Models
Funds
SVR LSVR RF LR SGD MLPR
| Cannara Robeco Bluechip fund 0.246 0.245 0.153 0.222 0.557 | 0.331 |
| ICICI Prudential Bluechip Fund 0.255 0.283 0.227 0.259 0.561 | 0.311 |
| SBI Focused Equity 0.314 0.665 0.403 0.798 0.690 | 0.309 |
| DSP Tax Saver Fund 0.274 0.365 0.381 0.351 0.567 | 0.364 |
| Axis Long Term Equity Fund 0.264 0.610 0.309 0.682 0.617 | 0.416 |
| Mirae Asset Emerging Bluechip Fund 0.245 0.325 0.351 0.439 0.542 | 0.547 |
| Standard Deviation 0.025 0.177 0.096 0.233 0.055 | 0.091 |
Average 0.266 0.415 0.304 0.458 0.589 0.379 Table 4.1: Mean absolute errors of different funds and different models
The models were tested across various funds so as to reduce any ambiguity in the result. From table 1 we can observe that Support Vector Regressor had the least mean absolute error even when compared with different models. The standard deviation for SVR was also found out to be the least when compared to other models thus indicating a consistent performance compared to its peers.
Thus we can conclude that amongst all the models Support Vector Regressor (SVR) had the best performance. Since ‘0’ mean absolute error is the theoretical value for a model to be 100% efficient a SVR reading of 0.025 indicates that it is optimal for forecasting NAV values.
4.4 Bear and Bull phase identification
After applying the technical indicators to the BSE S&P 500 index we have identified 4 such cycles in the period starting from 1st April 2004 to 21st May 2020.
The average duration of bear phase in this period = 568 days
The average duration of bull phase in this period = 755.25 days
Figure 4.11: Bear and Bull phases (bear are colour coded as red and bull as green)
The identified period are:
• Bear Cycle
C1 – 03 Dec ‘07 – 02 Mar ‘09
C2 – Oct ‘10 – 02 Jan ‘12
C3 – Nov ‘14 – 01 Mar ‘16
C4 – Jan ‘18 – 21 May ‘20
• Bull Cycle
D1 – 01 Apr 04 – 03 Dec ‘07
D2 – 02 Mar 9 – 01 Oct ‘10
D3 – 02 Jan 12 – 03 Nov ‘14
D4 – 01 Mar 16 – 01 Jan ‘18
4.5 Rate of return comparison
The rate of return of funds from different categories was evaluated. The returns were as expected and followed the notion of funds performing better in bull phase compared to bear phase.
Category Fund Bear Phase Bull Phase
| C1 | C2 | C3 | C4 | D1 | D2 | D3 | D4 | ||
| Large Cap | ICICI Prudential Bluechip | NA | -12.7% | -7.2% | -7.2% | NA | 80.5% | 26.7% | 28.4% |
| Cannara Robeco Bluechip | NA | -10.5% | -7.2% | 0.3% | NA | NA | 24.6% | 23.6% | |
| Mid Cap | UTI Mid Cap | -52.2% | -22.9% | -1.0% | -14% | NA | 100.1% | 43.8% | 32.1% |
| Edelweiss Mid Cap | NA | -21.7% | 3.8% | -12.9% | NA | 99.6% | 39.6% | 37.5% | |
| Small Cap | HDFC Small Cap | NA | -22.7% | -2.9% | -20.3% | NA | 100.4% | 28% | 46% |
| Kotak Small Cap | -55.8% | -25.3% | 1.2% | -16.6% | NA | 94.7% | 34.4% | 36.8% | |
| ELSS | Axis Long Term Equity | NA | -11.9% | 1.5% | -1.8% | NA | NA | 37.2% | 24.7% |
| DSP Tax Saver Fund | -47.9% | -23.6% | -2.9% | -7.9% | NA | 84.4% | 32.1% | 32.8% | |
| Debt fund | HSBC Debt | 11.9% | 8.3% | 7.2% | 8.5% | 2.3% | 4.7% | 8.0% | 6.4% |
| DSP Credit Risk | 8.7% | 8.1% | 9.2% | 0.6% | 5.4% | 4.9% | 9.2% | 8.8% | |
| INDEX | S&P BSE 500 | -60.8% | -40.6% | -14.6% | -65.1% | 101.5% | 164% | 45.5% | 42.2% |
Gold ETF Axis Gold ETF NA NA 11.65% 21.3% NA NA -3.08% -9.89% Table 4.2: Rate of return table for bull and bear cycle
We could infer from the above table that mutual funds are a safe investment tool and provides an investor with extra downside protection. During the bear phase although the market returns were exceptionally low the funds performed relatively better. The funds taken into consideration here are active funds and thus it implies that the fund managers of respective funds have implemented certain strategies to reduce the downside risk. This also proves that investors with less risk appetite can still invest in the market through these funds.
On the other hand these funds have managed to not beat the market returns consistently over the bull period. The downside protection witnessed during the bear phase comes at a cost and this is evident from the bull section of the table. The return of these funds do not deviate significantly from market returns thus a passive investor could still reap benefits along with the downside protection for if the market shifts into bear phase.
While analysing the debt fund row it is evident that the returns are almost constant for both bull and bear phase. Debt funds are regarded as the safest option for investment and these results do prove this fact. These type of funds should be used if the investment horizon is short term. Thus assisting in growing the investment and warding off unnecessary risks.
12-14
14-16 16-18 18-20
Figure 4.12: Axis Gold ETF and S&P 500 returns in four cycles
Exchange traded funds are also referred to as Index funds which are listed and traded as stocks. We have compared the Axis Gold ETF with the market returns. A Gold ETF tracks the price of the Gold and is traded on the stock market.
We can observe that the Gold ETF has negative correlation with the market returns. During the bear phase it shows significant positive returns and vice versa in the bull phase. This is because during a bear cycle investors lose trust in the market and they shift their investments into commodities which they feel would give them consistent returns. The demand for gold has existed for centuries and thus these investors feel safe in rearranging their portfolios in favour of debt and gold funds. This leads to an artificial demand for the commodity thus increasing its value. The vice versa happens when the market goes through a bull phase. As the market returns increase the investors flood the stock markets again since the demand decreases the price of the commodity also decreases.
4.6 Performance Measure Analysis
4.6.1 Jensen’s Alpha
| Fund | Bear Phase Bull Phase |
| 14-16 18-20 12-14 16-18 | |
| DSP Credit Risk Fund | 1.42 -6.61 0.84 1.56 |
| HDFC Small Cap Fund | -5.97 -13.55 18.83 37.29 |
| Kotak Small Cap Fund | -2.02 -9.84 23.27 23.83 |
| Axis Long Term Equity Fund | -2.26 9.03 28.89 14.01 |
| Axis Gold ETF | 1.17 15.89 -8.10 -19.73 |
| ICICI Prudential Bluechip Fund | -10.56 -3 17.93 19.8 |
| Canara Robeco Bluechip Fund | -10.56 3.35 13.95 14.58 |
Table 4.3 Jensen’s alpha of funds in bull and bear phase
A positive alpha indicates that the fund or portfolio has performed better than the expected return calculated using the CAPM (Capital Asset Pricing Mode).
Small cap and mid cap funds had large positive alpha during the bull phase on an average when compared to the large cap funds. This could be attributed to the fact that small cap and mid cap funds are riskier and have greater volatility thus they were rewarded during the bull phase although the difference in returns between the two categories isn’t too significant.
On the other hand during bear phase the small and mid-cap funds have large negative coefficients whereas large cap funds continue to have positive alphas. Thus we can infer that even though the market isn’t performing well, large cap funds have exceeded or are close to the expected returns because they are less risky and volatile.
The alpha coefficient for debt funds was almost negligible. Thus indicating that this category of fund does not deviate much from the expected returns in either direction which in turn makes them a safe bet for short term investment.
The general trend which can be noted here is that the funds tend to have positive and higher Jensen’s alpha during the bull phase and negative or lower coefficient during the bear phase.
4.6.2 Treynor’s Ratio
| Fund | Bear Phase Bull Phase |
| 14-16 18-20 12-14 16-18 | |
| DSP Credit Risk Fund | 10.62 65.86 63.77 3.11 |
| HDFC Small Cap Fund | -0.41 -0.55 18.20 11.96 |
| Kotak Small Cap Fund | -0.26 -0.47 7.19 2.73 |
| Axis Long Term Equity Fund | -0.28 -0.14 -980.10 2.60 |
| Axis Gold ETF | -0.26 0.22 2.48 -3.16 |
| ICICI Prudential Bluechip Fund Canara Robeco Bluechip Fund | -0.53 -0.20 6.13 2.68 -0.53 -0.11 1.01 1.67 |
Table 4.4: Treynor’s Ratio values of funds in bull and bear phase
A higher ratio indicates that the fund or portfolio has performed better compared to its peers. This ratio cannot be used to compare funds of different categories because the market risk pertaining to each category is different.
While analysing the funds it became evident that ICICI Prudential Bluechip fund has performed better compared to its peers and has provided with better returns per unit in relation to the market. Furthermore, the index used for large cap funds was BSE S&P 500. In the mid cap and small categories Edelweiss mid cap fund and HDFC small cap fund have performed better compared to their peers respectively. Moreover, the index in question for mid and small cap funds are NIFTY AUTO and NIFTY small cap 100.
Across all the categories the general trend observed is that the funds tend to have positive and higher Treynor’s ratio during the bull phase and negative or lower ratio during the bear phase.
4.6.3 Sharpe Ratio
| Fund | Bear Phase Bull Phase |
| 14-16 18-20 12-14 16-18 |
31
| DSP Credit Risk Fund | 1.57 -1.64 0.88 1.62 |
| HDFC Small Cap Fund | -0.63 -1.49 1.38 3.02 |
| Kotak Small Cap Fund | -0.40 -1.32 1.79 2.47 |
| Axis Long Term Equity Fund | -0.42 -0.44 2.17 1.63 |
| Axis Gold ETF | 0.30 1.07 -0.66 -1.43 |
ICICI Prudential
Bluechip Fund-0.93 -0.68 1.3 1.85
Canara Robeco
Bluechip Fund-0.86 -0.34 1.09 1.40
Table 4.5: Sharpe Ratio values of funds in bull and bear phase
Bear Phase Bull Phase
| Large Cap | -0.7025 1.41 |
| Mid Cap | -2.72 2.235 |
Small Cap -0.9595 2.15
Table 4.6: Average Sharpe values
Unlike Treynor’s ratio Sharpe ratio can be used to compare funds amongst categories. A higher ratio is desirable when comparing two entities.
During bull phase the small and large cap funds seem to have the upper hand when discussing the excess returns earned per total unit risk of the portfolio. This goes on to support the fact that if the markets are timed an investor can generate excess returns.
But during the bear phase their lies a significant risk to lose almost all of their portfolios value. The mid cap funds considered in this analysis have larger negative Sharpe values indicating that they have performed poorly when compared to risk free returns. Large cap funds have performed satisfactorily and have held their ground during the bear cycle but even then they have performed slightly poorer when compared to risk free assets. Debt fund’s portfolio mostly consists of risk free securities and assets and this can be asserted from our findings because the Treynor’s ratio is mostly small and positive. Across all the categories the general trend observed is that the funds tend to have positive and higher Sharpe ratio during the bull phase and negative or lower ratio during the bear phase.
4.6.4 Sortino Ratio
| Fund | Bear Phase Bull Phase |
| 14-16 18-20 12-14 16-18 | |
| DSP Credit Risk Fund | 1.13 -1.01 0.82 1.49 |
| HDFC Small Cap Fund | -0.64 -1.59 1.99 3.69 |
| Kotak Small Cap Fund | -0.42 -1.40 2.47 3.14 |
| Axis Long Term Equity Fund | -0.44 -0.51 3.11 2.25 |
Axis Gold ETF
0.21 1.76 -0.94 -2.23
ICICI Prudential
Bluechip Fund-0.92 -0.71 1.96 2.85
Canara Robeco
Bluechip Fund-0.93 -0.39 1.64 1.88
Table 4.7: Sortino Ratio values of funds in bull and bear phase
Sortino ratio is similar to Sharpe ratio but it does not punish positive volatility. Thus the inference from the Sharpe ratio should be similar to that of Sortino ratio and it does turn out to be the same but during bull phase the results deviate more towards the positive axis from Sharpe ratio and remain almost constant during the bear phase. Small cap and mid cap funds have shown greater positive volatility as its deviation from the Sharpe ratio is maximum. The result eradicates the stigma about small cap funds being a risky investment to an extent. If the
33
markets are timed well the volatility of the small cap funds can be used to earn greater returns.
4.6.5 Gold Exchange Traded Fund (ETF) Analysis
The gold ETF has negative correlation with the general trends. The negative correlation could be attributed to the fact that the investors look for other options when the market isn’t performing well or vice versa. They rely back on their traditional ideology of gold being a safe investment. This herd mentality results in this negative correlation during the change of cycles. The Jensen’s alpha for Gold ETFs aren’t exceptional thus indicating that they don’t deviate much from the expected values. The volatility for this particular category is very low thus indicating towards stability. The returns are almost always good compared to other assets thus making Gold ETF’S a good choice for investment.
4.6.6 Beta values, Standard deviation and downside deviation
| Fund | Bear Phase Bull Phase |
| 14-16 18-20 12-14 16-18 | |
| DSP Credit Risk Fund | 0.0013 -0.001 0.0002 0.0061 |
| HDFC Small Cap Fund | 0.26 0.50 0.01 0.03 |
| Kotak Small Cap Fund | 0.25 0.50 0.04 0.11 |
| Axis Long Term Equity Fund Axis Gold ETF | 0.22 0.65 0.00 0.07 -0.15 0.06 -0.04 0.05 |
| ICICI Prudential Bluechip Fund0.28 0.7 0.03 0.08 Canara Robeco Bluechip Fund0.28 0.63 0.16 0.10 |
Table 4.8 Beta values of funds in bull and bear phase
| Fund | Bear Phase Bull Phase |
| 14-16 18-20 12-14 16-18 | |
| DSP Credit Risk Fund | 0.89% 4% 1.58% 1.17% |
| HDFC Small Cap Fund | 16.86% 18.43% 14.69% 12.95% |
| Kotak Small Cap Fund | 17% 18% 15% 12% |
| Axis Long Term Equity Fund 15% 20% 14% 11% Axis Gold ETF13% 13% 17% 12% ICICI Prudential Bluechip Fund16.19% 20.95% 14.12% 11.58% Canara Robeco Bluechip Fund17.3% 19.84% 14.92% 11.9% |
Table 4.9 Standard Deviation of funds in bull and bear phase
| Fund | Bear Phase Bull Phase |
| 14-16 18-20 12-14 16-18 | |
| DSP Credit Risk Fund | 1,24% 6.54% 1.71% 1.27% |
| HDFC Small Cap Fund | 16.66% 17.3% 10.14% 10.6% |
| Kotak Small Cap Fund | 15.17% 16.93% 10.78% 9.52% |
| Axis Long Term Equity Fund | 14.31% 17.68% 9.45% 7.91% |
| Axis Gold ETF | 18% 8% 12% 8% |
| ICICI Prudential Bluechip Fund | 16.13% 18.16% 9.37% 7.52% |
| Canara Robeco Bluechip Fund | 15.86% 17.84% 9.84% 8.87% |
Table 4.10 Downside Deviation of funds in bull and bear phase
CONCLUSION AND FUTURE SCOPE OF WORK
5.1 Conclusion
It is a preconceived notion that markets are largely inefficient. If this wasn’t the case then there wouldn’t have been any opportunity to make profits more than the benchmark indexes. The mutual fund industry breeds on this notion of inefficient markets and has been consistently able to have better odds compared to its other competitors. Although this is true till a certain extent in developing or emerging markets the same couldn’t be said about developed markets. Thus predicting future worth of these markets is comparatively harder as almost all the data is public and is quickly realised or reflected in the stock prices.
Thus the prediction models would have a better risk to reward ratio when applied to emerging or developing markets. With the help of this project we were able to identify features and models which would help in predicting these values to an extent so that an investor could make an informed decision. Models such as Random forest regressor and Support vector regressor showed positive results in predicting compared to its peers.
Timing the market is only the first step towards earning greater profits or returns. The investor should also be smart enough to invest money in a diverse portfolio. Which could be created by analysing the performance of the funds in different phases. We have generated a general guideline as to what an investor should look for while investing and creating their portfolio so as to maximise his or her gains.
5.2 Future Scope
There is lot of scope for improvement in the research for evaluating mutual fund performances. Various other multi-criteria decision models could be tested for evaluating mutual fund performances. The size of the data can be increased in order to enhance the performance of the models. Although MF market is too young but in the long run testing of fund performances can be made. Portfolio risk through the measure of value at risk (VaR) can also be tested for differences in mutual fund classes.
Furthermore, the buying behaviour of mutual funds of individual investors can also be studied. Various attributes can be identified that investors consider important while investing in a mutual fund.
How Do You Forecast Mutual Fund Performance? Written by Raghav Sharma

REFERENCES for How Do You Forecast Mutual Fund Performance?
1. Panwar, S., & Madhumathi, R. (2006). “Characteristics and Performance Evaluation of Selected Mutual Funds in India”. SSRN Electronic Journal. doi:10.2139/ssrn.876402 2. William F. Sharpe “Mutual Fund Performance”, The Journal Of Business, Vol. 39, No.1, Part
2. Supplement on Security Prices(Jan 1996), pp. 119-138 2: Supplement on Security Prices(Jan 1996), pp. 119-138
3. Kanojia, S., & Arora, N. (2017). Investments, Market Timing and Portfolio Performance across Indian Bull and Bear Markets. Asia-Pacific Journal of Management Research and Innovation, 13(3-4), 98–109. doi:10.1177
4. Estimating Turning Points Using Large Data Sets James H. Stock and Mark W. Watson NBER Working Paper No. 16532 November 2010
5. Kole, E., & van Dijk, D. (2016). How to Identify and Forecast Bull and Bear Markets? Journal of Applied Econometrics, 32(1), 120–139. doi:10.1002/jae.2511
6. Chiang, W.-C., Urban, T. L., & Baldridge, G. W. (1996). A neural network approach to stock value forecasting. Omega, 24(2), 205–215.
7. Indro, D. C., Jiang, C. X., Patuwo, B. E., & Zhang, G. P. (1999). Predicting mutual fund performance using artificial neural networks.
ANNEXURES
Code:
1) Importing libraries
import pandas as pd
import numpy as np
import sklearn
import matplotlib.pyplot as plt
import matplotlib
import seaborn as sns
from sklearn.model_selection import train_test_split
from sklearn.preprocessing import StandardScaler
from sklearn.svm import SVR, LinearSVR
from sklearn.ensemble import RandomForestRegressor
from sklearn.linear_model import LinearRegression, SGDRegressor
from sklearn.neural_network import MLPRegressor
from sklearn.metrics import mean_absolute_error, mean_squared_log_error
2) Pre-processing
df_mirae = pd.read_excel(‘Mirae Asset Emerging Bluechip Fund.xlsx’) df_mirae.drop(index= [0,1,2,3,4], axis = 0, inplace=True)
df_mirae.columns = [‘Date’, ‘NAV’]
for i in range(df_mirae.shape[0]):
df_mirae.iloc[i][‘Date’] = df_mirae.iloc[i][‘Date’][df_mirae.iloc[i][‘Date’].find(‘-‘)+1:] df_mirae[‘NAV’] = pd.to_numeric(df_mirae[‘NAV’])
df_mirae = df_mirae.groupby(‘Date’, as_index= False).mean()
df_sbi = pd.read_excel(‘SBI Focused Equity Fund.xlsx’)
df_sbi.drop(index= [0,1,2,3,4], axis = 0, inplace=True)
df_sbi.columns = [‘Date’, ‘NAV’]
for i in range(df_sbi.shape[0]):
df_sbi.iloc[i][‘Date’] = df_sbi.iloc[i][‘Date’][df_sbi.iloc[i][‘Date’].find(‘-‘)+1:] df_sbi[‘NAV’] = pd.to_numeric(df_sbi[‘NAV’])
df_sbi = df_sbi.groupby(‘Date’, as_index= False).mean()
39
df_dsp = pd.read_excel(‘DSP Tax Saver Fund.xlsx’)
df_dsp.drop(index= [0,1,2,3,4], axis = 0, inplace=True)
df_dsp.columns = [‘Date’, ‘NAV’]
for i in range(df_dsp.shape[0]):
df_dsp.iloc[i][‘Date’] = df_dsp.iloc[i][‘Date’][df_dsp.iloc[i][‘Date’].find(‘-‘)+1:] df_dsp[‘NAV’] = pd.to_numeric(df_dsp[‘NAV’])
df_dsp = df_dsp.groupby(‘Date’, as_index= False).mean()
df_axis = pd.read_excel(‘Axis Long Term Equity Fund.xlsx’)
df_axis.drop(index= [0,1,2,3,4], axis = 0, inplace=True)
df_axis.columns = [‘Date’, ‘NAV’]
for i in range(df_axis.shape[0]):
df_axis.iloc[i][‘Date’] = df_axis.iloc[i][‘Date’][df_axis.iloc[i][‘Date’].find(‘-‘)+1:] df_axis[‘NAV’] = pd.to_numeric(df_axis[‘NAV’])
df_axis = df_axis.groupby(‘Date’, as_index= False).mean()
df_icici = pd.read_excel(‘ICICI Prudential Bluechip.xlsx’)
df_icici.drop(index= [0,1,2,3,4], axis = 0, inplace=True)
df_icici.columns = [‘Date’, ‘NAV’]
for i in range(df_icici.shape[0]):
df_icici.iloc[i][‘Date’] = df_icici.iloc[i][‘Date’][df_icici.iloc[i][‘Date’].find(‘-‘)+1:] df_icici[‘NAV’] = pd.to_numeric(df_icici[‘NAV’])
df_icici = df_icici.groupby(‘Date’, as_index= False).mean()
df_5_bond = pd.read_excel(‘5 year bond yield.xlsx’)
df_5_bond.drop(labels= [‘Price’, ‘High’, ‘Low’, ‘Change %’], inplace=True, axis=1) df_5_bond[‘Date’] = df_5_bond[‘Date’].astype(‘str’)
date = []
for i in range(df_5_bond.shape[0]):
date.append(df_5_bond.iloc[i][‘Date’][:df_5_bond.iloc[i][‘Date’].find(‘-‘)+1] + ’20’ + df_5_bo nd.iloc[i][‘Date’][df_5_bond.iloc[i][‘Date’].find(‘-‘)+1:])
df_5_bond[‘Date’] = date
df_10_bond = pd.read_csv(’10 Year Bond.csv’)
df_10_bond = df_10_bond[[‘Date’, ‘Open’]]
month_to_num = {‘Jan’: ’01’, ‘Feb’: ’02’, ‘Mar’: ’03’, ‘Apr’: ’04’, ‘May’: ’05’, ‘Jun’: ’06’, ‘Jul’: ’07’, ‘ Aug’: ’08’, ‘Sep’: ’09’, ‘Oct’: ’10’, ‘Nov’: ’11’, ‘Dec’: ’12’}
date = []
for i in range(df_10_bond.shape[0]):
date.append(month_to_num[df_10_bond.iloc[i][‘Date’][:df_10_bond.iloc[i][‘Date’].find(‘-‘)]] + df_10_bond.iloc[i][‘Date’][df_10_bond.iloc[i][‘Date’].find(‘-‘):])
df_10_bond[‘Date’] = date
date = []
for i in range(df_10_bond.shape[0]):
date.append(df_10_bond.iloc[i][‘Date’][:df_10_bond.iloc[i][‘Date’].find(‘-‘)+1] + ’20’ + df_10 _bond.iloc[i][‘Date’][df_10_bond.iloc[i][‘Date’].find(‘-‘)+1:])
df_10_bond[‘Date’] = date
df_expimp = pd.read_excel(“Emport_Import.xlsx”)
df_expimp[‘DATE’] = df_expimp[‘DATE’].astype(‘str’)
date = []
for i in range(df_expimp.shape[0]):
date.append(df_expimp.iloc[i][‘DATE’][:len(df_expimp.iloc[i][‘DATE’])-3]) df_expimp[‘DATE’] = date
date = []
for i in range(df_expimp.shape[0]):
date.append(df_expimp.iloc[i][‘DATE’][df_expimp.iloc[i][‘DATE’].find(‘-‘)+1:] + ‘-‘ + df_ex pimp.iloc[i][‘DATE’][:df_expimp.iloc[i][‘DATE’].find(‘-‘)])
df_expimp[‘DATE’] = date
df_expimp.rename(columns={‘DATE’: ‘Date’}, inplace=True)
df_cpi = pd.read_excel(‘consumer price index.xlsx’)
df_cpi[‘date’] = df_cpi[‘date’].astype(‘str’)
date = []
for i in range(df_cpi.shape[0]):
date.append(df_cpi.iloc[i][‘date’][:len(df_cpi.iloc[i][‘date’])-3])
df_cpi[‘date’] = date
date = []
for i in range(df_cpi.shape[0]):
date.append(df_cpi.iloc[i][‘date’][df_cpi.iloc[i][‘date’].find(‘-‘)+1:] + ‘-‘ + df_cpi.iloc[i][‘date’] [:df_cpi.iloc[i][‘date’].find(‘-‘)])
df_cpi[‘date’] = date
df_cpi.columns = [‘Date’, ‘CPI’]
df_bse = pd.read_csv(‘BSE Sensex.csv’)
date = []
for i in range(df_bse.shape[0]):
date.append(month_to_num[df_bse.iloc[i][‘Date’][df_bse.iloc[i][‘Date’].find(‘-‘)+1:df_bse.ilo c[i][‘Date’].find(‘-‘)+4]] +df_bse.iloc[i][‘Date’][df_bse.iloc[i][‘Date’].find(‘-‘)+4:]) df_bse[‘Date’] = date
date = []
for i in range(df_bse.shape[0]):
date.append(df_bse.iloc[i][‘Date’][:df_bse.iloc[i][‘Date’].find(‘-‘)+1] + ’20’ + df_bse.iloc[i][‘D ate’][df_bse.iloc[i][‘Date’].find(‘-‘)+1:])
df_bse[‘Date’] = date
df_bse[‘Close’] = pd.to_numeric(df_bse[‘Close’])
df_bse = df_bse.groupby(‘Date’, as_index=False).mean()
df_gdp = pd.read_csv(‘gdp.csv’)
41
df_gdp.drop(labels= [‘Unnamed: 2’, ‘Unnamed: 3’, ‘Unnamed: 4’, ‘Unnamed: 5’, ‘Unnamed: 6’, ‘Unnamed: 7’, ‘Unnamed: 8’, ‘Unnamed: 9’], inplace=True, axis=1)
df_gdp.rename(columns={‘DATE’: ‘Date’}, inplace=True)
df_3 = df_2.join(df_5_bond.set_index(‘Date’), on = ‘Date’)
df_4 = df_3.join(df_10_bond.set_index(‘Date’), on = ‘Date’)
df_5 = df_4.join(df_gdp.set_index(‘Date’), on = ‘Date’)
df_final_axis = df_5.join(df_axis.set_index(‘Date’), on = ‘Date’)
df_final_canara = df_5.join(df_canara.set_index(‘Date’), on = ‘Date’)
df_final_dsp = df_5.join(df_dsp.set_index(‘Date’), on = ‘Date’)
df_final_mirae = df_5.join(df_mirae.set_index(‘Date’), on = ‘Date’)
df_final_sbi = df_5.join(df_sbi.set_index(‘Date’), on = ‘Date’)
df_final_icici = df_5.join(df_icici.set_index(‘Date’), on = ‘Date’)
3) Modeling
X, Y = df_final_canara[[‘GDP’, ‘CPI’, ‘Close’, ‘Open’, ‘Open_10’]], df_final_canara[[‘NAV’]] X_train, X_test, Y_train, Y_test = train_test_split(X, Y, test_size = 0.1, random_state = 42) ss_x = StandardScaler()
ss_y = StandardScaler()
ss_x.fit(X_train)
ss_y.fit(Y_train)
x_train = (ss_x.transform(X_train))
x_test = (ss_x.transform(X_test))
y_train = ss_y.transform(Y_train)
y_test = ss_y.transform(Y_test)
svr = SVR()
svr.fit(x_train, y_train)
print(mean_absolute_error((svr.predict(x_test)),(y_test)))
lsvr = LinearSVR()
lsvr.fit(x_train, y_train)
print(mean_absolute_error((lsvr.predict(x_test)), (y_test)))
rf = RandomForestRegressor()
rf.fit(x_train, y_train)
print(mean_absolute_error((rf.predict(x_test)), (y_test)))
lr = LinearRegression()
lr.fit(x_train, y_train)
print(mean_absolute_error((lr.predict(x_test)), (y_test)))
sgd = SGDRegressor()
sgd.fit(x_train, y_train)
print(mean_absolute_error((sgd.predict(x_test)), (y_test)))
nn = MLPRegressor()
nn.fit(x_train, y_train)
print(mean_absolute_error((nn.predict(x_test)), (y_test)))
Written by Raghav Sharma
How Do You Forecast Mutual Fund Performance?



