Book Image

Python for Finance

By : Yuxing Yan
Book Image

Python for Finance

By: Yuxing Yan

Overview of this book

Table of Contents (20 chapters)
Python for Finance
Credits
About the Author
Acknowledgments
About the Reviewers
www.PacktPub.com
Preface
Index

Exercises


1. What is the potential usage of matplotlib?

2. How do we install matplotlib?

3. Does the matplotlib module depend on NumPy? Does it depend on SciPy?

4. Write a Python function to generate an NPV profile with a set of input cash flows.

5. Write a Python function to download daily price time series from Yahoo! Finance.

6. We have six-year return vectors for two stocks and intend to construct a simple equal-weighted portfolio. Interpret the following Python codes and explain the result for the portfolio:

>>>A=[0.09,0.02, -0.13,0.20,-0.09,-0.03]
>>>B=[0.10,-0.3, -0.02,0.14,-0.13,0.23]
>>>C=[0.08,-0.16, 0.033,-0.24,0.053,-0.39]
>>>port_EW=(A+B)/3.

7. What is the standard deviation in terms of stock daily returns for the stocks of IBM, DELL, WMT, and C and GE in 2011?

8. How do we estimate a moving beta for a set of given tickers?

9. How do we generate a histogram in terms of daily returns for IBM? You can use five-year daily data from Yahoo! Finance.

10...