Reader small image

You're reading from  Mastering Python for Finance. - Second Edition

Product typeBook
Published inApr 2019
Reading LevelIntermediate
PublisherPackt
ISBN-139781789346466
Edition2nd Edition
Languages
Right arrow
Author (1)
James Ma Weiming
James Ma Weiming
author image
James Ma Weiming

James Ma Weiming is a software engineer based in Singapore. His studies and research are focused on financial technology, machine learning, data sciences, and computational finance. James started his career in financial services working with treasury fixed income and foreign exchange products, and fund distribution. His interests in derivatives led him to Chicago, where he worked with veteran traders of the Chicago Board of Trade to devise high-frequency, low-latency strategies to game the market. He holds an MS degree in finance from Illinois Tech's Stuart School of Business in the United States and a bachelor's degree in computer engineering from Nanyang Technological University.
Read more about James Ma Weiming

Right arrow

Deep Learning for Finance

Deep learning represents the very cutting edge of Artificial Intelligence (AI). Unlike machine learning, deep learning takes a different approach in making predictions by using a neural network. An artificial neural network is modeled on the human nervous system, consisting of an input layer and an output layer, with one or more hidden layers in between. Each layer consists of artificial neurons working in parallel and passing outputs to the next layer as inputs. The word deep in deep learning comes from the notion that as data passes through more hidden layers in an artificial neural network, more complex features can be extracted.

TensorFlow is an open source, powerful machine learning and deep learning framework developed by Google. In this chapter, we will take a hands-on approach to learning TensorFlow by building a deep learning model with four...

A brief introduction to deep learning

The theory behind deep learning began as early as the 1940s. However, its popularity has soared in recent years thanks in part to improvements in computing hardware technology, smarter algorithms, and the adoption of deep learning frameworks. There is much to cover beyond this book. This section serves as a quick guide to gain a working knowledge for following the examples that we will cover in later parts of this chapter.

What is deep learning ?

In Chapter 10, Machine Learning for Finance, we learned how machine learning is useful for making predictions. Supervised learning uses error-minimization techniques to fit a model with training data, and can be regression based or classification...

A deep learning price prediction model with TensorFlow

In this section, we will learn how to use TensorFlow as a deep learning framework in building a price prediction model. Five years of pricing data, from 2013 to 2017, will be used for training our deep learning model. We will attempt to predict the prices of Apple (AAPL) in the following year of 2018.

Feature engineering our model

The daily adjusted closing prices of our data make up the target variables. The independent variables defining the features of our model are made up of these technical indicators:

  • Relative strength index (RSI)
  • Williams %R (WR)
  • Awesome oscillator (AO)
  • Volume-weighted average price (VWAP)
  • Average daily trading volume (ADTV)
  • 5-day moving average...

Credit card payment default prediction with Keras

Another popular deep learning Python library is Keras. In this section, we will use Keras to build a credit card payment default prediction model, and see how easy it is to construct an artificial neural network with five hidden layers, apply activation functions, and train this model as compared to TensorFlow.

Introduction to Keras

Keras is an open source deep learning library in Python, designed to be high level, user friendly, modular, and extensible. Keras was conceived to be an interface rather than a standalone machine learning framework, running on top of TensorFlow, CNTK, and Theano. Its huge community base with over 200,000 users makes it one of the most...

Summary

In this chapter, we have been introduced to deep learning and the use of neural networks. An artificial neutral network consists of an input layer and an output layer, with one or more hidden layers in between. Each layer consists of artificial neurons, and each artificial neuron receives weighted inputs that are summed together with a bias. An activation function transforms these inputs into an output, and feeds it as input to another neuron.

Using the TensorFlow Python library, we built a deep learning model with four hidden layers to predict the prices of a security. The dataset is preprocessed by scaling and split into training and testing data. Designing an artificial neuron network involves two phases. The first phase is to assemble the graph, and the second phase is to train the model. A TensorFlow session object provides an execution environment, where training...

lock icon
The rest of the chapter is locked
You have been reading a chapter from
Mastering Python for Finance. - Second Edition
Published in: Apr 2019Publisher: PacktISBN-13: 9781789346466
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.
undefined
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 $15.99/month. Cancel anytime

Author (1)

author image
James Ma Weiming

James Ma Weiming is a software engineer based in Singapore. His studies and research are focused on financial technology, machine learning, data sciences, and computational finance. James started his career in financial services working with treasury fixed income and foreign exchange products, and fund distribution. His interests in derivatives led him to Chicago, where he worked with veteran traders of the Chicago Board of Trade to devise high-frequency, low-latency strategies to game the market. He holds an MS degree in finance from Illinois Tech's Stuart School of Business in the United States and a bachelor's degree in computer engineering from Nanyang Technological University.
Read more about James Ma Weiming