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
Newsletter Hub
Free Learning
Arrow right icon
timer SALE ENDS IN
0 Days
:
00 Hours
:
00 Minutes
:
00 Seconds
Mastering Python for Finance
Mastering Python for Finance

Mastering Python for Finance: Implement advanced state-of-the-art financial statistical applications using Python , Second Edition

Arrow left icon
Profile Icon James Ma Weiming
Arrow right icon
AU$24.99 per month
Full star icon Full star icon Half star icon Empty star icon Empty star icon 2.8 (9 Ratings)
Paperback Apr 2019 426 pages 2nd Edition
eBook
AU$33.99 AU$48.99
Paperback
AU$60.99
Subscription
Free Trial
Renews at AU$24.99p/m
Arrow left icon
Profile Icon James Ma Weiming
Arrow right icon
AU$24.99 per month
Full star icon Full star icon Half star icon Empty star icon Empty star icon 2.8 (9 Ratings)
Paperback Apr 2019 426 pages 2nd Edition
eBook
AU$33.99 AU$48.99
Paperback
AU$60.99
Subscription
Free Trial
Renews at AU$24.99p/m
eBook
AU$33.99 AU$48.99
Paperback
AU$60.99
Subscription
Free Trial
Renews at AU$24.99p/m

What do you get with a Packt Subscription?

Free for first 7 days. $24.99 p/m after that. Cancel any time!
Product feature icon Unlimited ad-free access to the largest independent learning library in tech. Access this title and thousands more!
Product feature icon 50+ new titles added per month, including many first-to-market concepts and exclusive early access to books as they are being written.
Product feature icon Innovative learning tools, including AI book assistants, code context explainers, and text-to-speech.
Product feature icon Thousands of reference materials covering every tech concept you need to stay up to date.
Subscribe now
View plans & pricing
Table of content icon View table of contents Preview book icon Preview Book

Mastering Python for Finance

Overview of Financial Analysis with Python

Since the publication of my previous book Mastering Python for Finance, there have been significant upgrades to Python itself and many third-party libraries. Many tools and features have been deprecated in favor of new ones. This chapter walks you through how to get the latest tools available and how to prepare the environment that will be used throughout the rest of the book.

We will be using Quandl for the majority of datasets covered in this book. Quandl is a platform that serves financial, economic, and alternative data. These sources of data are contributed by various data publishers, including the United Nations, World Bank, central banks, trading exchanges, investment research firms, and even members of the Quandl community. With the Python Quandl module, you can easily download datasets and perform financial analytics to derive...

Getting Python

At the time of writing, the latest Python version is 3.7.0. You may download the latest version for Windows, macOS X, Linux/UNIX, and other operating systems from the official Python website at https://www.python.org/downloads/. Follow the installation instructions to install the base Python interpreter on your operating system.

The installation process should add Python to your environment path. To check the version of your installed Python, type the following command into the terminal if you are using macOS X/Linux, or the command prompt on Windows:

