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

Index

A

  • ActivatePython installation
    • URL / Installing matplotlib via ActivePython
  • American call
    • used, for estimating implied volatility / Estimating implied volatility by using an American call
  • American option
    • about / European versus American options
    • versus European option / European versus American options
  • Amihud's model for illiquidity (2002)
    • about / Amihud's model for illiquidity (2002)
  • Anaconda
    • URL / Installation of NumPy and SciPy
    • Python, launching from / Launching Python from Anaconda
  • Anaconda command prompt
    • used, for launching Python / Launching Python using the Anaconda command prompt
  • Anaconda installation
    • URL / Alternative installation via Anaconda
  • Anderson-Darling test / Tests of normality
  • annotate() function / Graphical representation of the portfolio diversification effect
  • annualized return distribution
    • estimating / Distribution of annual returns
  • annual percentage rate (APR) / Examples of using SciPy
  • Annual Percentage Rate (APR) / Converting the interest rates
  • annual returns
    • daily returns, converting to / Converting daily returns to annual returns, Merging datasets by date
  • annuity
    • estimating / Annuity estimation
  • ARCH
    • about / The ARCH model
    • (1) process, simulating / Simulating an ARCH (1) process
  • ARCH (1) process
    • simulating / Simulating an ARCH (1) process
  • arithmetic average
    • about / Using the Monte Carlo simulation to price average options
  • arithmetic mean
    • versus geometric mean / Geometric versus arithmetic mean
  • array
    • looping through / Looping through an array, Looping through an array/DataFrame
    • logic relationships / Logic relationships related to an array
  • array manipulations
    • performing / Performing array manipulations
  • array operations
    • plus operation, performing / Performing plus and minus operations
    • minus operation, performing / Performing plus and minus operations
    • matrix multiplication operation, performing / Performing a matrix multiplication operation
    • item by item multiplication operation, performing / Performing an item-by-item multiplication operation
  • arrays
    • working with / Working with arrays of ones, zeros, and the identity matrix
  • Asian options
    • about / Using the Monte Carlo simulation to price average options
    • advantages / Using the Monte Carlo simulation to price average options
  • Asset-Backed Security (ABS) / Introduction to Python

B

  • barrier options
    • pricing, Monte Carlo simulation used / Pricing barrier options using the Monte Carlo simulation
    • Up-and-out option / Pricing barrier options using the Monte Carlo simulation
    • Down-and-out option / Pricing barrier options using the Monte Carlo simulation
    • Up-and-in option / Pricing barrier options using the Monte Carlo simulation
  • bear spread with calls trading strategy / Various trading strategies
  • bear spread with puts trading strategy / Various trading strategies
  • binary file
    • data, saving to / Saving our data to a binary file
    • data, reading from / Reading data from a binary file
  • binary search
    • about / The mechanism of a binary search
  • binomial tree (CRR) method
    • about / Binomial tree (the CRR method) and its graphical representation
    • graphical representation / Binomial tree (the CRR method) and its graphical representation
    • for European options / The binomial tree method for European options
    • for American options / The binomial tree method for American options
  • binomial_grid() function / The p4f module for options, Binomial tree (the CRR method) and its graphical representation
  • Black-Scholes-Merton option model
    • about / European versus American options, The Black-Scholes-Merton option model on non-dividend paying stocks
  • Bondsonline
    • URL / Open data sources
  • bootstrapping
    • without replacements / Bootstrapping with/without replacements
    • with replacements / Bootstrapping with/without replacements
  • Breusch
    • about / Test of heteroskedasticity, Breusch, and Pagan (1979)
  • bs_call() function / The p4f module for options, Estimating the implied volatility by using a for loop
  • built-in functions
    • listing / Listing all built-in functions
  • bull spread with calls trading strategy / Various trading strategies
  • bull spread with puts trading strategy / Various trading strategies
  • Bureau of Labor Statistics
    • URL / Open data sources
  • butterfly with calls trading strategy / Various trading strategies, Butterfly with calls
  • butterfly with puts trading strategy / Various trading strategies

