Python for Finance
eBook - ePub

Python for Finance

Yuxing Yan

Share book
  1. 408 pages
  2. English
  3. ePUB (mobile friendly)
  4. Available on iOS & Android
eBook - ePub

Python for Finance

Yuxing Yan

Book details
Book preview
Table of contents
Citations

About This Book

In Detail

Python is a free and powerful tool that can be used to build a financial calculator and price options, and can also explain many trading strategies and test various hypotheses. This book details the steps needed to retrieve time series data from different public data sources.

Python for Finance explores the basics of programming in Python. It is a step-by-step tutorial that will teach you, with the help of concise, practical programs, how to run various statistic tests. This book introduces you to the basic concepts and operations related to Python. You will also learn how to estimate illiquidity, Amihud (2002), liquidity measure, Pastor and Stambaugh (2003), Roll spread (1984), spread based on high-frequency data, beta (rolling beta), draw volatility smile and skewness, and construct a binomial tree to price American options.

This book is a hands-on guide with easy-to-follow examples to help you learn about option theory, quantitative finance, financial modeling, and time series using Python.

Approach

A hands-on guide with easy-to-follow examples to help you learn about option theory, quantitative finance, financial modeling, and time series using Python.

Who this book is for

Python for Finance is perfect for graduate students, practitioners, and application developers who wish to learn how to utilize Python to handle their financial needs. Basic programming knowledge is helpful, but not necessary.

Frequently asked questions

How do I cancel my subscription?
Simply head over to the account section in settings and click on “Cancel Subscription” - it’s as simple as that. After you cancel, your membership will stay active for the remainder of the time you’ve paid for. Learn more here.
Can/how do I download books?
At the moment all of our mobile-responsive ePub books are available to download via the app. Most of our PDFs are also available to download and we're working on making the final remaining ones downloadable now. Learn more here.
What is the difference between the pricing plans?
Both plans give you full access to the library and all of Perlego’s features. The only differences are the price and subscription period: With the annual plan you’ll save around 30% compared to 12 months on the monthly plan.
What is Perlego?
We are an online textbook subscription service, where you can get access to an entire online library for less than the price of a single book per month. With over 1 million books across 1000+ topics, we’ve got you covered! Learn more here.
Do you support text-to-speech?
Look out for the read-aloud symbol on your next book to see if you can listen to it. The read-aloud tool reads text aloud for you, highlighting the text as it is being read. You can pause it, speed it up and slow it down. Learn more here.
Is Python for Finance an online PDF/ePUB?
Yes, you can access Python for Finance by Yuxing Yan in PDF and/or ePUB format, as well as other popular books in Ciencia de la computación & Aplicaciones de escritorio. We have over one million books available in our catalogue for you to explore.

Information

Year
2014
ISBN
9781783284375

Python for Finance


Table of Contents

Python for Finance
Credits
About the Author
Acknowledgments
About the Reviewers
www.PacktPub.com
Support files, eBooks, discount offers and more
Why subscribe?
Free access for Packt account holders
Preface
Why Python?
A programming book written by a finance professor
Small programs oriented
Using real-world data
What this book covers
What could you achieve after reading this book?
Who this book is for
Conventions
Two ways to use the book
Reader feedback
Customer support
Downloading the example code
Downloading the color images of this book
Errata
Piracy
Questions
1. Introduction and Installation of Python
Introduction to Python
Installing Python
Different versions of Python
Ways to launch Python
Launching Python with GUI
Launching Python from the Python command line
Launching Python from our own DOS window
Quitting Python
Error messages
Python language is case sensitive
Initializing the variable
Finding the help window
Finding manuals and tutorials
Finding the version of Python
Summary
Exercises
2. Using Python as an Ordinary Calculator
Assigning values to variables
Displaying the value of a variable
Error messages
Can't call a variable without assignment
Choosing meaningful names
Using dir() to find variables and functions
Deleting or unsigning a variable
Basic math operations – addition, subtraction, multiplication, and division
The power function, floor, and remainder
A true power function
Choosing appropriate precision
Finding out more information about a specific built-in function
Listing all built-in functions
Importing the math module
The pi, e, log, and exponential functions
"import math" versus "from math import *"
A few frequently used functions
The print() function
The type() function
Last expression _ (underscore)
Combining two strings
The upper() function
The tuple data type
Summary
Exercises
3. Using Python as a Financial Calculator
Writing a Python function without saving it
Default input values for a function
Indentation is critical in Python
Checking the existence of our functions
Defining functions from our Python editor
Activating our function using the import function
Debugging a program from a Python editor
Two ways to call our pv_f() function
Generating our own module
Types of comments
The first type of comment
The second type of comment
Finding information about our pv_f() function
The if() function
Annuity estimation
Converting the interest rates
Continuously compounded interest rate
A data type – list
Net present value and the NPV rule
Defining the payback period and the payback period rule
Defining IRR and the IRR rule
Showing certain files in a specific subdirectory
Using Python as a financial calculator
Adding our project directory to the path
Summary
Exercises
4. 13 Lines of Python to Price a Call Option
Writing a program – the empty shell method
Writing a program – the comment-all-out method
Using and debugging other programs
Summary
Exercises
5. Introduction to Modules
What is a module?
Importing a module
Adopting a short name for an imported module
Showing all functions in an imported module
Comparing "import math" and "from math import *"
Deleting an imported module
Importing only a few needed functions
Finding out all built-in modules
Finding out all the available modules
Finding the location of an imported module
More information about modules
Finding a specific uninstalled module
Module dependency
Summary
Exercises
6. Introduction to NumPy and SciPy
Installation of NumPy and SciPy
Launching Python from Anaconda
Examples of using NumPy
Examples of using SciPy
Showing all functions in NumPy and SciPy
More informatio...

Table of contents