Search icon CANCEL
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Mastering Python for Finance

You're reading from   Mastering Python for Finance Understand, design, and implement state-of-the-art mathematical and statistical applications used in finance with Python

Arrow left icon
Product type Paperback
Published in Apr 2015
Publisher Packt
ISBN-13 9781784394516
Length 340 pages
Edition 1st Edition
Languages
Arrow right icon
Toc

Table of Contents (12) Chapters Close

Preface 1. Python for Financial Applications FREE CHAPTER 2. The Importance of Linearity in Finance 3. Nonlinearity in Finance 4. Numerical Procedures 5. Interest Rates and Derivatives 6. Interactive Financial Analytics with Python and VSTOXX 7. Big Data with Python 8. Algorithmic Trading 9. Backtesting 10. Excel with Python Index

Correlation between SX5E and V2TX


We can use the corr function to derive the correlation values between each column of values in the pandas DataFrame object, as in the following Python example:

>>> print log_returns.corr()
           EUROSTOXX    VSTOXX
EUROSTOXX   1.000000 -0.732545
VSTOXX     -0.732545  1.000000
[2 rows x 2 columns]

At -0.7325, the EURO STOXX 50 Index is negatively correlated with the STOXX. To help us better visualize this relationship, we can plot both the sets of the daily log return values as a scatter plot. The statsmodels.api module is used to obtain the ordinary least squares regression line between the scattered data:

>>> import statsmodels.api as sm
>>>
>>> log_returns.plot(figsize=(10,8),
...                  x="EUROSTOXX", 
...                  y="VSTOXX",
...                  kind='scatter')
>>>
>>> ols_fit = sm.OLS(log_returns['VSTOXX'].values, 
...             log_returns['EUROSTOXX'].values).fit()
&gt...
lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime