Python for Finance: Analyze Big Financial Data
Appendix A. Selected Best Practices Best practices in general are those rules, either written down formally ...
Python Syntax One really helpful feature of Spyder as an integrated development environment is its automatic syntax ...
Valuation Algorithm z = np.random.standard_normal(I) # pseudorandom numbers ST = S0 np.exp((r - 0.5 ...
Subtraction / Division * Multiplication % Modulo == Is equal? != Is not equal? < Is smaller? <= Is equal ...
Documentation The two main elements of Python documentation are: Inline documentation Inline documentation can in ...
for i in range( 3 , end, 2 ): if I % i == 0 : print “Number is not prime, it is divided by %d.” % i bre ...
Figure A-1. Screenshot of Spyder with custom function and nicely rendered documentation string ...
Unit Testing As a final best practice, we want to consider unit testing. Among the different testi ...
”’ Tests if function f calculates correctly. ”’ nt.assert_equal(f(4.), 4.) nt.assert_equal(f( 1000 ), 1000 ) nt.as ...
[ 84 ] The majority of (Python) editors allow us to configure the use of a certain number of spaces even ...
Appendix B. Call Option Class Example B-1 contains a class definition for a European call option in the ...
option = call_option(self.S0, self.K, self.T, self.r, sigma_est) for i in range(it): option.sigma -= (option.value() - ...
Figure B-1. Value of European call option Figure B-2. Vega of European call option Compared wit ...
The option class also lends itself pretty well to the visualization of option statistics. ...
Appendix C. Dates and Times As in the majority of scientific disciplines, dates and times play an importa ...
Python The datetime module from the Python standard library allows for the implementation of the most impo ...
which then gives you a time object: In [ 15 ]: t = dt.datetime.time(d) t Out[15]: datetime.time(10, 5, 30, ...
known as Greenwich Mean Time, or GMT). This represents a two-hour difference from the author’s time ...
‘US/Alaska’, ‘US/Arizona’, ...
NumPy Since NumPy 1.7, there has been native date-time information support in NumPy. The basic class is called da ...
«
20
21
22
23
24
25
26
27
28
29
»
Free download pdf