
Hands-On Financial Trading with Python: A practical guide to using Zipline and other Python libraries for backtesting trading strategies
- Length: 489 pages
- Edition: 1
- Language: English
- Publisher: Packt Publishing
- Publication Date: 2021-05-11
- ISBN-10: 1838982884
- ISBN-13: 9781838982881
- Sales Rank: #2204135 (See Top 100 Books)
Discover how to perform accurate algorithmic trading using Quantopian and the pyfinance ecosystem
Key Features
- Get to grips with financial statistics and stock analysis and visualize data to gain quality insights
- Find out how to systematically approach quantitative research and strategy generation in automated trading
- Learn how to navigate significant number of features in Python data manipulation libraries
Book Description
Algorithmic trading, also known as automated trading, helps you stay ahead of the market by devising strategies in quantitative analysis to gain profits and cut losses. This book will help you to understand financial theories and execute a range of algorithmic trading strategies confidently.
The book starts by introducing you to algorithmic trading, the pyfinance ecosystem, and Quantopian. You’ll then cover algorithmic trading and quantitative analysis using Python, and learn how to build algorithmic trading strategies on Quantopian. As you advance, you’ll gain an in-depth understanding of Python libraries such as NumPy and pandas for analyzing financial datasets, and also explore Matplotlib, statsmodels, and scikit-learn libraries for advanced analytics. Moving on, you’ll explore useful financial concepts and theories such as financial statistics, leveraging and hedging, and short selling that will help you understand how financial markets operate. Finally, you will discover mathematical models and approaches for analyzing and understanding financial time series data.
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 on the Quantopian platform.
What you will learn
- Understand key financial theories such as the market hypothesis, the capital asset pricing model, and portfolio optimization
- Discover how quantitative analysis works, covering key techniques like financial statistics and ARIMA models
- Use core Python libraries to perform quantitative research and strategy development using real datasets
- Perform quantitative research on Quantopian financial datasets
- Build and deploy algo trading strategies
- Assemble Python libraries with backtesting frameworks and explore financial concepts to master quantitative trading
Who This Book Is For
This book is for data analysts and financial traders who want to explore algo trading using Python core libraries. If you are looking for a practical guide to execute various algorithmic trading strategies, then this book is for you. Basic working knowledge of Python programming and statistics will be helpful.
Hands-On Financial Trading with Python Contributors About the authors About the reviewer Preface Who this book is for What this book covers To get the most out of this book Download the example code files Download the color images Conventions used Get in touch Reviews Section 1: Introduction to Algorithmic Trading Chapter 1: Introduction to Algorithmic Trading Walking through the evolution of algorithmic trading Understanding financial asset classes Going through the modern electronic trading exchange Order types Limit order books The exchange matching engine Understanding the components of an algorithmic trading system The core infrastructure of an algorithmic trading system The quantitative infrastructure of an algorithmic trading system Summary Section 2: In-Depth Look at Python Libraries for the Analysis of Financial Datasets Chapter 2: Exploratory Data Analysis in Python Technical requirements Introduction to EDA Steps in EDA Revelation of the identity of A, B, and C and EDA's conclusions Special Python libraries for EDA Summary Chapter 3: High-Speed Scientific Computing Using NumPy Technical requirements Introduction to NumPy Creating NumPy ndarrays Creating 1D ndarrays Creating 2D ndarrays Creating any-dimension ndarrays Creating an ndarray with np.zeros(...) Creating an ndarray with np.ones(...) Creating an ndarray with np.identity(...) Creating an ndarray with np.arange(...) Creating an ndarray with np.random.randn(…) Data types used with NumPy ndarrays Creating a numpy.float64 array Creating a numpy.bool array ndarrays' dtype attribute Converting underlying data types of ndarray with numpy.ndarrays.astype(...) Indexing of ndarrays Direct access to an ndarray's element ndarray slicing Boolean indexing Indexing with arrays Basic ndarray operations Scalar multiplication with an ndarray Linear combinations of ndarrays Exponentiation of ndarrays Addition of an ndarray with a scalar Transposing a matrix Changing the layout of an ndarray Finding the minimum value in an ndarray Calculating the absolute value Calculating the mean of an ndarray Finding the index of the maximum value in an ndarray Calculating the cumulative sum of elements of an ndarray Finding NaNs in an ndarray Finding the truth values of x1>x2 of two ndarrays any and all Boolean operations on ndarrays Sorting ndarrays Searching within ndarrays File operations on ndarrays File operations with text files File operations with binary files Summary Chapter 4: Data Manipulation and Analysis with pandas Technical requirements Introducing pandas Series, pandas DataFrames, and pandas Indexes pandas.Series pandas.DataFrame pandas.Index Learning essential pandas.DataFrame operations Indexing, selection, and filtering of DataFrames Dropping rows and columns from a DataFrame Sorting values and ranking the values' order within a DataFrame Arithmetic operations on DataFrames Merging and combining multiple DataFrames into a single DataFrame Hierarchical indexing Grouping operations in DataFrames Transforming values in DataFrames' axis indices Handling missing data in DataFrames The transformation of DataFrames with functions and mappings Discretization/bucketing of DataFrame values Permuting and sampling DataFrame values to generate new DataFrames Exploring file operations with pandas.DataFrames CSV files JSON files Summary Chapter 5: Data Visualization Using Matplotlib Technical requirements Creating figures and subplots Defining figures' subplots Plotting in subplots Enriching plots with colors, markers, and line styles Enriching axes with ticks, labels, and legends Enriching data points with annotations Saving plots to files Charting a pandas DataFrame with Matplotlib Creating line plots of a DataFrame column Creating bar plots of a DataFrame column Creating histogram and density plots of a DataFrame column Creating scatter plots of two DataFrame columns Plotting time series data Summary Chapter 6: Statistical Estimation, Inference, and Prediction Technical requirements Introduction to statsmodels Normal distribution test with Q-Q plots Time series modeling with statsmodels ETS analysis of a time series Augmented Dickey-Fuller test for stationarity of a time series Autocorrelation and partial autocorrelation of a time series ARIMA time series model Using a SARIMAX time series model with pmdarima Time series forecasting with Facebook's Prophet library Introduction to scikit-learn regression and classification Generating the dataset Running RidgeCV regression on the dataset Running a classification method on the dataset Summary Section 3: Algorithmic Trading in Python Chapter 7: Financial Market Data Access in Python Technical requirements Exploring the yahoofinancials Python library Single-ticker retrieval Multiple-tickers retrieval Exploring the pandas_datareader Python library Access to Yahoo Finance Access to EconDB Access to the Federal Reserve Bank of St Louis' FRED Caching queries Exploring the Quandl data source Exploring the IEX Cloud data source Exploring the MarketStack data source Summary Chapter 8: Introduction to Zipline and PyFolio Technical requirements Introduction to Zipline and PyFolio Installing Zipline and PyFolio Installing Zipline Installing PyFolio Importing market data into a Zipline/PyFolio backtesting system Importing data from the historical Quandl bundle Importing data from the CSV files bundle Importing data from custom bundles Structuring Zipline/PyFolio backtesting modules Trading happens every day Trading happens on a custom schedule Reviewing the key Zipline API reference Types of orders Commission models Slippage models Running Zipline backtesting from the command line Introduction to risk management with PyFolio Market volatility, PnL variance, and PnL standard deviation Trade-level Sharpe ratio Maximum drawdown Summary Chapter 9: Fundamental Algorithmic Trading Strategies Technical requirements What is an algorithmic trading strategy? Learning momentum-based/trend-following strategies Rolling window mean strategy Simple moving averages strategy Exponentially weighted moving averages strategy RSI strategy MACD crossover strategy RSI and MACD strategies Triple exponential average strategy Williams R% strategy Learning mean-reversion strategies Bollinger band strategy Pairs trading strategy Learning mathematical model-based strategies Minimization of the portfolio volatility strategy with monthly trading Maximum Sharpe ratio strategy with monthly trading Learning time series prediction-based strategies SARIMAX strategy Prophet strategy Summary Appendix A: How to Setup a Python Environment Technical requirements Initial setup Downloading the complimentary Quandl data bundle Why subscribe? Other Books You May Enjoy Packt is searching for authors like you Leave a review - let other readers know what you think
How to download source code?
1. Go to: https://github.com/PacktPublishing
2. In the Find a repository… box, search the book title: Hands-On Financial Trading with Python: A practical guide to using Zipline and other Python libraries for backtesting trading strategies
, sometime you may not get the results, please search the main title.
3. Click the book title in the search results.
3. Click Code to download.
1. Disable the AdBlock plugin. Otherwise, you may not get any links.
2. Solve the CAPTCHA.
3. Click download link.
4. Lead to download server to download.