Importing the math module
When learning finance with real-world data, we deal with many issues such as downloading data from Yahoo! finance, choosing an optimal portfolio, estimating volatility for individual stocks or for a portfolio, and constructing an efficient frontier. For each subject (topic), experts develop a specific module (package). To use them, we have to import them. For example, we can use import math
to import all basic math functions. In the following codes, we calculate the square root of a value:
>>>import math >>>math.sqrt(3) 1.732050807568772
To find out all functions contained in the math
module, we call the dir()
function again as follows:
>>>import math >>>dir(math) ['__doc__', '__loader__', '__name__', '__package__', 'acos', 'acosh', 'asin', 'asinh', 'atan', 'atan2', 'atanh', 'ceil', 'copysign', &apos...