C

  • calendar spread
    • about / A calendar spread
  • calendar spread trading strategy / Various trading strategies
  • call
    • pricing, simulation used / Pricing a call using simulation
  • call buyer
    • about / Cash flows, types of options, a right, and an obligation
  • call option
    • about / Cash flows, types of options, a right, and an obligation
  • candlesticks
    • used, to represent daily price / Candlesticks representation of IBM's daily price
  • capitalize() function / The upper() function
  • CAPM
    • about / Linear regression and Capital Assets Pricing Model (CAPM), Pastor and Stambaugh (2003) liquidity measure
    • Fama-French three-factor model / Fama-French three-factor model
    • Fama-MacBeth regression / Fama-MacBeth regression, Estimating rolling beta
    • rolling beta estimation / Estimating rolling beta
    • VaR, using / Understanding VaR
  • cash flow
    • about / Cash flows, types of options, a right, and an obligation
  • CBOE
    • option data, retrieving from / Retrieving option data from CBOE
    • URL / The put-call ratio
  • ceil() function / Activating our function using the import function
  • Census Bureau
    • URL / Open data sources
  • certain files
    • displaying, in specific subdirectory / Showing certain files in a specific subdirectory
  • clipboard
    • data, inputting from / Inputting data from the clipboard
  • closing price
    • and trading volume, viewing / Presenting both closing price and trading volume
  • Cluster / A list of subpackages for SciPy
  • CND() function / Writing a program – the empty shell method
  • colors
    • using / Using colors effectively
  • comment-all-out method
    • about / Writing a program – the comment-all-out method
    • example / Writing a program – the comment-all-out method
  • comments types
    • first type comment / The first type of comment
    • second type comment / The second type of comment
  • compounded interest
    • defining / Understanding simple and compounded interest rates
  • Constants / A list of subpackages for SciPy
  • Consumer Price Index (CPI) / A useful dataset
  • continuously compounded interest rate
    • about / Continuously compounded interest rate
  • Cook Pine Capital
    • URL / Estimating fat tails
  • CPI (consumer price index) / Choosing meaningful names
  • CQ dataset
    • about / Spread estimated based on high-frequency data
  • CSV file
    • data, inputting from / Inputting data from a CSV file
  • CT dataset
    • URL / Python for high-frequency data
    • about / Python for high-frequency data
  • cumulative standard normal distribution
    • about / Cumulative standard normal distribution, Normal distribution, standard normal distribution, and cumulative standard normal distribution
  • current price
    • retrieving, from Yahoo! Finance / Retrieving the current price from Yahoo! Finance

D

  • %d / The tuple data type
  • daily price
    • representing, candlesticks used / Candlesticks representation of IBM's daily price
  • daily returns
    • converting, to monthly returns / Converting daily returns to monthly returns, Converting daily returns to annual returns
    • converting, to annual returns / Converting daily returns to annual returns, Merging datasets by date
  • data
    • retrieving, from external text file / Retrieving data from an external text file
    • inputting, from clipboard / Inputting data from the clipboard
    • inputting, from text file / Inputting data from a text file
    • inputting, from Excel file / Inputting data from an Excel file, Inputting data from a CSV file
    • inputting, from CSV file / Inputting data from a CSV file
    • retrieving, from web page / Retrieving data from a web page
    • inputting, from MATLAB dataset / Inputting data from a MATLAB dataset
    • outputting, to external files / Outputting data to external files
    • outputting, to text file / Outputting data to a text file
    • saving, to binary file / Saving our data to a binary file
    • reading, from binary file / Reading data from a binary file
  • DataFrame
    • used, for working with time series / Using the DataFrame
    • looping through / Looping through an array/DataFrame
  • dataset
    • URL / A useful dataset, Selecting m stocks randomly from n given stocks
  • datasets
    • merging, by date / Merging datasets by date
    • n-stock portfolio, forming / Forming an n-stock portfolio, T-test and F-test
  • data types
    • about / A data type – list, Understanding the data types
  • date
    • datasets, merging by / Merging datasets by date
  • datetime.date.today() function / Retrieving historical price data from Yahoo! Finance
  • date variables
    • used, for working with time series / Using date variables
  • default input values
    • used, for functions / Default input values for a function
  • default precision
    • choosing / Choosing appropriate precision
  • del() function / Deleting or unsigning a variable
  • delta
    • about / Greek letters for options
  • delta_call() function / Greek letters for options
  • delta_put function / Greek letters for options
  • dictionary
    • looping through / Looping through a dictionary
  • different correlations
    • impact of / Impact of different correlations
  • different shapes
    • using / Using different shapes
  • dir() function
    • using, for finding variables / Using dir() to find variables and functions
    / Importing the math module, Checking the existence of our functions, Showing certain files in a specific subdirectory, Showing all functions in NumPy and SciPy
  • dir2() function / Default input values for a function, Showing certain files in a specific subdirectory
  • DOS window
    • Python, launching / Launching Python from our own DOS window
    • used, for launching Python / Launching Python using the DOS window
  • Down-and-out option / Pricing barrier options using the Monte Carlo simulation
  • DuPont identity
    • working with / Working with DuPont identity

E

  • e (2.71828) / The pi, e, log, and exponential functions
  • Economics module / Module dependency
  • effective annual rate (EAR) / Converting the interest rates
  • efficiency
    • measuring, by time spent / Measuring efficiency by time spent in finishing a program
  • efficient frontier
    • constructing / Constructing an efficient frontier
    • variance-covariance matrix, estimating / Estimating a variance-covariance matrix
    • variance-covariance matrix optimization / Optimization – minimization
    • optimal portfolio, constructing / Constructing an optimal portfolio
    • constructing, n stocks used / Constructing an efficient frontier with n stocks
    • finding, based on two stocks / Finding an efficient frontier based on two stocks
    • constructing, with n stocks / Constructing an efficient frontier with n stocks
  • empty shell method
    • about / Writing a program – the empty shell method
    • describing / Writing a program – the empty shell method
  • Enter key / Finding the help window
  • enumerate() function / Net present value and the NPV rule, The enumerate() function
  • equal means test
    • performing / Tests of equal means and equal variances
  • equal variances test
    • performing, sp.stats.bartlet used / Tests of equal means and equal variances
  • error message
    • about / Error messages
    • abcde variable, error message / Can't call a variable without assignment
  • error messages / Error messages
  • European option
    • about / European versus American options
    • versus American option / European versus American options
  • European options
    • with known dividends / European options with known dividends
  • Excel file
    • data, inputting from / Inputting data from an Excel file, Inputting data from a CSV file
  • existence
    • checking, of functions / Checking the existence of our functions
  • exit modes / GJR_GARCH by Glosten, Jagannanthan, and Runkle (1993)
  • exotic options
    • about / Exotic options
    • Monte Carlo simulation, using / Using the Monte Carlo simulation to price average options
    • barrier options pricing, Monte Carlo simulation used / Pricing barrier options using the Monte Carlo simulation
  • expiration dates
    • retrieving, from Yahoo! Finance / Different expiring dates from Yahoo! Finance
    • URL / Different expiring dates from Yahoo! Finance
  • external text file
    • data, retrieving from / Retrieving data from an external text file

