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

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...