Hands-On Financial Trading with Python: A practical guide to using Zipline and other Python libraries for backtesting trading strategies
Book information
Description
Discover how to build and backtest algorithmic trading strategies with Zipline Key FeaturesGet to grips with market data and stock analysis and visualize data to gain quality insightsFind out how to systematically approach quantitative research and strategy generation/backtesting in algorithmic tradingLearn how to navigate the different features in Python's data analysis librariesBook Description Algorithmic trading helps you stay ahead of the markets by devising strategies in quantitative analysis to gain profits and cut losses. The book starts by introducing you to algorithmic trading and explaining why Python is 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. You'll also focus on 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. What you will learnDiscover how quantitative analysis works by covering financial statistics and ARIMAUse core Python libraries to perform quantitative research and strategy development using real datasetsUnderstand how to access financial and economic data in PythonImplement effective data visualization with MatplotlibApply scientific computing and data visualization with popular Python librariesBuild and deploy backtesting algorithmic trading strategiesWho this book is for This book is for data analysts and financial traders who want to explore how to design algorithmic trading strategies using Python's core libraries. If you are looking for a practical guide to backtesting algorithmic trading strategies and building your own strategies, then this book is for you. Beginner-level working knowledge of Python programming and statistics will be helpful. Table of ContentsIntroduction to algorithmic tradingExploratory Data Analysis in PythonHigh-speed Scientific Computing using NumPyData Manipulation and Analysis with PandasData Visualization using MatplotlibStatistical Estimation, Inference, and PredictionFinancial Market Data Access in PythonIntroduction to Zipline and PyFolioFundamental algorithmic trading strategies Cover Copyright Contributors Table of Contents Preface 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 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 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 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 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 Other Books You May Enjoy Index
Similar books
Hands-On Financial Trading with Python
2021 · EPUB
Hands-On Financial Trading with Python: A practical guide to using Zipline and other Python libraries for backtesting trading strategies
2021 · EPUB
Building Low Latency Applications with C++: Develop a complete low latency trading ecosystem from scratch using modern C++
2023 · EPUB
Developing High Frequency Trading Systems: Learn how to implement high-frequency trading from scratch with C++ or Java basics
2022 · PDF
Learn Algorithmic Trading: Build and deploy algorithmic trading systems and strategies using Python and advanced data analysis
2019 · PDF
MySQL® Notes for Professionals book
2018 · PDF
MrExcel 2022: Boosting Excel
2022 · PDF
MrExcel 2022: Boosting Excel
2022 · PDF