elle
(Elle)
#1
Conclusions
Without going into too much detail, this chapter illustrates the use of Python by the means
of concrete and typical financial examples:
Calculation of implied volatilities
Using real-world data, in the form of a cross section of option data for a given day,
we calculate numerically the implied volatilities of European call options on the
VSTOXX volatility index. This example introduces some custom Python functions
(e.g., for analytical option valuation) and uses functionality from NumPy, SciPy, and
pandas.
Monte Carlo simulation
Using different implementation approaches, we simulate the evolution of an index
level over time and use our simulated end-of-period values to derive Monte Carlo
estimators for European call options. Using NumPy, the major benefits of vectorization
of Python code are illustrated: namely, compactness of code and speed of execution.
Backtesting of trend signal strategy
Using real historical time series data for the S&P 500, we backtest the performance
of a trading strategy based on signals generated by 42-day and 252-day trends
(moving averages). This example illustrates the capabilities and convenience of
pandas when it comes to time series analytics.
In terms of working with Python, this chapter introduces interactive financial analytics
(using the IPython interactive shell), working with more complex functions stored in
modules, as well as the performance-oriented implementation of algorithms using
vectorization. One important topic is not covered: namely, object orientation and classes in
Python. For the curious reader, Appendix B contains a class definition for a European call
option with methods based on the functions found in the code of Example 3-1 in this
chapter.