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
About the Author
About the Reviewers

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 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 and save it under our default directory, that is, Python33 in C:, or other designated directory.

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

  3. Repeat the previous step by adding one function at a time until 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 file has only two functions, we could generate a very simple...