F

  • F-test
    • about / T-test and F-test
  • Fama-French dataset / Lower partial standard deviation
  • Fama-French three-factor model
    • about / Fama-French three-factor model
  • Fama-MacBeth regression
    • about / Fama-MacBeth regression, Estimating rolling beta
  • fat tails
    • estimating / Estimating fat tails
  • Federal Reserve Bank Data Library
    • URL / Open data sources
  • Fftpack / A list of subpackages for SciPy
  • fGarch / Simulating a GARCH (p,q) process using modified garchSim()
  • figure
    • saving, to file / Saving our figure to a file
  • file
    • figure, saving to / Saving our figure to a file
  • File | New Window Ctrl + N / Writing a program – the comment-all-out method
  • fin101() function / Using Python as a financial calculator
  • finance related Python modules
    • Ystockquote / Module dependency
    • Quant / Module dependency
    • trytond_currency / Module dependency
    • Economics / Module dependency
    • trytond_project / Module dependency
    • trytond_analytic_account / Module dependency
    • trytond_account_statement / Module dependency
    • trytond_stock_split / Module dependency
    • trytond_stock_forecast / Module dependency
    • Finance / Module dependency
    • FinDates / Module dependency
  • financial calculator
    • Python, using as / Using Python as a financial calculator
  • FinDates module / Module dependency
  • first type comment / The first type of comment
  • floating strikes
    • lookback options, pricing with / Pricing lookback options with floating strikes
  • floor function
    • using / The power function, floor, and remainder
  • for loop
    • about / Understanding a for loop
    • used, for estimating implied volatility / Estimating the implied volatility by using a for loop
    • IRR, estimating via / Estimation of IRR via a for loop
    • assigning through / Assignment through a for loop
  • from math import * / Comparing "import math" and "from math import *"
  • functions
    • print() function / The print() function
    • type() function / The type() function
    • upper() function / The upper() function
    • default input values, using for / Default input values for a function
    • existence, checking / Checking the existence of our functions
    • defining, from Python editor / Defining functions from our Python editor
    • activating, import function used / Activating our function using the import function
    • displaying, in NumPy / Showing all functions in NumPy and SciPy
    • displaying, in SciPy / Showing all functions in NumPy and SciPy
    • finding, from imported module / Finding a function from an imported module

G

  • GARCH
    • about / The GARCH (Generalized ARCH) model
    • process, simulating / Simulating a GARCH process
    • (p,q) process simulating, modified garchSim() used / Simulating a GARCH (p,q) process using modified garchSim()
  • GARCH (p,q) process
    • simulating, modified garchSim() used / Simulating a GARCH (p,q) process using modified garchSim()
  • garchSim() R function / Simulating a GARCH (p,q) process using modified garchSim()
  • genfromtxt() function / The loadtxt() and getfromtxt() functions
  • geometric average
    • about / Using the Monte Carlo simulation to price average options
  • geometric mean
    • versus arithmetic mean / Geometric versus arithmetic mean
  • GJR_GARCH() function / GJR_GARCH by Glosten, Jagannanthan, and Runkle (1993)
  • Glosten model / GJR_GARCH by Glosten, Jagannanthan, and Runkle (1993)
  • Google Finance
    • URL / Open data sources
  • graph
    • texts, adding to / Adding texts to our graph
    • mathematical formulae, adding to / Adding mathematical formulae to our graph
    • simple images, adding to / Adding simple images to our graphs
  • Greek letters
    • for options / Greek letters for options
  • GUI
    • used, for Python launching / Launching Python with GUI

H

  • head() function / Retrieving option data from Yahoo! Finance
  • hedging strategies
    • about / Hedging strategies
  • help() function / A true power function, Finding out more information about a specific built-in function, Using the help function related to modules, Generating random numbers from a standard normal distribution
  • help(round) function / Finding out more information about a specific built-in function
  • help function
    • using / Using the help function related to modules
  • help window
    • finding / Finding the help window
  • heteroskedasticity / Test of heteroskedasticity, Breusch, and Pagan (1979)
  • high-frequency data
    • about / Python for high-frequency data
    • TAQ database / Python for high-frequency data
    • retrieving, from Google Finance / Python for high-frequency data
    • TAQ / Python for high-frequency data
    • TORQ database / Python for high-frequency data
    • spread estimation based / Spread estimated based on high-frequency data
  • High minus Low (HML) / A useful dataset
  • histogram
    • used, for displaying return distribution / Histogram showing return distribution
    • about / Histogram for a normal distribution
  • historical price data
    • retrieving, from Yahoo Finance / Retrieving historical price data from Yahoo! Finance
    • retrieving, from Yahoo! Finance / Retrieving historical price data from Yahoo! Finance
  • HML (High Minus Low) / Selecting m stocks randomly from n given stocks

I

  • IBM option data
    • URL / Retrieving option data from CBOE
  • if() function / The if() function
  • implied volatility
    • about / Definition of an implied volatility
    • estimating, for loop used / Estimating the implied volatility by using a for loop
    • estimating, while loop used / Estimating implied volatility by using a while loop
    • estimating, American call used / Estimating implied volatility by using an American call
  • implied volatility function
    • based on European call / Implied volatility function based on a European call
    • based on put option model / Implied volatility based on a put option model
  • imported module
    • short name, adopting for / Adopting a short name for an imported module
    • all functions, dispalying / Showing all functions in an imported module
    • deleting / Deleting an imported module
    • location, finding / Finding the location of an imported module
    • functions, finding from / Finding a function from an imported module
  • import function
    • used, for activating functions / Activating our function using the import function
  • import math / Comparing "import math" and "from math import *"
  • in-and-out parity
    • about / Barrier in-and-out parity
  • indentation
    • in Python / Indentation is critical in Python
  • input values, and option values
    • relationship / Relationship between input values and option values
  • installation
    • Python / Installing Python
  • Integrate / A list of subpackages for SciPy
  • interest rates
    • converting / Converting the interest rates
  • Internal Rate of Return (IRR) / Understanding the Net Present Value (NPV) profile
  • International Business Machines (IBM) / Introduction to Python
  • Interpolate / A list of subpackages for SciPy
  • interpolation technique
    • about / Understanding the interpolation technique, Outputting data to external files
  • intra-day graphical representations
    • about / IBM's intra-day graphical representations
  • intra-day pattern
    • URL / IBM's intra-day graphical representations
  • Io / A list of subpackages for SciPy
  • IRR
    • defining / Defining IRR and the IRR rule
    • estimating, via for loop / Estimation of IRR via a for loop
  • IRR rule
    • defining / Defining IRR and the IRR rule
  • isnan() function / Estimation of IRR via a for loop
  • item by item multiplication operation
    • performing / Performing an item-by-item multiplication operation
  • items() function / Looping through a dictionary

J

  • Jagannanthan model / GJR_GARCH by Glosten, Jagannanthan, and Runkle (1993)
  • January effect
    • testing / Testing the January effect
  • join() function / Converting daily returns to monthly returns

K

  • Kolmogorov-Smirnov test / Tests of normality
  • kurtosis / Estimating fat tails

L

  • LaTeX
    • URL / Adding mathematical formulae to our graph
  • LEGB rule / A true power function
  • len() function / The tuple data type, Retrieving historical price data from Yahoo! Finance
  • Linalg / A list of subpackages for SciPy
  • linear equations
    • solving, SciPy used / Solving linear equations using SciPy
  • linspace() function / Understanding how to use matplotlib
  • list data type
    • about / Understanding the list data type
  • lo() function / Writing a program – the comment-all-out method
  • loadmat() function / Inputting data from a MATLAB dataset
  • loadtxt() function / The loadtxt() and getfromtxt() functions
  • logic relationships / Logic relationships related to an array
  • lognormal distribution
    • graphical presentation / Graphical presentation of a lognormal distribution
  • long-term return forecast
    • about / Long-term return forecasting
  • lookback options
    • pricing, with floating strikes / Pricing lookback options with floating strikes
  • loss function
    • for call option / Payoff and profit/loss functions for the call and put options
  • lower partial standard deviation
    • about / Lower partial standard deviation

M

  • M.P. Visser / Graphical presentation of volatility clustering
  • manuals, Python
    • finding / Finding manuals and tutorials
    • online tutorials / Finding manuals and tutorials
    • PDF version / Finding manuals and tutorials
  • market returns
    • and stock, comparing / Comparing stock and market returns
  • mathematical formulae
    • adding, to graph / Adding mathematical formulae to our graph
  • math import * / "import math" versus "from math import *"
  • math module
    • importing / Importing the math module
    • pi (3.14159265) / The pi, e, log, and exponential functions
    • e (2.71828) / The pi, e, log, and exponential functions
  • MATLAB dataset
    • data, inputting from / Inputting data from a MATLAB dataset
  • matplotlib
    • installing, via ActivatePython / Installing matplotlib via ActivePython
    • alternative installation, via Anaconda / Alternative installation via Anaconda
    • using / Understanding how to use matplotlib
    • URL / Finding manuals, examples, and videos
  • matplotlib module
    • installing / Installing the matplotlib module independently
  • Matplotlib module / Finding out all the available modules
  • matrix multiplication operation
    • performing / Performing a matrix multiplication operation
  • mean() function / Geometric versus arithmetic mean
  • meaningful variable names
    • choosing / Choosing meaningful names
  • min_value variable / Implied volatility based on a put option model
  • module
    • about / What is a module?, More information about modules
    • importing / Importing a module
    • short name, adopting for / Adopting a short name for an imported module
    • log() function, importing / Importing only a few needed functions
    • exp() function, importing / Importing only a few needed functions
    • sqrt(), importing / Importing only a few needed functions
    • built-in modules / Finding out all built-in modules
    • available modules, finding / Finding out all the available modules
    • specific uninstalled module, finding / Finding a specific uninstalled module
    • dependency approaches / Module dependency
  • Monte Carlo simulation
    • using / Using the Monte Carlo simulation to price average options
    • used, for pricing barrier options / Pricing barrier options using the Monte Carlo simulation
  • monthly returns
    • daily returns, converting to / Converting daily returns to monthly returns, Converting daily returns to annual returns
  • m stocks
    • random selection, from n given stocks / Selecting m stocks randomly from n given stocks
  • multiple IRRs
    • estimating / Estimation of multiple IRRs

