Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Python for Finance Cookbook

You're reading from   Python for Finance Cookbook Over 50 recipes for applying modern Python libraries to financial data analysis

Arrow left icon
Product type Paperback
Published in Jan 2020
Publisher Packt
ISBN-13 9781789618518
Length 432 pages
Edition 1st Edition
Languages
Tools
Arrow right icon
Author (1):
Arrow left icon
Eryk Lewinson Eryk Lewinson
Author Profile Icon Eryk Lewinson
Eryk Lewinson
Arrow right icon
View More author details
Toc

Table of Contents (12) Chapters Close

Preface 1. Financial Data and Preprocessing 2. Technical Analysis in Python FREE CHAPTER 3. Time Series Modeling 4. Multi-Factor Models 5. Modeling Volatility with GARCH Class Models 6. Monte Carlo Simulations in Finance 7. Asset Allocation in Python 8. Identifying Credit Default with Machine Learning 9. Advanced Machine Learning Models in Finance 10. Deep Learning in Finance 11. Other Books You May Enjoy

To get the most out of this book

For this book, we assume that you have the following:

  • A good understanding of programming in Python and machine/deep learning models
  • Knowledge of how to use popular libraries, such as NumPy, pandas, and matplotlib
  • Knowledge of basic statistics and quantitative finance

In this book, we attempt to give you a high-level overview of various techniques; however, we will focus on the practical applications of these methods. For a deeper dive into the theoretical foundations, we provide references for further reading.

The best way to learn anything is by doing. That is why we highly encourage you to experiment with the code samples provided (the code can be found in the accompanying GitHub repository), apply the techniques to different datasets, and explore possible extensions.

The code for this book was successfully run on a MacBook; however, it should work on any operating system. Additionally, you can always use online services such as Google Colab.

At the very beginning of each notebook (available on the book's GitHub repository), we run
a few cells that import and set up plotting with matplotlib. We will not mention this later on, as this would be repetitive, so at any time, assume that matplotlib is imported.

In the first cell, we first set up the backend of matplotlib to inline:

%matplotlib inline
%config InlineBackend.figure_format = 'retina'

By doing so, each plotted figure will appear below the cell that generated it and the plot will also be visible in the Notebook should it be exported to another format (such as PDF or
HTML). The second line is used for MacBooks and displays the plot in higher resolution for
Retina displays.
The second cell appears as follows:

import matplotlib.pyplot as plt
import warnings

plt.style.use('seaborn')
plt.rcParams['figure.figsize'] = [16, 9]
plt.rcParams['figure.dpi'] = 300
warnings.simplefilter(action='ignore', category=FutureWarning)

In this cell, we import matplotlib and warnings, set up the style of the plots to
'seaborn' (this is a personal preference), as well as default plot settings, such as figure
size and resolution. We also disable (ignore) some warnings. In some chapters, we might
modify these settings for better readability of the figures (especially in black and white).

Download the example code files

You can download the example code files for this book from your account at www.packt.com. If you purchased this book elsewhere, you can visit www.packtpub.com/support and register to have the files emailed directly to you.

You can download the code files by following these steps:

  1. Log in or register at www.packt.com.
  2. Select the Support tab.
  3. Click on Code Downloads.
  4. Enter the name of the book in the Search box and follow the onscreen instructions.

Once the file is downloaded, please make sure that you unzip or extract the folder using the latest version of:

  • WinRAR/7-Zip for Windows
  • Zipeg/iZip/UnRarX for Mac
  • 7-Zip/PeaZip for Linux

The code bundle for the book is also hosted on GitHub at https://github.com/PacktPublishing/Book-Name. In case there's an update to the code, it will be updated on the existing GitHub repository.

We also have other code bundles from our rich catalog of books and videos available at https://github.com/PacktPublishing/. Check them out!

Download the color images

Conventions used

There are a number of text conventions used throughout this book.

CodeInText: Indicates code words in text, database table names, folder names, filenames, file extensions, pathnames, dummy URLs, user input, and Twitter handles. Here is an example: "Finally, we took the natural logarithm of the divided values by using np.log."

A block of code is set as follows:

df_yahoo = yf.download('AAPL', 
start='2000-01-01',
end='2010-12-31',
progress=False)

Bold: Indicates a new term, an important word, or words that you see on screen. For example, words in menus or dialog boxes appear in the text like this. Here is an example: "A single candlestick (typically corresponding to one day, but a higher frequency is possible) combines the open, high, low, and close prices (OHLC)."

Warnings or important notes appear like this.
Tips and tricks appear like this.
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
Banner background image