10.12.2019 Views

Python for Finance

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Chapter 11

#

sum=0.0

for i in np.arange(m):

sum+=ret2[i]

ret3=sum/m

ES=position*ret3

print("Holding=",position, "Expected Shortfall=", round(ES,4),

"tomorrow")

('m=', 12)

('Holding=', 26503.070499999998, 'Expected Shortfall=', -1105.1574,

'tomorrow')

Since there are 11 returns are less the 12th returns, the expected shortfall will be the

average of those 12 returns times our portfolio market value on the evaluation day:

Appendix A – data case 7 – VaR estimation for

individual stocks and a portfolio

There are three objectives of this dataset:

• Understand the concepts and methodology related to a VaR

• Estimate a VaR for individual stocks

• Estimate a VaR for a portfolio

The question is: What are your VaRs for each stock and for an equal-weighted

portfolio over 10 days for a 99% confidence interval? Assume that the data period is

from February 7, 2012 to February 7, 2017 and you have a $1m investment (position

in Equation 1):

i Company name Ticker Industry

1 Microsoft Corporation MSFT Application software

2 Apple Inc. AAPL Personal computer

3 Home Depot, Inc. HD Home improvement services

4 Citigroup Inc. C Money Center Banks

5 Wal-Mart Stores, Inc. WMT Discount, variety stores

6 General Electric Corporation GE Technology

The concrete steps are given here:

1. Retrieve the daily data from Yahoo! Finance.

2. Estimate the daily returns.

[ 415 ]

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!