N

  • n-stock portfolio
    • forming / Forming an n-stock portfolio, T-test and F-test
  • Ndimage / A list of subpackages for SciPy
  • Nested (multiple) for loops
    • about / Nested (multiple) for loops
  • Net Present Value ( NPV) function / The enumerate() function
  • normal distribution
    • about / Normal distribution, standard normal distribution, and cumulative standard normal distribution
    • drawing / Normal distribution, standard normal distribution, and cumulative standard normal distribution
    • random samples, drawing from / Drawing random samples from a normal (Gaussian) distribution
    • n random numbers, generating from / Generating n random numbers from a normal distribution
    • histogram / Histogram for a normal distribution
  • normality test
    • about / Tests of normality
  • normdist() function / Writing a program – the empty shell method
  • np.argmin() function / The x.sum() dot function
  • np.array() function / Examples of using NumPy
  • np.irr() function / Understanding the Net Present Value (NPV) profile
  • np.linspace() function / Interpolation in SciPy
  • np.min() function / The x.sum() dot function
  • np.npv() function / Examples of using SciPy
  • np.random.normal() function / Understanding how to use matplotlib
  • np.size() function / Examples of using NumPy
  • np.std() function / Examples of using NumPy
  • NPV
    • about / Net present value and the NPV rule
    • defining / Understanding the Net Present Value (NPV) profile
  • NPV() function / Examples of using SciPy
  • NPV profile
    • about / Understanding the Net Present Value (NPV) profile
    • colors, using / Using colors effectively
    • different shapes, using / Using different shapes
  • NPV rule
    • about / Net present value and the NPV rule
  • npv_f() function / Estimation of IRR via a for loop
  • n random numbers
    • generating, from normal distribution / Generating n random numbers from a normal distribution
  • n stocks
    • used, for constructing an efficient frontier / Constructing an efficient frontier with n stocks
    • efficient frontier, constructing with / Constructing an efficient frontier with n stocks
  • NumPy
    • installing / Installation of NumPy and SciPy, Installing NumPy independently
    • functions, displaying in / Showing all functions in NumPy and SciPy
  • NumPy, using
    • examples / Examples of using NumPy
  • numpy.random function / Generating random numbers from a standard normal distribution
  • NumPy module / Finding the location of an imported module

O

  • % operator / The power function, floor, and remainder
  • Odr / A list of subpackages for SciPy
  • OLS regression
    • using / Examples from statsmodels
  • one dimensional time series
    • generating, pd.Series() function used / Using pd.Series() to generate one-dimensional time series, Using date variables
    • date variables, using / Using date variables
    • DataFrame, using / Using the DataFrame
  • open data sources
    • Yahoo! Finance / Open data sources
    • Google Finance / Open data sources
    • Federal Reserve Bank Data Library / Open data sources
    • Russell indices / Open data sources
    • Prof. French's Data Library / Open data sources
    • Census Bureau / Open data sources
    • Bondsonline / Open data sources
    • U.S. Department of the Treasury / Open data sources
    • Bureau of Labor Statistics / Open data sources
    • Yahoo! Finance, downloading from / Open data sources
  • optimal portfolio
    • constructing / Constructing an optimal portfolio
  • optimization
    • about / Understanding optimization
  • optimization, variance-covariance matrix
    • about / Optimization – minimization
  • optimize / A list of subpackages for SciPy
  • option data
    • retrieving, from CBOE / Retrieving option data from CBOE
    • retrieving, from Yahoo! Finance / Retrieving option data from Yahoo! Finance
    • retrieving, Yahoo! Finance / Retrieving option data from Yahoo! Finance
  • over-the-counter (OTC) / Exotic options
  • own module
    • generating / Generating our own module