$ python --version
Python 3.7.0
For easy installation of Python libraries, consider using an all-in-one Python distribution such as Anaconda (https://www.anaconda.com/download/), Miniconda (https://conda.io/miniconda.html), or Enthought Canopy (https://www.enthought.com/product/enthought-python-distribution/). Advanced...

Introduction to Quandl

Quandl is a platform that serves financial, economic, and alternative data. These sources of data are contributed by various data publishers, including the United Nations, World Bank, central banks, trading exchanges, and investment research firms.

With the Python Quandl module, you can easily get financial datasets into Python. Quandl offers free datasets, some of which are samples. Paid access is required for access to premium data products.

Setting up Quandl for your environment

The Quandl package requires the latest versions of NumPy and pandas. Additionally, we will require matplotlib for the rest of this chapter.

To install these packages, type the following code in your terminal window:

...

Plotting a time series chart

A simple and effective technique for analyzing time series data is by visualizing it on a graph, from which we can infer certain assumptions. This section will guide you through the process of downloading a dataset of stock prices from Quandl and plotting it on a price and volume graph. We will also cover plotting candlestick charts, which will give us more information than line charts.

Retrieving datasets from Quandl

Fetching data from Quandl into Python is fairly straightforward. Suppose we are interested in ABN Amro Group from the Euronext Stock Exchange. The ticker symbol in Quandl is EURONEXT/ABN. In a Jupyter notebook cell, run the following command:

In [ ]:
import quandl

# Replace...

Performing financial analytics on time series data

In this section, we will visualize some statistical properties of time series data used in financial analytics.

Plotting returns

One of the classic measures of security performance is its returns over a prior period. A simple method for calculating returns in pandas is pct_change, where the percentage change from the previous row is computed for every row in the DataFrame.

In the following example, we use ABN stock data to plot a simple graph of daily percentage returns:

In [ ]:
%matplotlib inline
import quandl

quandl.ApiConfig.api_key = QUANDL_API_KEY
df = quandl.get('EURONEXT/ABN.4')
daily_changes = df.pct_change(periods=1)
daily_changes...

Summary

In this chapter, we set up our working environment with Python 3.7 and used the virtual environment package to manage separate package installations. The pip command is a handy Python package manager that easily downloads and installs Python modules, including Jupyter, Quandl, and pandas. Jupyter is a browser-based interactive computational environment for executing Python code and visualizing data. With a Quandl account, we can easily obtain high-quality time series datasets. These sources of data are contributed by various data publishers. Datasets directly download into a pandas DataFrame object that allows us to perform financial analytics, such as plotting daily percentage returns, histograms, Q-Q plots, correlations, simple moving averages, and exponential moving averages.

Left arrow icon Right arrow icon
Download code icon Download Code

Key benefits

  • Explore advanced financial models used by the industry and ways of solving them using Python
  • Build state-of-the-art infrastructure for modeling, visualization, trading, and more
  • Empower your financial applications by applying machine learning and deep learning

Description

The second edition of Mastering Python for Finance will guide you through carrying out complex financial calculations practiced in the industry of finance by using next-generation methodologies. You will master the Python ecosystem by leveraging publicly available tools to successfully perform research studies and modeling, and learn to manage risks with the help of advanced examples. You will start by setting up your Jupyter notebook to implement the tasks throughout the book. You will learn to make efficient and powerful data-driven financial decisions using popular libraries such as TensorFlow, Keras, Numpy, SciPy, and scikit-learn. You will also learn how to build financial applications by mastering concepts such as stocks, options, interest rates and their derivatives, and risk analytics using computational methods. With these foundations, you will learn to apply statistical analysis to time series data, and understand how time series data is useful for implementing an event-driven backtesting system and for working with high-frequency data in building an algorithmic trading platform. Finally, you will explore machine learning and deep learning techniques that are applied in finance. By the end of this book, you will be able to apply Python to different paradigms in the financial industry and perform efficient data analysis.

Who is this book for?

If you are a financial or data analyst or a software developer in the financial industry who is interested in using advanced Python techniques for quantitative methods in finance, this is the book you need! You will also find this book useful if you want to extend the functionalities of your existing financial applications by using smart machine learning techniques. Prior experience in Python is required.

What you will learn

  • Solve linear and nonlinear models representing various financial problems
  • Perform principal component analysis on the DOW index and its components
  • Analyze, predict, and forecast stationary and non-stationary time series processes
  • Create an event-driven backtesting tool and measure your strategies
  • Build a high-frequency algorithmic trading platform with Python
  • Replicate the CBOT VIX index with SPX options for studying VIX-based strategies
  • Perform regression-based and classification-based machine learning tasks for prediction
  • Use TensorFlow and Keras in deep learning neural network architecture

Product Details

Country selected
Publication date, Length, Edition, Language, ISBN-13
Publication date : Apr 30, 2019
Length: 426 pages
Edition : 2nd
Language : English
ISBN-13 : 9781789346466
Category :
Languages :
Tools :

What do you get with a Packt Subscription?

Free for first 7 days. $24.99 p/m after that. Cancel any time!
Product feature icon Unlimited ad-free access to the largest independent learning library in tech. Access this title and thousands more!
Product feature icon 50+ new titles added per month, including many first-to-market concepts and exclusive early access to books as they are being written.
Product feature icon Innovative learning tools, including AI book assistants, code context explainers, and text-to-speech.
Product feature icon Thousands of reference materials covering every tech concept you need to stay up to date.
Subscribe now
View plans & pricing

Product Details

Publication date : Apr 30, 2019
Length: 426 pages
Edition : 2nd
Language : English
ISBN-13 : 9781789346466
Category :
Languages :
Tools :

Packt Subscriptions

See our plans and pricing
Modal Close icon
AU$24.99 billed monthly
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Simple pricing, no contract
AU$249.99 billed annually
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Choose a DRM-free eBook or Video every month to keep
Feature tick icon PLUS own as many other DRM-free eBooks or Videos as you like for just AU$5 each
Feature tick icon Exclusive print discounts
AU$349.99 billed in 18 months
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Choose a DRM-free eBook or Video every month to keep
Feature tick icon PLUS own as many other DRM-free eBooks or Videos as you like for just AU$5 each
Feature tick icon Exclusive print discounts

Frequently bought together


Stars icon
Total AU$ 189.97
Python for Finance Cookbook
AU$60.99
Learn Algorithmic Trading
AU$67.99
Mastering Python for Finance
AU$60.99
Total AU$ 189.97 Stars icon

Table of Contents

15 Chapters
Section 1: Getting Started with Python Chevron down icon Chevron up icon
Overview of Financial Analysis with Python Chevron down icon Chevron up icon
Section 2: Financial Concepts Chevron down icon Chevron up icon
The Importance of Linearity in Finance Chevron down icon Chevron up icon
Nonlinearity in Finance Chevron down icon Chevron up icon
Numerical Methods for Pricing Options Chevron down icon Chevron up icon
Modeling Interest Rates and Derivatives Chevron down icon Chevron up icon
Statistical Analysis of Time Series Data Chevron down icon Chevron up icon
Section 3: A Hands-On Approach Chevron down icon Chevron up icon
Interactive Financial Analytics with the VIX Chevron down icon Chevron up icon
Building an Algorithmic Trading Platform Chevron down icon Chevron up icon
Implementing a Backtesting System Chevron down icon Chevron up icon
Machine Learning for Finance Chevron down icon Chevron up icon
Deep Learning for Finance Chevron down icon Chevron up icon
Other Books You May Enjoy Chevron down icon Chevron up icon

Customer reviews

Top Reviews
Rating distribution
Full star icon Full star icon Half star icon Empty star icon Empty star icon 2.8
(9 Ratings)
5 star 33.3%
4 star 11.1%
3 star 0%
2 star 11.1%
1 star 44.4%
Filter icon Filter
Top Reviews

Filter reviews by




Amazon Customer Mar 27, 2022
Full star icon Full star icon Full star icon Full star icon Full star icon 5
Book was in perfect shape. Quick delivery.
Amazon Verified review Amazon
Alicia M. Sep 05, 2023
Full star icon Full star icon Full star icon Full star icon Full star icon 5
Llegó en buen estado y era lo que esperaba.
Amazon Verified review Amazon
Joseph R. Jul 19, 2019
Full star icon Full star icon Full star icon Full star icon Full star icon 5
This book is a must-read for anyone aspiring or practicing in the field of quantitative finance. James' work is extremely well-written, easy to follow, and detailed.As a financial engineer, I use numerical methods in my daily life; most of these I thought were only possible in lower-level languages. I was incredibly shocked to learn that all of these advanced mathematical methodologies can be written in Python and used for practical applications in algorithmic trading. In addition to walking the reader through these methods step-by-step, James teaches the reader how to build a real, working algorithmic trading strategy (several of them actually) and gives the reader the tools to backtest and implement the strategy for their own use!This is the first book, to my knowledge, that covers these incredibly important steps and does so in a way that programmers of all experience-levels can understand. Absolutely brilliant work!Note: The screenshot is taken from the output of my pairs trading (statistical arbitrage) strategy that I built and traded on InteractiveBrokers - all thanks to James' work!
Amazon Verified review Amazon
Robin T. Wernick Dec 09, 2020
Full star icon Full star icon Full star icon Full star icon Empty star icon 4
Trying to introduce the entire world of Finance Computing is a real stretch or any reference book and this one is short a few critical sections, but I applaud this effort to cover it all. Financial concepts and supporting mathematics are covered decently, but are largely isolated from the full coding examples. This may be because it will save space.Warning: As in the first edition, All code files are of type "ipynb". This will require the use of Jupyter Notebook to display them on screen! So get ready to learn a new IDE to apply this book. See Packt Books for code downloads.API access to Alpha Advantage and Quandl financial data sources are only superficially covered in the book. Critical program coding that explains the API is missing in both cases. I hope that the recommended Jupyter Notebook won't prove to be non intuitive to use to see all the supporting code.Finally, I missed seeing any coding support for access to databases such as MySQL or 'kdb'. I think the author is primarily a concept thinker and leaves the detail work to his assistants. But for us, we need more handholding to make the entire concept framework pay off. So I recommend that you add other references such as "Python GUI Programming Cookbook" and/or "Hands-On Web Scraping with Python" to fill in the missing pieces.
Amazon Verified review Amazon
Jesús Israel Dec 27, 2024
Full star icon Full star icon Empty star icon Empty star icon Empty star icon 2
Lamentablemente el libro esta desactualizado. La libreria para obtener datos del Nasdaq ya esta obsoleta!!.
Subscriber review Packt
Get free access to Packt library with over 7500+ books and video courses for 7 days!
Start Free Trial

FAQs

What is included in a Packt subscription? Chevron down icon Chevron up icon

A subscription provides you with full access to view all Packt and licnesed content online, this includes exclusive access to Early Access titles. Depending on the tier chosen you can also earn credits and discounts to use for owning content

How can I cancel my subscription? Chevron down icon Chevron up icon

To cancel your subscription with us simply go to the account page - found in the top right of the page or at https://subscription.packtpub.com/my-account/subscription - From here you will see the ‘cancel subscription’ button in the grey box with your subscription information in.

What are credits? Chevron down icon Chevron up icon

Credits can be earned from reading 40 section of any title within the payment cycle - a month starting from the day of subscription payment. You also earn a Credit every month if you subscribe to our annual or 18 month plans. Credits can be used to buy books DRM free, the same way that you would pay for a book. Your credits can be found in the subscription homepage - subscription.packtpub.com - clicking on ‘the my’ library dropdown and selecting ‘credits’.

What happens if an Early Access Course is cancelled? Chevron down icon Chevron up icon

Projects are rarely cancelled, but sometimes it's unavoidable. If an Early Access course is cancelled or excessively delayed, you can exchange your purchase for another course. For further details, please contact us here.

Where can I send feedback about an Early Access title? Chevron down icon Chevron up icon

If you have any feedback about the product you're reading, or Early Access in general, then please fill out a contact form here and we'll make sure the feedback gets to the right team. 

Can I download the code files for Early Access titles? Chevron down icon Chevron up icon

We try to ensure that all books in Early Access have code available to use, download, and fork on GitHub. This helps us be more agile in the development of the book, and helps keep the often changing code base of new versions and new technologies as up to date as possible. Unfortunately, however, there will be rare cases when it is not possible for us to have downloadable code samples available until publication.

When we publish the book, the code files will also be available to download from the Packt website.

How accurate is the publication date? Chevron down icon Chevron up icon

The publication date is as accurate as we can be at any point in the project. Unfortunately, delays can happen. Often those delays are out of our control, such as changes to the technology code base or delays in the tech release. We do our best to give you an accurate estimate of the publication date at any given time, and as more chapters are delivered, the more accurate the delivery date will become.

How will I know when new chapters are ready? Chevron down icon Chevron up icon

We'll let you know every time there has been an update to a course that you've bought in Early Access. You'll get an email to let you know there has been a new chapter, or a change to a previous chapter. The new chapters are automatically added to your account, so you can also check back there any time you're ready and download or read them online.

I am a Packt subscriber, do I get Early Access? Chevron down icon Chevron up icon

Yes, all Early Access content is fully available through your subscription. You will need to have a paid for or active trial subscription in order to access all titles.

How is Early Access delivered? Chevron down icon Chevron up icon

Early Access is currently only available as a PDF or through our online reader. As we make changes or add new chapters, the files in your Packt account will be updated so you can download them again or view them online immediately.

How do I buy Early Access content? Chevron down icon Chevron up icon

Early Access is a way of us getting our content to you quicker, but the method of buying the Early Access course is still the same. Just find the course you want to buy, go through the check-out steps, and you’ll get a confirmation email from us with information and a link to the relevant Early Access courses.

What is Early Access? Chevron down icon Chevron up icon

Keeping up to date with the latest technology is difficult; new versions, new frameworks, new techniques. This feature gives you a head-start to our content, as it's being created. With Early Access you'll receive each chapter as it's written, and get regular updates throughout the product's development, as well as the final course as soon as it's ready.We created Early Access as a means of giving you the information you need, as soon as it's available. As we go through the process of developing a course, 99% of it can be ready but we can't publish until that last 1% falls in to place. Early Access helps to unlock the potential of our content early, to help you start your learning when you need it most. You not only get access to every chapter as it's delivered, edited, and updated, but you'll also get the finalized, DRM-free product to download in any format you want when it's published. As a member of Packt, you'll also be eligible for our exclusive offers, including a free course every day, and discounts on new and popular titles.