Hands-On Financial Trading with Python
eBook - ePub

Hands-On Financial Trading with Python

A practical guide to using Zipline and other Python libraries for backtesting trading strategies

Jiri Pik, Sourav Ghosh

Buch teilen
  1. 360 Seiten
  2. English
  3. ePUB (handyfreundlich)
  4. Über iOS und Android verfügbar
eBook - ePub

Hands-On Financial Trading with Python

A practical guide to using Zipline and other Python libraries for backtesting trading strategies

Jiri Pik, Sourav Ghosh

Angaben zum Buch
Buchvorschau
Inhaltsverzeichnis
Quellenangaben

Über dieses Buch

Build and backtest your algorithmic trading strategies to gain a true advantage in the market

Key Features

  • Get quality insights from market data, stock analysis, and create your own data visualisations
  • Learn how to navigate the different features in Python's data analysis libraries
  • Start systematically approaching quantitative research and strategy generation/backtesting in algorithmic trading

Book Description

Creating an effective system to automate your trading can help you achieve two of every trader's key goals; saving time and making money. But to devise a system that will work for you, you need guidance to show you the ropes around building a system and monitoring its performance. This is where Hands-on Financial Trading with Python can give you the advantage.

This practical Python book will introduce you to Python and tell you exactly why it's the best platform for developing trading strategies. You'll then cover quantitative analysis using Python, and learn how to build algorithmic trading strategies with Zipline using various market data sources.

Using Zipline as the backtesting library allows access to complimentary US historical daily market data until 2018. As you advance, you will gain an in-depth understanding of Python libraries such as NumPy and pandas for analyzing financial datasets, and explore Matplotlib, statsmodels, and scikit-learn libraries for advanced analytics.

As you progress, you'll pick up lots of skills like time series forecasting, covering pmdarima and Facebook Prophet.

By the end of this trading book, you will be able to build predictive trading signals, adopt basic and advanced algorithmic trading strategies, and perform portfolio optimization to help you get —and stay—ahead of the markets.

What you will learn

  • Discover how quantitative analysis works by covering financial statistics and ARIMA
  • Use core Python libraries to perform quantitative research and strategy development using real datasets
  • Understand how to access financial and economic data in Python
  • Implement effective data visualization with Matplotlib
  • Apply scientific computing and data visualization with popular Python libraries
  • Build and deploy backtesting algorithmic trading strategies

Who this book is for

If you're a financial trader or a data analyst who wants a hands-on introduction to designing algorithmic trading strategies, then this book is for you. You don't have to be a fully-fledged programmer to dive into this book, but knowing how to use Python's core libraries and a solid grasp on statistics will help you get the most out of this book.

Häufig gestellte Fragen

Wie kann ich mein Abo kündigen?
Gehe einfach zum Kontobereich in den Einstellungen und klicke auf „Abo kündigen“ – ganz einfach. Nachdem du gekündigt hast, bleibt deine Mitgliedschaft für den verbleibenden Abozeitraum, den du bereits bezahlt hast, aktiv. Mehr Informationen hier.
(Wie) Kann ich Bücher herunterladen?
Derzeit stehen all unsere auf Mobilgeräte reagierenden ePub-Bücher zum Download über die App zur Verfügung. Die meisten unserer PDFs stehen ebenfalls zum Download bereit; wir arbeiten daran, auch die übrigen PDFs zum Download anzubieten, bei denen dies aktuell noch nicht möglich ist. Weitere Informationen hier.
Welcher Unterschied besteht bei den Preisen zwischen den Aboplänen?
Mit beiden Aboplänen erhältst du vollen Zugang zur Bibliothek und allen Funktionen von Perlego. Die einzigen Unterschiede bestehen im Preis und dem Abozeitraum: Mit dem Jahresabo sparst du auf 12 Monate gerechnet im Vergleich zum Monatsabo rund 30 %.
Was ist Perlego?
Wir sind ein Online-Abodienst für Lehrbücher, bei dem du für weniger als den Preis eines einzelnen Buches pro Monat Zugang zu einer ganzen Online-Bibliothek erhältst. Mit über 1 Million Büchern zu über 1.000 verschiedenen Themen haben wir bestimmt alles, was du brauchst! Weitere Informationen hier.
Unterstützt Perlego Text-zu-Sprache?
Achte auf das Symbol zum Vorlesen in deinem nächsten Buch, um zu sehen, ob du es dir auch anhören kannst. Bei diesem Tool wird dir Text laut vorgelesen, wobei der Text beim Vorlesen auch grafisch hervorgehoben wird. Du kannst das Vorlesen jederzeit anhalten, beschleunigen und verlangsamen. Weitere Informationen hier.
Ist Hands-On Financial Trading with Python als Online-PDF/ePub verfügbar?
Ja, du hast Zugang zu Hands-On Financial Trading with Python von Jiri Pik, Sourav Ghosh im PDF- und/oder ePub-Format sowie zu anderen beliebten Büchern aus Computer Science & Data Visualisation. Aus unserem Katalog stehen dir über 1 Million Bücher zur Verfügung.

Information

Jahr
2021
ISBN
9781838988807

Section 1: Introduction to Algorithmic Trading

This section will introduce you to important concepts in algorithmic trading and Python.
This section comprises the following chapter:
  • Chapter 1, Introduction to Algorithmic Trading and Python

Chapter 1: Introduction to Algorithmic Trading