P

  • p4f module
    • for options / The p4f module for options
  • Pagan
    • about / Test of heteroskedasticity, Breusch, and Pagan (1979)
  • Pandas
    • installing / Installing Pandas and statsmodels
    • used, for data manipulation / Using Pandas, Examples from statsmodels
  • Pandas module / Introduction to Python
  • Pandas pickle format
    • URL / The mechanism of a binary search
  • Pastor and Stambaugh (2003) liquidity measure
    • about / Pastor and Stambaugh (2003) liquidity measure
  • path
    • project directory, adding to / Adding our project directory to the path
  • Path Browser / More information about modules
  • path function / Adding our project directory to the path
  • payback period
    • defining / Defining the payback period and the payback period rule
  • payback period rule
    • defining / Defining the payback period and the payback period rule
  • payoff function
    • for call option / Payoff and profit/loss functions for the call and put options
  • pd.DataFrame() function / Using the DataFrame
  • pd.interpolate() function / Understanding the interpolation technique
  • pd.ols function / Estimating rolling beta
  • pd.read_clipboard() function / Inputting data from the clipboard
  • pd.read_csv() function / Retrieving data from a web page
  • pd.Series() function / Using pd.Series() to generate one-dimensional time series
    • used, for generating one dimensional time series / Using pd.Series() to generate one-dimensional time series, Using date variables
  • permutation() function / Bootstrapping with/without replacements
  • pi (3.14159265) / The pi, e, log, and exponential functions
  • PIN (Probability of informed trading) / Generating random numbers from a Poisson distribution
  • pi value
    • estimating, simulation used / Using simulation to estimate the pi value
  • plt.bar() function / Working with DuPont identity
  • plus operation
    • performing / Performing plus and minus operations
  • Poisson distribution
    • random numbers, generating from / Generating random numbers from a Poisson distribution
  • portfolio diversification effect
    • graphical representation / Graphical representation of the portfolio diversification effect
    • number of stocks / Number of stocks and portfolio risk
    • portfolio risk / Number of stocks and portfolio risk
  • power function
    • using / The power function, floor, and remainder
    • about / A true power function
  • print() function / The print() function, Generating random numbers from a standard normal distribution
  • Prof. French's Data Library
    • URL / Open data sources
  • profit function
    • for call option / Payoff and profit/loss functions for the call and put options
  • program
    • debugging, from Python editor / Debugging a program from a Python editor
    • debugging / Using and debugging other programs
  • project directory
    • adding, to path / Adding our project directory to the path
  • put-call parity
    • about / The put-call parity and its graphical representation
    • graphical representation / The put-call parity and its graphical representation
  • put-call ratio
    • about / The put-call ratio
    • for shorter period / The put-call ratio for a short period with a trend
  • put option
    • about / Payoff and profit/loss functions for the call and put options, Cash flows, types of options, a right, and an obligation
  • pv() function / Launching Python from Anaconda
  • pv_f() function / Defining functions from our Python editor, The second type of comment
    • calling / Two ways to call our pv_f() function
    • about / Finding information about our pv_f() function
  • Python
    • about / Introduction to Python
    • benefits / Introduction to Python
    • modules / Introduction to Python
    • shortcoming / Introduction to Python
    • installing / Installing Python
    • launching, ways / Installing Python
    • versions / Different versions of Python
    • launching, with GUI / Launching Python with GUI
    • launching, from Python command line / Launching Python from the Python command line
    • launching, from own DOS window / Launching Python from our own DOS window
    • quiting, ways / Quitting Python, Python language is case sensitive
    • help window, finding / Finding the help window
    • version, finding / Finding the version of Python
    • addition operation / Basic math operations – addition, subtraction, multiplication, and division
    • subtraction operation / Basic math operations – addition, subtraction, multiplication, and division
    • multiplication operation / Basic math operations – addition, subtraction, multiplication, and division
    • division operation / Basic math operations – addition, subtraction, multiplication, and division
    • used, as financial calculator / Using Python as a financial calculator
    • launching, from Anaconda / Launching Python from Anaconda
    • launching, Anaconda command prompt used / Launching Python using the Anaconda command prompt
    • launching, DOS window used / Launching Python using the DOS window
    • launching, Spyder used / Launching Python using Spyder
  • Python code
    • for down-and-in put option / Pricing barrier options using the Monte Carlo simulation
  • Python command line
    • Python, launching from / Launching Python from the Python command line
  • Python editor
    • functions, defining from / Defining functions from our Python editor
    • program, debugging from / Debugging a program from a Python editor
  • Python function
    • writing / Writing a Python function without saving it
  • Python home documents / Finding manuals and tutorials
  • Python Manuals
    • finding / Finding manuals and tutorials
  • Python Package Index
    • URL / Module dependency

Q

  • quant / What is a module?
  • Quant module / Module dependency

R

  • r.sort() function / Retrieving historical price data from Yahoo! Finance
  • randint() function / Selecting m stocks randomly from n given stocks
  • random.rand() function / Generating random numbers with a seed
  • random.seed() function / GJR_GARCH by Glosten, Jagannanthan, and Runkle (1993)
  • random access
    • versus sequential access / Sequential versus random access
  • random numbers
    • generating, with seed / Generating random numbers with a seed, Generating random numbers with a seed
    • generating, from standard normal distribution / Generating random numbers from a standard normal distribution
    • generating, from uniform distribution / Generating random numbers from a uniform distribution
    • generating, from Poisson distribution / Generating random numbers from a Poisson distribution
  • random samples
    • drawing, from normal distribution / Drawing random samples from a normal (Gaussian) distribution
  • randrange() function / Selecting m stocks randomly from n given stocks
  • range() function / Understanding a for loop
  • read_csv() function / Retrieving data from a web page
  • read_table() function / Inputting data from a text file
  • remainder / The power function, floor, and remainder
  • remove() function / Selecting m stocks randomly from n given stocks
  • return
    • versus volatility, comparing / Comparing return versus volatility for several stocks
  • return distribution
    • displaying, histogram used / Histogram showing return distribution
  • return estimation
    • about / Return estimation
    • daily returns, converting to monthly returns / Converting daily returns to monthly returns
    • daily returns, converting to annual returns / Converting daily returns to annual returns, Merging datasets by date
  • Return on Equity (ROE) / Working with DuPont identity
  • ret_f() function / Test of equivalency of volatility over two periods
  • Roll's model to estimate spread (1984)
    • about / Roll's model to estimate spread (1984)
  • rolling beta
    • estimating / Estimating rolling beta
  • round() function / Choosing appropriate precision
  • Runkle model / GJR_GARCH by Glosten, Jagannanthan, and Runkle (1993)

