Search icon
Arrow left icon
All Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletters
Free Learning
Arrow right icon
Python for Finance

You're reading from  Python for Finance

Product type Book
Published in Apr 2014
Publisher
ISBN-13 9781783284375
Pages 408 pages
Edition 1st Edition
Languages
Author (1):
Yuxing Yan Yuxing Yan
Profile icon Yuxing Yan

Table of Contents (20) Chapters

Python for Finance
Credits
About the Author
Acknowledgments
About the Reviewers
www.PacktPub.com
Preface
Introduction and Installation of Python Using Python as an Ordinary Calculator Using Python as a Financial Calculator 13 Lines of Python to Price a Call Option Introduction to Modules Introduction to NumPy and SciPy Visual Finance via Matplotlib Statistical Analysis of Time Series The Black-Scholes-Merton Option Model Python Loops and Implied Volatility Monte Carlo Simulation and Options Volatility Measures and GARCH Index

The put-call parity and its graphical representation


Let's look at a call with an exercise price of $20, a maturity of three months, and a risk-free rate of 5 percent. The present value of this future $20 price is calculated in the following code:

>>>x=20*exp(-0.05*3/12)   
>>>round(x,2)
19.75
>>>

In three months, what will be the wealth of our portfolio, which consists of a call on the same stock and $19.75 cash today? If the stock price is below $20, we don't exercise the call and keep the cash. If the stock price is above $20, we use our cash of $20 to exercise our call option to own the stock. Thus, our portfolio value will be the maximum of those two values, that is, the stock price in three months or $20, max(s,20).

On the other hand, how about a portfolio with a stock and a put option with an exercise price of $20? If the stock price falls below $20, we exercise the put option and get $20. If the stock price is above $20, we simply keep the stock. Thus, our...

lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $15.99/month. Cancel anytime}