My Account Log in

2 options

Python for finance : financial modeling and quantitative analysis explained / Yuxing Yan.

Ebook Central College Complete Available online

View online

O'Reilly Online Learning: Academic/Public Library Edition Available online

View online
Format:
Book
Author/Creator:
Yan, Yuxing, author.
Language:
English
Subjects (All):
Python (Computer program language).
Finance--Data processing.
Finance.
Big data.
Physical Description:
1 online resource (1 volume) : illustrations
Edition:
Second edition.
Place of Publication:
Birmingham, [England] ; Mumbai, [India] : Packt, 2017.
System Details:
text file
Summary:
Learn and implement various Quantitative Finance concepts using the popular Python libraries About This Book Understand the fundamentals of Python data structures and work with time-series data Implement key concepts in quantitative finance using popular Python libraries such as NumPy, SciPy, and matplotlib A step-by-step tutorial packed with many Python programs that will help you learn how to apply Python to finance Who This Book Is For This book assumes that the readers have some basic knowledge related to Python. However, he/she has no knowledge of quantitative finance. In addition, he/she has no knowledge about financial data. What You Will Learn Become acquainted with Python in the first two chapters Run CAPM, Fama-French 3-factor, and Fama-French-Carhart 4-factor models Learn how to price a call, put, and several exotic options Understand Monte Carlo simulation, how to write a Python program to replicate the Black-Scholes-Merton options model, and how to price a few exotic options Understand the concept of volatility and how to test the hypothesis that volatility changes over the years Understand the ARCH and GARCH processes and how to write related Python programs In Detail This book uses Python as its computational tool. Since Python is free, any school or organization can download and use it. This book is organized according to various finance subjects. In other words, the first edition focuses more on Python, while the second edition is truly trying to apply Python to finance. The book starts by explaining topics exclusively related to Python. Then we deal with critical parts of Python, explaining concepts such as time value of money stock and bond evaluations, capital asset pricing model, multi-factor models, time series analysis, portfolio theory, options and futures. This book will help us to learn or review the basics of quantitative finance and apply Python to solve various problems, such as estimating IBM’s market risk, running a Fama-French 3-factor, 5-factor, or Fama-French-Carhart 4 factor model, estimating the VaR of a 5-stock portfolio, estimating the optimal portfolio, and constructing the efficient frontier for a 20-stock portfolio with real-world stock, and with Monte Carlo Simulation. Later, we will also learn how to replicate the famous Black-Scholes-Merton option model and how to price exotic options such as the average price call option. Style and approach This book takes a step-by-step approach in explaining the l...
Contents:
Cover
Copyright
Credits
About the Author
About the Reviewers
www.PacktPub.com
Customer Feedback
Table of Contents
Preface
Chapter 1: Python Basics
Python installation
Installation of Python via Anaconda
Launching Python via Spyder
Direct installation of Python
Variable assignment, empty space, and writing our own programs
Writing a Python function
Python loops
Python loops, if...else conditions
Data input
Data manipulation
Data output
Exercises
Summary
Chapter 2: Introduction to Python Modules
What is a Python module?
Introduction to NumPy
Introduction to SciPy
Introduction to matplotlib
How to install matplotlib
Several graphical presentations using matplotlib
Introduction to statsmodels
Introduction to pandas
Python modules related to finance
Introduction to the pandas_reader module
Two financial calculators
How to install a Python module
Module dependency
Chapter 3: Time Value of Money
Introduction to time value of money
Writing a financial calculator in Python
Definition of NPV and NPV rule
Definition of IRR and IRR rule
Definition of payback period and payback period rule
Writing your own financial calculator in Python
Two general formulae for many functions
Appendix A - Installation of Python, NumPy, and SciPy
Appendix B - visual presentation of time value of money
Appendix C - Derivation of present value of annuity from present value of one future cash flow and present value of perpetuity
Appendix D - How to download a free financial calculator written in Python
Appendix E - The graphical presentation of the relationship between NPV and R
Appendix F - graphical presentation of NPV profile with two IRRs
Appendix G - Writing your own financial calculator in Python.
Exercises
Chapter 4: Sources of Data
Diving into deeper concepts
Retrieving data from Yahoo!Finance
Retrieving data from Google Finance
Retrieving data from FRED
Retrieving data from Prof. French's data library
Retrieving data from the Census Bureau, Treasury, and BLS
Generating two dozen datasets
Several datasets related to CRSP and Compustat
Appendix A - Python program for return distribution versus a normal distribution
Appendix B - Python program to a draw candle-stick picture
Appendix C - Python program for price movement
Appendix D - Python program to show a picture of a stock's intra-day movement
Appendix E -properties for a pandas DataFrame
Appendix F -how to generate a Python dataset with an extension of .pkl or .pickle
Appendix G - data case #1 -generating several Python datasets
Chapter 5: Bond and Stock Valuation
Introduction to interest rates
Term structure of interest rates
Bond evaluation
Stock valuation
A new data type - dictionary
Appendix A - simple interest rate versus compounding interest rate
Appendix B - several Python functions related to interest conversion
Appendix C - Python program for rateYan.py
Appendix D - Python program to estimate stock price based on an n-period model
Appendix E - Python program to estimate the duration for a bond
Appendix F - data case #2 - fund raised from a new bond issue
Chapter 6: Capital Asset Pricing Model
Introduction to CAPM
Moving beta
Adjusted beta
Scholes and William adjusted beta
Extracting output data
Outputting data to text files
Saving our data to a .csv file
Saving our data to an Excel file
Saving our data to a pickle dataset
Saving our data to a binary file
Reading data from a binary file
Simple string manipulation.
Python via Canopy
References
Chapter 7: Multifactor Models and Performance Measures
Introduction to the Fama-French three-factor model
Fama-French three-factor model
Fama-French-Carhart four-factor model and Fama-French five-factor model
Implementation of Dimson (1979) adjustment for beta
Performance measures
How to merge different datasets
Appendix A - list of related Python datasets
Appendix B - Python program to generate ffMonthly.pkl
Appendix C - Python program for Sharpe ratio
Appendix D - data case #4 - which model is the best, CAPM, FF3, FFC4, or FF5, or others?
Chapter 8: Time-Series Analysis
Introduction to time-series analysis
Merging datasets based on a date variable
Using pandas.date_range() to generate one dimensional time-series
Return estimation
Converting daily returns to monthly ones
Merging datasets by date
Understanding the interpolation technique
Merging data with different frequencies
Tests of normality
Estimating fat tails
T-test and F-test
Tests of equal variances
Testing the January effect
52-week high and low trading strategy
Estimating Roll's spread
Estimating Amihud's illiquidity
Estimating Pastor and Stambaugh (2003) liquidity measure
Fama-MacBeth regression
Durbin-Watson
Python for high-frequency data
Spread estimated based on high-frequency data
Introduction to CRSP
Appendix A - Python program to generate GDP dataset usGDPquarterly2.pkl
Appendix B - critical values of F for the 0.05 significance level
Appendix C - data case #4 - which political party manages the economy better?
Chapter 9: Portfolio Theory
Introduction to portfolio theory
A 2-stock portfolio
Optimization - minimization.
Forming an n-stock portfolio
Constructing an optimal portfolio
Constructing an efficient frontier with n stocks
Appendix A - data case #5 - which industry portfolio do you prefer?
Appendix B - data case #6 - replicate S&amp
P500 monthly returns
Chapter 10: Options and Futures
Introducing futures
Payoff and profit/loss functions for call and put options
European versus American options
Understanding cash flows, types of options, rights and obligations
Black-Scholes-Merton option model on non-dividend paying stocks
Generating our own module p4f
European options with known dividends
Various trading strategies
Covered-call - long a stock and short a call
Straddle - buy a call and a put with the same exercise prices
Butterfly with calls
The relationship between input values and option values
Greeks
Put-call parity and its graphic presentation
The put-call ratio for a short period with a trend
Binomial tree and its graphic presentation
Binomial tree (CRR) method for European options
Binomial tree (CRR) method for American options
Hedging strategies
Implied volatility
Binary-search
Retrieving option data from Yahoo! Finance
Volatility smile and skewness
Appendix A - data case 6: portfolio insurance
Chapter 11: Value at Risk
Introduction to VaR
Normality tests
Skewness and kurtosis
Modified VaR
VaR based on sorted historical returns
Simulation and VaR
VaR for portfolios
Backtesting and stress testing
Expected shortfall
Appendix A - data case 7 - VaR estimation for individual stocks and a portfolio
Chapter 12: Monte Carlo Simulation
Importance of Monte Carlo Simulation.
Generating random numbers from a standard normal distribution
Drawing random samples from a normal distribution
Generating random numbers with a seed
Random numbers from a normal distribution
Histogram for a normal distribution
Graphical presentation of a lognormal distribution
Generating random numbers from a uniform distribution
Using simulation to estimate the pi value
Generating random numbers from a Poisson distribution
Selecting m stocks randomly from n given stocks
With/without replacements
Distribution of annual returns
Simulation of stock price movements
Graphical presentation of stock prices at options' maturity dates
Replicating a Black-Scholes-Merton call using simulation
Exotic option #1 - using the Monte Carlo Simulation to price average
Exotic option #2 - pricing barrier options using the Monte Carlo Simulation
Liking two methods for VaR using simulation
Capital budgeting with Monte Carlo Simulation
Python SimPy module
Comparison between two social policies - basic income and basic job
Finding an efficient frontier based on two stocks by using simulation
Long-term return forecasting
Efficiency, Quasi-Monte Carlo, and Sobol sequences
Appendix A - data case #8 - Monte Carlo Simulation and blackjack
Chapter 13: Credit Risk Analysis
Introduction to credit risk analysis
Credit rating
Credit spread
YIELD of AAA-rated bond, Altman Z-score
Using the KMV model to estimate the market value of total assets and its volatility
Term structure of interest rate
Distance to default
Credit default swap
Appendix A - data case #8 - predicting bankruptcy by using Z-score
Chapter 14: Exotic Options.
European, American, and Bermuda options.
Notes:
Previous edition published: 2014.
Includes index.
Includes bibliographical references at the end of each chapters and index.
Description based on online resource; title from PDF title page (ebrary, viewed October 19, 2017).
OCLC:
995052576

The Penn Libraries is committed to describing library materials using current, accurate, and responsible language. If you discover outdated or inaccurate language, please fill out this feedback form to report it and suggest alternative language.

My Account

Shelf Request an item Bookmarks Fines and fees Settings

Guides

Using the Library Catalog Using Articles+ Library Account