S

  • SciPy
    • installing / Installation of NumPy and SciPy
    • functions, displaying in / Showing all functions in NumPy and SciPy
    • subpackages / A list of subpackages for SciPy
    • stats / Statistic submodule (stats) from SciPy
    • interpolating in / Interpolation in SciPy
    • used, for solving linear equations / Solving linear equations using SciPy
  • SciPy, subpackages
    • Cluster / A list of subpackages for SciPy
    • Constants / A list of subpackages for SciPy
    • Fftpack / A list of subpackages for SciPy
    • Integrate / A list of subpackages for SciPy
    • Interpolate / A list of subpackages for SciPy
    • Io / A list of subpackages for SciPy
    • Linalg / A list of subpackages for SciPy
    • Ndimage / A list of subpackages for SciPy
    • Odr / A list of subpackages for SciPy
    • optimize / A list of subpackages for SciPy
    • signal / A list of subpackages for SciPy
    • sparse / A list of subpackages for SciPy
    • spatial / A list of subpackages for SciPy
    • special / A list of subpackages for SciPy
    • stats / A list of subpackages for SciPy
  • SciPy, using
    • examples / Examples of using SciPy
  • second type comment / The second type of comment
  • Securities and Exchange Commission (SEC) / Introduction to Python
  • seed
    • random numbers, generating with / Generating random numbers with a seed, Generating random numbers with a seed
  • seed() function / Generating random numbers with a seed, Generating random numbers from a uniform distribution, Simulation of stock price movements
  • sequential access
    • versus random access / Sequential versus random access
  • Shapiro-Wilk test / Tests of normality
  • sign() function / Estimating implied volatility by using a while loop
  • signal / A list of subpackages for SciPy
  • simple images
    • adding, to graph / Adding simple images to our graphs
  • simple interest
    • defining / Understanding simple and compounded interest rates
  • simulation
    • used, for pi value estimation / Using simulation to estimate the pi value
    • used, for pricing call / Pricing a call using simulation
  • skewness / Estimating fat tails, Volatility smile and skewness
  • Small minus Big (SMB) / A useful dataset
  • SMB (Small Minus Big) / Selecting m stocks randomly from n given stocks
  • smile / Volatility smile and skewness
  • Sobol sequence
    • used, for improving efficiency / Using the Sobol sequence to improve the efficiency
    • URL / Using the Sobol sequence to improve the efficiency
  • sp.fv() function / Examples of using SciPy
  • sp.npv() function / Examples of using SciPy
  • sp.pmt() function / Examples of using SciPy
  • sp.prod() function / Examples of using SciPy
  • sp.pv() function / Examples of using SciPy
  • sp.stats.bartlet function
    • used, for testing equal variance / Tests of equal means and equal variances
  • sparse / A list of subpackages for SciPy
  • spatial / A list of subpackages for SciPy
  • special / A list of subpackages for SciPy
  • specific function
    • about / More information about a specific function
  • specific subdirectory
    • certain files, displaying / Showing certain files in a specific subdirectory
  • specific uninstalled module
    • finding / Finding a specific uninstalled module
  • spread estimation
    • based on, high-frequency data / Spread estimated based on high-frequency data
  • Spyder
    • used, for launching Python / Launching Python using Spyder
    • using / More on using Spyder
    • URL / More on using Spyder
  • sqrt() function / Error messages, "import math" versus "from math import *", Importing a module, Deleting an imported module
  • sqrt(3) command / Error messages
  • standard normal distribution
    • about / Normal distribution, standard normal distribution, and cumulative standard normal distribution
    • random numbers, generating from / Generating random numbers from a standard normal distribution
  • stats / A list of subpackages for SciPy, Statistic submodule (stats) from SciPy
  • stats.anderson() function / Tests of normality
  • stats.norm.cdf() function / Normal distribution, standard normal distribution, and cumulative standard normal distribution, The Black-Scholes-Merton option model on non-dividend paying stocks
  • stats.norm.pdf() function / Normal distribution, standard normal distribution, and cumulative standard normal distribution
  • Statsmodels / Different versions of Python
  • statsmodels
    • installing / Installing Pandas and statsmodels
    • using, for statistical analysis / Examples from statsmodels
    • OLS regression method / Examples from statsmodels
  • std() function / More information about a specific function
  • stock
    • and market returns, comparing / Comparing stock and market returns
    • performance, comparing among / Performance comparisons among stocks
  • stock price movements
    • simulating / Simulation of stock price movements
  • straddle trading strategy / Various trading strategies, Straddle – buy a call and a put with the same exercise prices
  • strangle trading strategy / Various trading strategies
  • strap trading strategy / Various trading strategies
  • string.replace() function / Python for high-frequency data
  • strip() function / The upper() function
  • strip trading strategy / Various trading strategies
  • sys module / Finding the version of Python

