Python for Finance: Analyze Big Financial Data
In [ 45 ]: plt.figure(figsize=( 8 , 4 )) plt.plot(strikes, option_values_seq, ‘b’, label=‘Sequential’) plt.plot(strik ...
multiprocessing The advantage of IPython.parallel is that it scales over small- and medium-sized clusters ( ...
Figure 8-4. Execution speed depending on the number of threads used (eight-core machine) EASY PARALLELIZATION ...
Dynamic Compiling Numba is an open source, NumPy-aware optimizing compiler for Python code. It uses the LLVM ...
systematically: In [ 62 ]: func_list = [‘f_py’, ‘f_np’, ‘f_nb’] data_list = 3 * [‘I, J’] In [ 63 ]: perf_com ...
Risk-neutral discounting Discount the (expected) inner values at maturity step by step to arrive at the pr ...
of random numbers will lead to (slightly) different estimates. 20,000 paths per simulation can also be con ...
[ 0.987, 0.994, 1. , 1.006, 1.013], [ 0.981, 0.987, 0.994, 1. , ...
Memory: with Numba there is no need to initialize large array objects; the compiler specializes the m ...
Static Compiling with Cython The strength of Numba is the effortless application of the approach to arbitr ...
In [ 84 ]: from nested_loop import f_cy Now, we can check the performance of the Cython function: In [ 85 ]: %time res ...
Generation of Random Numbers on GPUs The last topic in this chapter is the use of devices for massively para ...
t0 = t.time() a = get_randoms(i, 1 ) t1 = t.time() cpu_times.append(t1 - t0) t2 = t.time() a = get_cuda_ran ...
Figure 8-6. Random number generation on GPU and CPU (factor = 10) Now let’s consider a test series wit ...
Conclusions Nowadays, the Python ecosystem provides a number of ways to improve the performance of code: Paradigm ...
Further Reading For all performance libraries introduced in this chapter, there are valuable web resources ava ...
Chapter 9. Mathematical Tools The mathematicians are the priests of the modern world. — Bill Gaede Since the ar ...
Approximation To begin with, let us import the libraries that we need for the moment — NumPy and matplotlib. ...
Monomials as basis functions One of the simplest cases is to take monomials as basis functions — i.e. ...
account for the sin part of the example function: In [ 6 ]: plt.plot(x, f(x), ‘b’, label=‘f(x)’) plt.plot(x, ry, ‘ ...
«
6
7
8
9
10
11
12
13
14
15
»
Free download pdf