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

Using Python as a financial calculator


Based on what we have learned in this chapter, we are ready to put together about two dozen functions related to finance 101 or other finance courses, and call our final big program fin101.py. After debugging all the errors, we could call this module (program) easily by issuing the command from fin101 import *. A more detailed procedure of how to generate such an R-based financial calculator is as follows:

  1. Create an empty Python file called fin101.py and save it under our default directory, that is, Python33 in C:, or other designated directory.

  2. Add the pv_f() function to fin101.py, and debug the program until it is error free.

  3. Repeat the previous step by adding one function at a time until fin101.py includes all our functions.

  4. Generate a function called fin101, which is used to offer a list of all our included functions. A few lines are shown in the following code. Assuming that our fin101.py file has only two functions, we could generate a very simple...