FRA Main Project Part B Guided
FRA Main Project Part B Guided
Context
Investors face market risk, arising from asset price fluctuations due to economic
events, geopolitical developments, and investor sentiment changes.
Understanding and analyzing this risk is crucial for informed decision-making and
optimizing investment strategies.
Objective
The objective of this analysis is to conduct Market Risk Analysis on a portfolio of
Indian stocks using Python. It uses historical stock price data to understand
market volatility and riskiness. Using statistical measures like mean and
standard deviation, investors gain a deeper understanding of individual stocks'
performance and portfolio variability.
Through this analysis, investors can aim to achieve the following objectives:
Data Dictionary
The dataset contains weekly stock price data for 5 Indian stocks over an 8-year
period. The dataset enables us to analyze the historical performance of
individual stocks and the overall market dynamics.
Blanks '_______' are provided in the notebook that needs to be filled with an
appropriate code to get the correct result. With every '_______' blank, there is
a comment that briefly describes what needs to be filled in the blank space.
Identify the task to be performed correctly, and only then proceed to write
the required code.
Fill the code wherever asked by the commented lines like "# write your code
here" or "# complete the code". Running incomplete code may throw error.
Please run the codes in a sequential manner from the beginning to avoid any
unnecessary errors.
Add the results/observations (wherever mentioned) derived from the analysis
in the presentation and submit the same.
%matplotlib inline
import warnings
warnings.filterwarnings('ignore')
28-03-
0 86 608 867 67 514
2016
04-04-
1 86 607 863 65 519
2016
11-04-
2 85 583 853 66 506
2016
18-04-
3 87 625 900 69 515
2016
25-04-
4 89 606 880 71 532
2016
Overview of the Dataset
In [ ]: df.shape ## Complete the code to view dimensions of the data
Out[ ]: (418, 6)
<class 'pandas.core.frame.DataFrame'>
RangeIndex: 418 entries, 0 to 417
Data columns (total 6 columns):
# Column Non-Null Count Dtype
--- ------ -------------- -----
0 Date 418 non-null object
1 Dish TV 418 non-null int64
2 Infosys 418 non-null int64
3 Hindustan Unilever 418 non-null int64
4 Vodafone Idea 418 non-null int64
5 Cipla 418 non-null int64
dtypes: int64(5), object(1)
memory usage: 19.7+ KB
Date 0
Dish TV 0
Infosys 0
Hindustan Unilever 0
Vodafone Idea 0
Cipla 0
dtype: int64
2016-03-
0 86 608 867 67 514
28
2016-04-
1 86 607 863 65 519
04
2016-04-
2 85 583 853 66 506
11
2016-04-
3 87 625 900 69 515
18
2016-04-
4 89 606 880 71 532
25
Return Calculation
In [ ]: Return_of_Stocks = np.log(df.drop(['Date'],axis=1)).diff(axis = 0)
Return_of_Stocks
Out[ ]: Dish TV Infosys Hindustan Unilever Vodafone Idea Cipla
Average Returns
In [ ]: StockMeans = Return_of_Stocks.mean() ## Complete the code to get the mean f
StockMeans.sort_values()
Out[ ]: 0
Dish TV -0.003751
Infosys 0.002180
Cipla 0.002538
dtype: float64
Inference
as mentioned earlier the dips are more at the same the returns are more
with Hindustan uni lever , CIpla and Infosys.
Volatility
In [ ]: StockStdDev = Return_of_Stocks.std() ## Complete the code to get the std. d
StockStdDev.sort_values()
Out[ ]: 0
Infosys 0.036102
Cipla 0.036759
Dish TV 0.091333
dtype: float64
Inference
Dish TV -0.003751
Infosys 0.002180
Cipla 0.002538
Out[ ]: StockStdDev
Dish TV 0.091333
Infosys 0.036102
Cipla 0.036759
In [ ]: fig = plt.figure(figsize=(10,6))
ax = fig.add_subplot(111)
plt.xlabel('Volatility')
plt.ylabel('Net returns')
plt.title('Net return vs Volatility for stocks')
plt.grid()
plt.show()
Inference