Python for Finance: Analyze Big Financial Data

Python for Finance: Analyze Big Financial Data

Language: English

Pages: 606

ISBN: 1491945281

Format: PDF / Kindle (mobi) / ePub

The financial industry has adopted Python at a tremendous rate recently, with some of the largest investment banks and hedge funds using it to build core trading and risk management systems. This hands-on guide helps both developers and quantitative analysts get started with Python, and guides you through the most important aspects of using Python for quantitative finance.

Using practical examples through the book, author Yves Hilpisch also shows you how to develop a full-fledged framework for Monte Carlo simulation-based derivatives and risk analytics, based on a large, realistic case study. Much of the book uses interactive IPython Notebooks, with topics that include:

  • Fundamentals: Python data structures, NumPy array handling, time series analysis with pandas, visualization with matplotlib, high performance I/O operations with PyTables, date/time information handling, and selected best practices
  • Financial topics: mathematical techniques with NumPy, SciPy and SymPy such as regression and optimization; stochastics for Monte Carlo simulation, Value-at-Risk, and Credit-Value-at-Risk calculations; statistics for normality tests, mean-variance portfolio optimization, principal component analysis (PCA), and Bayesian regression
  • Special topics: performance Python for financial algorithms, such as vectorization and parallelization, integrating Python with Excel, and building financial applications based on Web technologies





















scenario plays out in the simple economy. [63] Cf. Williams (1991) on the probabilistic concepts. [64] Cf. Delbaen and Schachermayer (2004). [65] Adding a time component is actually a straightforward undertaking, which is nevertheless not done here for the ease of the exposition. [66] For the pricing of, for example, short-dated options, this assumption seems satisfied in many circumstances. [67] A unit zero-coupon bond pays exactly one currency unit at its maturity and no coupons between

plt.axis('tight') # adjusts the axis ranges Figure 5-4. Plot with grid and tight axes Other options for plt.axis are given in Table 5-1, the majority of which have to be passed as a string object. Table 5-1. Options for plt.axis Parameter DescriptionEmpty Returns current axis limits off Turns axis lines and labels off equal Leads to equal scaling scaled Equal scaling via dimension changes tight Makes all data visible (tightens limits) image Makes all data visible (with data limits)

volatilities implied by options on the EURO STOXX 50 index It is noteworthy that we now (indirectly) use implied volatilities, which relate to expectations with regard to the future volatility development, while the previous DAX analysis used historical volatility measures. For details, see the “VSTOXX Advanced Services” tutorial pages provided by Eurex. We begin with a few imports: In [62]: import pandas as pd from urllib import urlretrieveFor the analysis, we retrieve files from the Web and

overhead. In the case of numexpr, the string-based expression is evaluated once and then compiled for later use; with the Python eval function this evaluation takes place 500,000 times. Memory Layout and Performance NumPy allows the specification of a so-called dtype per ndarray object: for example, np.int32 or f8. NumPy also allows us to choose from two different memory layouts when initializing an ndarray object. Depending on the structure of the object, one layout can have advantages

differences to note. The first is that the valuation function is applied asynchronously via view.apply_sync to our cluster view, which in effect initiates the parallel valuation of all options at once. Of course, not all options can be valued in parallel because there are (generally) not enough cores/threads available. Therefore, we have to wait until the queue is completely finished; this is accomplished by the wait method of the Client object c. When all results are available, the function

Download sample