In this chapter, we will take you through a brief history of trading and explain in which situations manual and algorithmic trading each make sense. Additionally, we will discuss financial asset classes, which are a categorization of the different types of financial assets. You will learn about the components of the modern electronic trading exchange, and, finally, we will outline the key components of an algorithmic trading system.
In this chapter, we will cover the following topics:
  • Walking through the evolution of algorithmic trading
  • Understanding financial asset classes
  • Going through the modern electronic trading exchange
  • Understanding the components of an algorithmic trading system

Walking through the evolution of algorithmic trading

The concept of trading one possession for another has been around since the beginning of time. In its earliest form, trading was useful for exchanging a less desirable possession for a more desirable possession. Eventually, with the passage of time, trading has evolved into participants trying to find a way to buy and hold trading instruments (that is, products) at prices perceived as lower than fair value in the hopes of being able to sell them in the future at a price higher than the purchase price. This buy-low-and-sell-high principle serves as the basis for all profitable trading to date; of course, how to achieve this is where the complexity and competition lies.
Markets are driven by the fundamental economic forces of supply and demand. As demand increases without a commensurate increase in supply, or supply decreases without a decrease in demand, a commodity becomes scarce and increases in value (that is, its market price). Conversely, if demand drops without a decrease in supply, or supply increases without an increase in demand, a commodity becomes more easily available and less valuable (a lower market price). Therefore, the market price of a commodity should reflect the equilibrium price based on available supply (sellers) and available demand (buyers).
There are many drawbacks to the manual trading approach, as follows:
  • Human traders are inherently slow at processing new market information, making them likely to miss information or to make errors in interpreting updated market data. This leads to bad trading decisions.
  • Humans, in general, are also prone to distractions and biases that reduce profits and/or generate losses. For example, the fear of losing money and the joy of making money also causes us to deviate from the optimal systematic trading approach, which we understand in theory but fail to execute in practice. In addition, people are also naturally and non-uniformly biased against profitable trades versus losing trades; for instance, human traders are quick to increase the amount of risk after profitable trades and slow down to decrease the amount of risk after losing trades.
  • Human traders learn by experiencing market conditions, for example, by being present and trading live markets. So, they cannot learn from and backtest over historical market data conditions – an important advantage of automated strategies, as we will see later.
With the advent of technology, trading has evolved from pit trading carried out by yelling and signaling buy and sell orders all the way to using sophisticated, efficient, and fast computer hardware and software to execute trades, often without much human intervention. Sophisticated algorithmic trading software systems have replaced human traders and engineers, and mathematicians who build, operate, and improve these systems, known as quants, have risen to power.
In particular, the key advantages of an automated, computer-driven systematic/algorithmic trading approach are as follows:
  • Computers are extremely good at performing clearly defined and repetitive rule-based tasks. They can perform these tasks extremely quickly and can handle massive throughputs.
  • Additionally, computers do not get distracted, tired, or make mistakes (unless there is a software bug, which, technically, counts as a software developer error).
  • Algorithmic trading strategies also have no emotions as far as trading through losses or profits; therefore, they can stick to a systematic trading plan no matter what.
All of these advantages make systematic algorithmic trading the perfect candidate to set up low-latency, high-throughput, scalable, and robust trading businesses.
However, algorithmic trading is not always better than manual trading:
  • Manual trading is better at dealing with significantly complex ideas and the complexities of real-world trading operations that are, sometimes, difficult to express as an automated software solution.
  • Automated trading systems require significant investments in time and R&D costs, while manual trading strategies are often significantly faster to get to market.
  • Algorithmic trading strategies are also prone to software development/operation bugs, which can have a significant impact on a trading business. Entire automated trading operations being wiped out in a matter of a few minutes is not unheard of.
  • Often, automated quantitative trading systems are not good at dealing with extremely unlikely events termed as black swan events, such as the LTCM crash, the 2010 flash crash, the Knight Capital crash, and more.
In this section, we learned about the history of trading and when automated/algorithmic is better than manual trading. Now, let's proceed toward the next section, where we will learn about the actual subject of trading categorized into financial asset classes.

Understanding financial asset classes

Algorithmic trading deals with the trading of financial assets. A financial asset is a non-physical asset whose value arises from contractual agreements.
The major financial asset classes are as follows:
  • Equities (stocks): These allow market participants to invest directly in the company and become owners of the company.
  • Fixed income (bonds): These represent a loan made by the investor to a borrower (for instance, a government or a firm). Each bond has its end date when the principal of the loan is due to be paid back and, usually, either fixed or variable interest payments made by the borrower over the lifetime of the bond.
  • Real Estate Investment Trusts (REITs): These are publicly traded companies that own or operate or finance income-producing real estate. These can be used as a proxy to directly invest in the housing market, say, by purchasing a property.
  • Commodities: Examples include metals (silver, gold, copper, and more) and agricultural produce (wheat, corn, milk, and more). They are financial assets tracking the price of the underlying commodities.
  • Exchange-Traded Funds (ETFs): An EFT is an exchange-listed security that tracks a collection of other securities. ETFs, such as SPY, DIA, and QQQ, hold equity stocks to track the larger well-known S&P 500, Dow Jones Industrial Average, and Nasdaq stock indices. ETFs such as United States Oil Fund (USO) track oil prices by investing in short-term WTI crude oil futures. ETFs are a convenient investment vehicle for investors to invest in a wide range of asset classes at relatively lower costs.
  • Foreign Exchange (FX) between different currency pairs, the major ones being the US Dollar (USD), Euro (EUR), Pound Sterling (GBP), Japanese Yen (JPY), Australian Dollar (AUD), New Zealand Dollar (NZD), Canadian Dollar (CAD), Swiss Franc (C...

Inhaltsverzeichnis