T

  • T-test
    • about / T-test and F-test
    • performing / T-test and F-test
    • equal variances test, performing / Tests of equal means and equal variances
    • equal means test, performing / Tests of equal means and equal variances
    • January effect, testing / Testing the January effect
  • tail() function / Retrieving option data from Yahoo! Finance
  • terminal stock prices
    • estimating / Graphical presentation of stock prices at options' maturity dates
  • text file
    • data, inputting from / Inputting data from a text file
    • data, outputting to / Outputting data to a text file
  • texts
    • adding, to graph / Adding texts to our graph
  • time value, money
    • defining / Understanding the time value of money
  • TORQ database
    • about / Python for high-frequency data
    • URL / Python for high-frequency data
  • trading strategies
    • about / Various trading strategies
    • bull spread with calls / Various trading strategies
    • bull spread with puts / Various trading strategies
    • bear spread with puts / Various trading strategies
    • bear spread with calls / Various trading strategies
    • straddle / Various trading strategies, Straddle – buy a call and a put with the same exercise prices
    • strip / Various trading strategies
    • strap / Various trading strategies
    • strangle / Various trading strategies
    • butterfly with calls / Various trading strategies, Butterfly with calls
    • butterfly with puts / Various trading strategies
    • calendar spread / Various trading strategies, A calendar spread
    • covered call / Covered call – long a stock and short a call
  • trading volume
    • and closing price, viewing / Presenting both closing price and trading volume
  • trytond_account_statement module / Module dependency
  • trytond_currency module / Module dependency
  • trytond_project module / Module dependency
  • trytond_stock_forecast module / Module dependency
  • trytond_stock_split module / Module dependency
  • ttest_1samp() function / Statistic submodule (stats) from SciPy
  • tuple datatype / The tuple data type
  • two-year price movement
    • graphical representation / Graphical representation of two-year price movement
  • two strings
    • combining / Combining two strings
  • type() function / The type() function

U

  • U.S. Department of the Treasury
    • URL / Open data sources
  • uniform distribution
    • random numbers, generating from / Generating random numbers from a uniform distribution
  • unique() function / Spread estimated based on high-frequency data, Selecting m stocks randomly from n given stocks
  • Up-and-in option / Pricing barrier options using the Monte Carlo simulation
  • up-and-in parity
    • graphical representation / Graphical presentation of an up-and-out and up-and-in parity
  • Up-and-out option / Pricing barrier options using the Monte Carlo simulation
  • up-and-out parity
    • graphical representation / Graphical presentation of an up-and-out and up-and-in parity
  • upper() function / The upper() function
  • useful applications
    • 52-week high and low trading strategy / 52-week high and low trading strategy
    • Roll's model to estimate spread (1984) / Roll's model to estimate spread (1984)
    • Amihud's model for illiquidity (2002) / Amihud's model for illiquidity (2002), Pastor and Stambaugh (2003) liquidity measure
    • Pastor and Stambaugh (2003) liquidity measure / Pastor and Stambaugh (2003) liquidity measure

V

  • values
    • assigning, to variables / Assigning values to variables
  • vanilla options
    • about / Exotic options
  • VaR
    • using / Understanding VaR
  • variable
    • initializing / Initializing the variable
    • values, assigning to / Assigning values to variables
    • values, displaying / Displaying the value of a variable
    • unsigning / Deleting or unsigning a variable
    • deleting / Deleting or unsigning a variable
  • variance-covariance matrix
    • estimating / Estimating a variance-covariance matrix
    • optimization / Optimization – minimization
  • versions, Python
    • finding / Finding the version of Python
  • Visual financial statements
    • URL / Finding manuals, examples, and videos
  • volatility
    • versus return, comparing / Comparing return versus volatility for several stocks
    • about / Conventional volatility measure – standard deviation, Volatility smile and skewness
    • over two periods, equivalency testing / Test of equivalency of volatility over two periods
  • volatility clustering
    • about / Graphical presentation of volatility clustering
  • volatility skewness
    • about / Volatility smile and skewness
  • volatility smile
    • about / Volatility smile and skewness

W

  • 52-week high and low trading strategy
    • about / 52-week high and low trading strategy
  • web page
    • data, retrieving from / Retrieving data from a web page
  • web page examples
    • URL / Finding manuals, examples, and videos
  • while loop
    • about / Understanding a while loop
    • used, for estimating implied volatility / Estimating implied volatility by using a while loop

X

  • x.sum() dot function
    • about / The x.sum() dot function
  • xlim() function / Understanding simple and compounded interest rates

Y

  • Yahoo! Finance
    • URL / Open data sources, Retrieving option data from Yahoo! Finance
    • historical price data, retrieving from / Retrieving historical price data from Yahoo! Finance
    • option data, retrieving from / Retrieving option data from Yahoo! Finance, Retrieving option data from Yahoo! Finance
    • different expiring dates / Different expiring dates from Yahoo! Finance
    • current price, retrieving from / Retrieving the current price from Yahoo! Finance
  • Yahoo Finance
    • historical price data, retrieving from / Retrieving historical price data from Yahoo! Finance
  • yanMonthly.pickle
    • URL / Looping through an array/DataFrame
  • ylim() function / Understanding simple and compounded interest rates
  • Ystockquote / Module dependency