Search icon
Subscription
0
Cart icon
Close icon
You have no products in your basket yet
Arrow left icon
All Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletters
Free Learning
Arrow right icon
Python for Finance

You're reading from  Python for Finance

Product type Book
Published in Apr 2014
Publisher
ISBN-13 9781783284375
Pages 408 pages
Edition 1st Edition
Languages
Author (1):
Yuxing Yan Yuxing Yan
Profile icon Yuxing Yan

Table of Contents (20) Chapters

Python for Finance
Credits
About the Author
Acknowledgments
About the Reviewers
www.PacktPub.com
Preface
Introduction and Installation of Python Using Python as an Ordinary Calculator Using Python as a Financial Calculator 13 Lines of Python to Price a Call Option Introduction to Modules Introduction to NumPy and SciPy Visual Finance via Matplotlib Statistical Analysis of Time Series The Black-Scholes-Merton Option Model Python Loops and Implied Volatility Monte Carlo Simulation and Options Volatility Measures and GARCH Index

Ways to launch Python


There are three ways to launch Python and they are explained in the following sections.

Launching Python with GUI

To launch Python, perform the following steps:

  1. Click on Start and then on All Programs.

  2. Find Python 3.3.

  3. Click on IDLE (Python GUI) as shown in the following screenshot:

  4. After Python starts, the following window appears:

Assume that an estimate of $100 is expected to be received in one year with an annual discount rate of 10 percent. The present value of one future cash flow is as follows:

In this equation, PV is the present value, FV is the future value, R is the discount rate, and n is the number of periods. According to the preceding formula, we could manually type those values to get the present value of this one future cash flow. Assume that we would receive $100 in one year. If the annual discount rate is 10 percent, what is the present value of this $100? For this, let's take a look at the following lines of code:

>>>100/(1+0.1)
90.9090909090909
>>>

Note

The triple larger than signs (>>>) is the Python prompt.

It is a good idea to create a Python icon on your desktops for your convenience. In addition to the preceding method, there are other methods to launch Python; see the next two sections: Launching Python from the Python command line and Launching Python from our own DOS window.

Launching Python from the Python command line

A new user could skip this section and go to the Quitting Python section because learning how to launch Python with GUI is more than enough. There are two reasons for this. The first is because we know how to launch Python by using Python IDLE or by clicking on the Python icon on our desktops, and the second reason is that we could save and run our Python programs easily using Python IDLE.

To launch Python from the Python command line, we have to perform the following steps:

  1. Click on Start and then on All Programs.

  2. Find Python 3.3.

  3. Click on Python (command line) as shown in the following screenshot:

  4. After we click on Python (command line), we will see the following window:

Launching Python from our own DOS window

We could generate our own DOS window, and then launch Python from there. In addition, we could navigate to the subdirectory, which contains our Python programs. In order to this, perform the following steps:

  1. Open a Window command line by clicking on Start and then enter cmd in the run window as shown in the following screenshot:

  2. Type cd c:\python33 to move to the appropriate directory.

  3. Type python to run the software as shown in the following screenshot:

If we want to launch Python anywhere else, we have to include the path of our Python directory. Assume that after installation we have python33 in C:. Replace step 2 with the following DOS command:

set path=%path%;C:\python33
You have been reading a chapter from
Python for Finance
Published in: Apr 2014 Publisher: ISBN-13: 9781783284375
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $15.99/month. Cancel anytime}