Movatterモバイル変換


[0]ホーム

URL:


Packt
Search iconClose icon
Search icon CANCEL
Subscription
0
Cart icon
Your Cart(0 item)
Close icon
You have no products in your basket yet
Save more on your purchases!discount-offer-chevron-icon
Savings automatically calculated. No voucher code required.
Profile icon
Account
Close icon

Change country

Modal Close icon
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletter Hub
Free Learning
Arrow right icon
timerSALE ENDS IN
0Days
:
00Hours
:
00Minutes
:
00Seconds
Home> Data> Data Analysis> Hands-On Financial Trading with Python
Hands-On Financial Trading with Python
Hands-On Financial Trading with Python

Hands-On Financial Trading with Python: A practical guide to using Zipline and other Python libraries for backtesting trading strategies

Arrow left icon
Profile Icon PikProfile Icon Sourav Ghosh
Arrow right icon
$33.99$37.99
Full star iconFull star iconFull star iconFull star iconHalf star icon4.4(14 Ratings)
eBookApr 2021360 pages1st Edition
eBook
$33.99 $37.99
Paperback
$46.99
Subscription
Free Trial
Renews at $19.99p/m
Arrow left icon
Profile Icon PikProfile Icon Sourav Ghosh
Arrow right icon
$33.99$37.99
Full star iconFull star iconFull star iconFull star iconHalf star icon4.4(14 Ratings)
eBookApr 2021360 pages1st Edition
eBook
$33.99 $37.99
Paperback
$46.99
Subscription
Free Trial
Renews at $19.99p/m
eBook
$33.99 $37.99
Paperback
$46.99
Subscription
Free Trial
Renews at $19.99p/m

What do you get with eBook?

Product feature iconInstant access to your Digital eBook purchase
Product feature icon Download this book inEPUB andPDF formats
Product feature icon Access this title in our online reader with advanced features
Product feature iconDRM FREE - Read whenever, wherever and however you want
Product feature iconAI Assistant (beta) to help accelerate your learning
OR

Contact Details

Modal Close icon
Payment Processing...
tickCompleted

Billing Address

Table of content iconView table of contentsPreview book icon Preview Book

Hands-On Financial Trading with 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 itsearliest 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 thehopes of being able to sell them in the future at a price higher than the purchase price. Thisbuy-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 thefundamental 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 aremany drawbacks to themanual trading approach, as follows:

  • Human tradersare 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 andbacktest 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 andsignaling 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 improvethese systems, known asquants, have risen to power.

Inparticular, the key advantages of anautomated, 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 theseadvantages 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 extremelyunlikely events termed asblack 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

Algorithmictrading 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): Theseallow 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 whenthe 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 companiesthat 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: Examplesinclude 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 tracksa 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 asUnited States Oil Fund (USO) track oil prices by investingin 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) betweendifferent currency pairs, the major ones being theUS Dollar (USD),Euro (EUR),Pound Sterling (GBP),Japanese Yen (JPY),Australian Dollar (AUD),New Zealand Dollar (NZD),Canadian Dollar (CAD),Swiss Franc (CHF),Norwegian Krone (NOK), andSwedish Krona (SEK). These are often referred to as the G10 currencies.
  • The keyFinancial derivatives are options and futures – these are complex leveragedderivative products that can magnify the risk as well as the reward:

    a)Futures are financialcontracts to buy or sell an asset at a predetermined future date and price.

    b)Options are financialcontracts giving their owner the right, but not the obligation, to buy or sell an underlying asset at a stated price (strike price) prior to or on a specified date.

In this section, we learned about the financial asset classes and their unique properties. Now, let's discuss the order types and exchange matching algorithms of modern electronic trading exchanges.

Going through the modern electronic trading exchange

The firsttrading exchange was the Amsterdam Stock Exchange, which began in 1602. Here, the trading happened in person. The applications of technology to trading included using pigeons, telegraph systems, Morse code, telephones, computer terminals, and nowadays, high-speed computer networks and state-of-the-art computers. With the passage of time, the trading microstructure has evolved into the order types and matching algorithms that we are used to today.

Knowledgeof the modern electronic trading exchange microstructure is important for the design of algorithmic strategies.

Order types

Financial trading strategies employ a variety of different order types, and some of the mostcommon ones include Market orders, Marketwith Price Protection orders,Immediate-Or-Cancel (IOC) orders,Fill and Kill (FAK) orders,Good-'Till-Day (GTD) orders,Good-'Till-Canceled (GTC) orders, Stop orders, and Iceberg orders.

For thestrategiesthat wewill be exploring in this book, we will focus on Market orders, IOC, and GTC.

Market orders

Marketorders are buy-or-sell orders that need to be executed instantly at the current market price and are used when the immediacy of execution is preferred to the execution price.

These orders will execute against all available orders on the opposite side at the order's price until all the quantity asked for is executed. If it runs out of available liquidity to match against, it can be configured tosit in the order book orexpire. Sitting in the book means the order becomes a resting order that is added to the book for other participants to trade against. To expire means that the remaining order quantity is canceled instead of being added to the book so that new orders cannot match against the remaining quantity.

So, for instance, a buy market order will match against all sell orders sitting in the book from the best price to the worst price until the entire market order is executed.

These orders may suffer from extremeslippage, which is defined as the difference in the executed order's price and the market price at the time the order was sent.

IOC orders

IOC orders cannot execute at prices worse than what they were sent for, which means buy orders cannot execute higher than the order's price, and sell orders cannot execute lower than the order's price. Thisconcept is known aslimit price since that price is limited to the worst price the order can execute at.

An IOCorder will continue matching against orders on the order side until one of the following happens:

  • The entire quantity on the IOC order is executed.
  • The price of the passive order on the other side is worse than the IOC order's price.
  • The IOC order is partially executed, and the remaining quantity expires.

An IOC order that is sent at a price better than the best available order on the other side (that is, the buy order is lower than the best offer price, or the sell order is higher than the best bid price) does not execute at all and just expires.

GTC orders

GTC orderscan persist indefinitely and require a specific cancellation order.

Limit order books

The exchangeaccepts order requests from all market participants and maintains them in alimit order book. Limit order books are a view into all the market participant's visible orders available at the exchange at any point in time.

Buy orders (orbids) are arranged from the highest price (that is, the best price) to the lowestprice (that is, the worst price), andAsk orders (that is,asks oroffers) arearranged from the lowest price (that is, the best price) to the highest price (that is, the lowest price).

The highest bid prices are considered the best bid prices because buy orders with the highest buy prices are the first to be matched, and the reverse is true for ask prices, that is, sell orders with the lowest sell prices match first.

Orders on the same side and at the same price level are arranged in theFirst-In-First-Out (FIFO) order, whichis also known as priority order – orderswith better priority are ahead of orders with lower priority because the better priority orders have reached the exchange before the others. All else being equal (that is, the same order side, price, and quantity), orders with better priority will execute before orders with worse priority.

The exchange matching engine

Thematching engine at the electronic trading exchange performs thematching of orders usingexchange matching algorithms. The process of matching entails checking all active ordersentered by market participants and matching the orders that cross each other in price until there are no unmatched orders that couldbe matched – so, buy orders with prices at or above other sell orders match against them, and the converse is true as well, that is, sell orders with prices at or below other buy orders match against them. The remaining orders remain in the exchange matching book until a new order flow comes in, leading to new matches if possible.

In the FIFO matching algorithm, orders are matched first – from the best price to the worst price. So, an incoming buy order tries to match against resting sell orders (that is, asks/offers) from the lowest price to the highest price, and an incoming sell order tries to match against resting buy orders (that is, bids) from the highest price to the lowest price. New incoming orders are matched with a specific sequence of rules. For incoming aggressive orders (orders with prices better than the best price level on the other side), they are matched on a first-come-first-serve basis, that is, orders that show up first, take out liquidity and, therefore, match first. For passive resting orders that sit in the book, since they do not execute immediately, they are assigned based on priority on a first-come-first-serve basis. That means orders on the same side and at the same price are arranged based on the time it takes them to reach the matching engine; orders with earlier times are assigned better priority and, therefore, are eligible to be matched first.

In this section, we learned about the order types and exchange matching engine of the modern electronic trading exchange. Now, let's proceed toward the next section, where we will learn about the components of an algorithmic trading system.

Understanding the components of an algorithmic trading system

A client-sidealgorithmic trading infrastructure can be broken down broadly into two categories:core infrastructure andquantitative infrastructure.

The core infrastructure of an algorithmic trading system

A core infrastructurehandles communication with the exchange using market data and order entry protocols. It is responsible for relaying informationbetween the exchange and the algorithmic trading strategy.

Its components are also responsible for capturing, timestamping, and recording historical market data, which is one of the top priorities for algorithmic trading strategy research and development.

The core infrastructure also includes a layer of risk management components to guard the trading system against erroneous or runaway trading strategies to prevent catastrophic outcomes.

Finally, some of the less glamorous tasks involved in the algorithmic trading business, such as back-office reconciliation tasks, compliance, and more, are also addressed by the core infrastructure.

Trading servers

The trading server involvesone or more computers receiving and processingmarket and other relevant data, and trading exchange information (for example, an order book), and issuing trading orders.

From thelimit order book, updates to the exchange matching book are disseminated to all market participants overmarket data protocols.

Market participants havetrading servers that receive these market data updates. While, technically, these trading servers can be anywhere in the world, modern algorithmic tradingparticipants have their trading servers placed in a data center very close to the exchange matching engine. This is called acolocated orDirect Market Access (DMA) setup, which guarantees that participants receive market dataupdates as fast as possible by being as close to the matching engine as possible.

Once the market data update, which is communicated via exchange-provided market data protocols, is received by each market participant, they use software applications known asmarket data feed handlers to decode the market data updates and feed it to thealgorithmic trading strategy on the client side.

Once thealgorithmic trading strategy has digested the market data update, based on the intelligence developed in the strategy, it generates outgoing order flow. This can be the addition, modification, or cancellation of orders at specific prices and quantities.

The orderrequests are picked up by an, often, separate client component known as theorder entry gateway. The order entry gateway componentcommunicates with the exchange usingorder entry protocols to translate this request from the strategy to the exchange. Notifications in response to these order requests are sent by the electronic exchange back to the order entry gateway. Again, in response to this order flow by a specific market participant, the matching engine generates market data updates, therefore going back to the beginning of this information flow loop.

The quantitative infrastructure of an algorithmic trading system

A quantitative infrastructure builds on top of the platform provided by the core infrastructureand, essentially, tries to build components on top to research, develop, and effectively leveragethe platform to generate revenue.

The research framework includes components such as backtesting,Post-Trade Analytics (PTA), and signal research components.

Othercomponents that are used in research as well as deployed to live markets would be limit order books, predictive signals, and signal aggregators, which combine individual signals into a composite signal.

Execution logiccomponents use trading signals and do the heavy lifting of managing live orders, positions, andProfit And Loss (PnL) across different strategies and trading instruments.

Finally, trading strategies themselves have a risk management component to manage and mitigate risk across different strategies and instruments.

Trading strategies

Profitable trading ideas have always been driven by human intuition developed from observingthe patterns of market conditions and the outcomes of various strategies under different market conditions.

For example, historically, it hasbeen observed that large market rallies generate investor confidence, causing more market participants to jump in and buy more; therefore, recursively causing larger rallies. Conversely, large drops in market prices scare off participants invested in the trading instrument, causing them to sell their holdings and exacerbate the drop in prices. These intuitive ideas backed by observationsin markets led to the idea oftrend-following strategies.

It has also been observed that short-term volatile moves in either direction often tend to revertto their previous market price, leading tomean reversion-based speculators and trading strategies. Similarly, historical observations that similar product prices move together, which also makes intuitivesense have led to the generation of correlationand collinearity-based trading strategies such asstatistical arbitrage andpairs trading strategies.

Since every market participant uses different trading strategies, the final market prices reflect the majority of market participants. Trading strategies whose views align with the majority of market participants are profitable under those conditions. A single trading strategy generally cannot be profitable 100 percent of the time, so sophisticated participants have a portfolio of trading strategies.

Trading signals

Tradingsignals are also referred to as features, calculators, indicators, predictors, or alpha.

Trading signalsare what drive algorithmic trading strategy decisions. Signals are well-defined pieces of intelligence derived from market data, alternative data (such as news, social media feeds, and more), and even our own order flow, which is designed to predict certain market conditions in the future.

Signals almost always originate from some intuitive idea and observation of certain market conditions and/or strategy performance. Often, most quantitative developers spend most of their time researching anddeveloping new trading signals to improve profitability under different market conditions and to improve the algorithmic trading strategy overall.

The trading signal research framework

A lotof man-hours are invested in researching and discovering new signals to improvetrading performance. To do that in a systematic, efficient, scalable, andscientific manner, often, the first step is to build a goodsignal research framework.

This framework has subcomponents for the following:

  • Data generation is based on the signal we are trying to build and the market conditions/objectives we are trying to capture/predict. In most real-world algorithmic trading, we use tick data, which is data that represents every single event in the market. As you might imagine, there are a lot of events every day and this leads to massive amounts of data, so you also need to think about subsamplingthe data received.Subsampling has several advantages, such as reducing the scale of data, eliminating the noise/spurious patches of data, and highlighting interesting/important data.
  • The evaluation of the predictive power or usefulness of features concerning the market objective that they are trying to capture/predict.
  • The maintenance of historical results of signals under different market conditions along with tuning existing signals to changing market conditions.

Signal aggregators

Signal aggregators areoptional components that take inputsfrom individual signals and aggregate them in different ways to generate a new composite signal.

A very simple aggregation method would be to take the average of all the input signals and output the average as the composite signal value.

Readersfamiliar with statistical learning concepts of ensemble learning – bagging and boosting – might be able to spot a similarity between those learning modelsand signal aggregators. Oftentimes signal aggregators are just statistical models (regression/classification) where the input signals are just features used to predict the same final market objective.

The execution of strategies

The executionof strategies deals withefficiently managing and executing orders based on the outputs of the trading signals to minimize trading fees and slippage.

Slippage is thedifference between market prices and execution prices and is caused due to the latency experienced by an order to get to the market before prices change as well as the size of an order causing a change in price once it hits the market.

The quality of execution strategies employed in an algorithmic trading strategy can significantly improve/degrade the performance of profitable trading signals.

Limit order books

Limit order books are built both in the exchange match engine and during the algorithmictrading strategies, although notnecessarily all algorithmic trading signals/strategies require the entire limit order book.

Sophisticated algorithmic trading strategies can build a lot more intelligence into their limit order books. We can detect and track our own orders in the limit book and understand, given our priority, what our probability of getting our orders executed is. We can also use this information to execute our own orders even before the order entry gateway gets the execution notification from the exchange and leverage that ability to our advantage. Other more complex microstructure features such as detecting icebergs, detecting stop orders, detecting large in-flow or out-flow of buy/sell orders, and more are all possible with limit order books and market data updates at a lot of electronic trading exchanges.

Position and PnL management

Let's explore how positions and PnLs evolve as a trading strategy opens and closes long and short positions by executing trades.

When astrategy does not have a position in the market, that is, price changes do not affect the trading account's value, it is referred to as having a flat position.

From aflat position, if a buy order executes, then it is referred to as having a long position. If a strategy has a long position and prices increase, the position profits from the price increase. PnL also increases in this scenario, that is, profit increases (or loss decreases). Conversely, if a strategy has a long position and prices decrease, the position loses from the price decrease. PnL decreases in this scenario, for example, the profit decreases (or the loss increases).

From a flat position, if a sell order is executed then it is referred to as having a short position. If a strategy has a short position and prices decrease, the position profits from the price decrease. PnL increases in this scenario. Conversely, if a strategy has a short position andprices increase, then PnL decreases. PnL for a position that is still open is referred to asunrealized PnL since PnL changes with price changes as long as the position remains open.

A long position is closed by selling an amount of the instrument equivalent to the position size. This is referred to as closing or flattening a position, and, at this point, PnL isreferred to asrealized PnL since it no longer changes as price changes since the position is closed.

Similarly, short positions are closed by buying the same amount as the position size.

At any point, thetotal PnL is thesum of realized PnLs on all closed positions and unrealized PnLs on all open positions.

When along or short position is composed of buys or sells at multiple prices with different sizes, then the average price of the position is computed by computing theVolume Weighted Average Price (VWAP), which is the price of each execution weighted by the quantity executed at each price. Marking to market refers to taking the VWAP of a position and comparing that to the current market price to get a sense of how profitable or lossy a certain long/short position is.

Backtesting

A backtester uses historically recorded market data and simulation components to simulatethe behavior and performance of an algorithmic trading strategy as if it were deployed to live markets in the past. Algorithmictrading strategies are developed and optimized using a backtester until the strategy performance is in line with expectations.

Backtesters are complex components that need to model market data flow, client-side and exchange-side latencies in software and network components, accurate FIFO priorities, slippage, fees, and market impact from strategy order flow (that is, how would other market participants react to a strategy's order flow being added to the market data flow) to generate accurate strategy and portfolio performance statistics.

PTA

PTA is performed on trades generated by an algorithmic trading strategy run in simulation or live markets.

PTA systemsare used to generate performance statisticsfrom historically backtested strategies with the objective to understand historical strategy performance expectations.

When applied to trades generated from live trading strategies, PTA can be used to understand strategy performance in live markets as well as compare and assert that live trading performance is in line with simulated strategy performance expectations.

Risk management

Good riskmanagement principles ensurethat strategies are run for optimal PnL performance and safeguards are put in place against runaway/errant strategies.

Bad risk management cannot only turn a profitable trading strategy into a non-profitable one but can also put the investor's entire capital at risk due to uncontrolled strategy losses, malfunctioning strategies, and possible regulatory repercussions.

Summary

In this chapter, we have learned when algorithmic trading has an advantage over manual trading, what the financial asset classes are, the most used order types, what the limit order book is, and how the orders are matched by the financial exchange.

We have also discussed the key components of an algorithmic trading system – the core infrastructure and the quantitative infrastructure which consists of trading strategies, their execution, limit order book, position, PnL management, backtesting, post-trade analytics, and risk management.

In the next chapter, we will discuss the value of Python when it comes to algorithmic trading.

Left arrow icon

Page1 of 6

Right arrow icon
Download code iconDownload Code

Key benefits

  • 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

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.

Who is this book 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.

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

Product Details

Country selected
Publication date, Length, Edition, Language, ISBN-13
Publication date :Apr 29, 2021
Length:360 pages
Edition :1st
Language :English
ISBN-13 :9781838988807
Category :
Languages :
Concepts :
Tools :

What do you get with eBook?

Product feature iconInstant access to your Digital eBook purchase
Product feature icon Download this book inEPUB andPDF formats
Product feature icon Access this title in our online reader with advanced features
Product feature iconDRM FREE - Read whenever, wherever and however you want
Product feature iconAI Assistant (beta) to help accelerate your learning
OR

Contact Details

Modal Close icon
Payment Processing...
tickCompleted

Billing Address

Product Details

Publication date :Apr 29, 2021
Length:360 pages
Edition :1st
Language :English
ISBN-13 :9781838988807
Category :
Languages :
Concepts :
Tools :

Packt Subscriptions

See our plans and pricing
Modal Close icon
$19.99billed monthly
Feature tick iconUnlimited access to Packt's library of 7,000+ practical books and videos
Feature tick iconConstantly refreshed with 50+ new titles a month
Feature tick iconExclusive Early access to books as they're written
Feature tick iconSolve problems while you work with advanced search and reference features
Feature tick iconOffline reading on the mobile app
Feature tick iconSimple pricing, no contract
$199.99billed annually
Feature tick iconUnlimited access to Packt's library of 7,000+ practical books and videos
Feature tick iconConstantly refreshed with 50+ new titles a month
Feature tick iconExclusive Early access to books as they're written
Feature tick iconSolve problems while you work with advanced search and reference features
Feature tick iconOffline reading on the mobile app
Feature tick iconChoose a DRM-free eBook or Video every month to keep
Feature tick iconPLUS own as many other DRM-free eBooks or Videos as you like for just $5 each
Feature tick iconExclusive print discounts
$279.99billed in 18 months
Feature tick iconUnlimited access to Packt's library of 7,000+ practical books and videos
Feature tick iconConstantly refreshed with 50+ new titles a month
Feature tick iconExclusive Early access to books as they're written
Feature tick iconSolve problems while you work with advanced search and reference features
Feature tick iconOffline reading on the mobile app
Feature tick iconChoose a DRM-free eBook or Video every month to keep
Feature tick iconPLUS own as many other DRM-free eBooks or Videos as you like for just $5 each
Feature tick iconExclusive print discounts

Frequently bought together


Hands-On Financial Trading with Python
Hands-On Financial Trading with Python
Read more
Apr 2021360 pages
Full star icon4.4 (14)
eBook
eBook
$33.99$37.99
$46.99
Hands-On Data Analysis with Pandas
Hands-On Data Analysis with Pandas
Read more
Apr 2021788 pages
Full star icon4.6 (14)
eBook
eBook
$45.99$51.99
$64.99
Graph Machine Learning
Graph Machine Learning
Read more
Jun 2021338 pages
Full star icon4.1 (22)
eBook
eBook
$37.99$42.99
$52.99
Stars icon
Total$164.97
Hands-On Financial Trading with Python
$46.99
Hands-On Data Analysis with Pandas
$64.99
Graph Machine Learning
$52.99
Total$164.97Stars icon

Table of Contents

13 Chapters
Section 1: Introduction to Algorithmic TradingChevron down iconChevron up icon
Section 1: Introduction to Algorithmic Trading
Chapter 1: Introduction to Algorithmic TradingChevron down iconChevron up icon
Chapter 1: Introduction to Algorithmic Trading
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
Summary
Section 2: In-Depth Look at Python Libraries for the Analysis of Financial DatasetsChevron down iconChevron up icon
Section 2: In-Depth Look at Python Libraries for the Analysis of Financial Datasets
Chapter 2: Exploratory Data Analysis in PythonChevron down iconChevron up icon
Chapter 2: Exploratory Data Analysis in Python
Technical requirements
Introduction to EDA
Special Python libraries for EDA
Summary
Chapter 3: High-Speed Scientific Computing Using NumPyChevron down iconChevron up icon
Chapter 3: High-Speed Scientific Computing Using NumPy
Technical requirements
Introduction to NumPy
Creating NumPy ndarrays
Data types used with NumPy ndarrays
Indexing of ndarrays
Basic ndarray operations
File operations on ndarrays
Summary
Chapter 4: Data Manipulation and Analysis with pandasChevron down iconChevron up icon
Chapter 4: Data Manipulation and Analysis with pandas
Technical requirements
Introducing pandas Series, pandas DataFrames, and pandas Indexes
Learning essential pandas.DataFrame operations
Exploring file operations with pandas.DataFrames
Summary
Chapter 5: Data Visualization Using MatplotlibChevron down iconChevron up icon
Chapter 5: Data Visualization Using Matplotlib
Technical requirements
Creating figures and 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
Summary
Chapter 6: Statistical Estimation, Inference, and PredictionChevron down iconChevron up icon
Chapter 6: Statistical Estimation, Inference, and Prediction
Technical requirements
Introduction to statsmodels
Using a SARIMAX time series model with pmdarima
Time series forecasting with Facebook's Prophet library
Introduction to scikit-learn regression and classification
Summary
Section 3: Algorithmic Trading in PythonChevron down iconChevron up icon
Section 3: Algorithmic Trading in Python
Chapter 7: Financial Market Data Access in PythonChevron down iconChevron up icon
Chapter 7: Financial Market Data Access in Python
Technical requirements
Exploring the yahoofinancials Python library
Exploring the pandas_datareader Python library
Exploring the Quandl data source
Exploring the IEX Cloud data source
Exploring the MarketStack data source
Summary
Chapter 8: Introduction to Zipline and PyFolioChevron down iconChevron up icon
Chapter 8: Introduction to Zipline and PyFolio
Technical requirements
Introduction to Zipline and PyFolio
Installing Zipline and PyFolio
Importing market data into a Zipline/PyFolio backtesting system
Structuring Zipline/PyFolio backtesting modules
Reviewing the key Zipline API reference
Running Zipline backtesting from the command line
Introduction to risk management with PyFolio
Summary
Chapter 9: Fundamental Algorithmic Trading StrategiesChevron down iconChevron up icon
Chapter 9: Fundamental Algorithmic Trading Strategies
Technical requirements
What is an algorithmic trading strategy?
Learning momentum-based/trend-following strategies
Learning mean-reversion strategies
Learning mathematical model-based strategies
Learning time series prediction-based strategies
Summary
Other Books You May EnjoyChevron down iconChevron up icon
Other Books You May Enjoy
Packt is searching for authors like you
Leave a review - let other readers know what you think

Recommendations for you

Left arrow icon
LLM Engineer's Handbook
LLM Engineer's Handbook
Read more
Oct 2024522 pages
Full star icon4.9 (28)
eBook
eBook
$47.99
$59.99
Getting Started with Tableau 2018.x
Getting Started with Tableau 2018.x
Read more
Sep 2018396 pages
Full star icon4 (3)
eBook
eBook
$38.99$43.99
$54.99
Python for Algorithmic Trading Cookbook
Python for Algorithmic Trading Cookbook
Read more
Aug 2024404 pages
Full star icon4.2 (20)
eBook
eBook
$42.99$47.99
$59.99
RAG-Driven Generative AI
RAG-Driven Generative AI
Read more
Sep 2024338 pages
Full star icon4.3 (18)
eBook
eBook
$31.99$35.99
$43.99
Machine Learning with PyTorch and Scikit-Learn
Machine Learning with PyTorch and Scikit-Learn
Read more
Feb 2022774 pages
Full star icon4.4 (96)
eBook
eBook
$38.99$43.99
$54.99
$79.99
Building LLM Powered  Applications
Building LLM Powered Applications
Read more
May 2024342 pages
Full star icon4.2 (22)
eBook
eBook
$35.98$39.99
$49.99
Python Machine Learning By Example
Python Machine Learning By Example
Read more
Jul 2024518 pages
Full star icon4.9 (9)
eBook
eBook
$32.99$36.99
$45.99
AI Product Manager's Handbook
AI Product Manager's Handbook
Read more
Nov 2024488 pages
eBook
eBook
$31.99$35.99
$44.99
Right arrow icon

Customer reviews

Top Reviews
Rating distribution
Full star iconFull star iconFull star iconFull star iconHalf star icon4.4
(14 Ratings)
5 star64.3%
4 star14.3%
3 star14.3%
2 star7.1%
1 star0%
Filter icon Filter
Top Reviews

Filter reviews by




aditya KarampudiAug 24, 2021
Full star iconFull star iconFull star iconFull star iconFull star icon5
I was initially skeptical about the contents of this one, but after going through few chapters, I got the overall structure of the book. It is a latest version that uses zipline and also FB time series library. I have enjoyed it and requires quite some understanding of statistics, regression for better utilization of the book. Overall, it is a great book for trading and definitely worth a try!
Amazon Verified reviewAmazon
Rodolphe DesbordesJul 20, 2021
Full star iconFull star iconFull star iconFull star iconFull star icon5
For someone like me, with no knowledge of Python and trading, I have found this book extremely useful. The structure is logic, the content is accessible and informative. I would recommend this book to data scientists, academics, and financial traders who want to explore algorithmic trading using Python core libraries.
Amazon Verified reviewAmazon
Dan OrmsbyAug 18, 2021
Full star iconFull star iconFull star iconFull star iconFull star icon5
If you need to understand python and trading. This is the book for you! Clearly written with good example code.
Amazon Verified reviewAmazon
Kevin J. DaveyMay 08, 2021
Full star iconFull star iconFull star iconFull star iconFull star icon5
This book does a fine job at giving detailed, practical advice for how to use Python and available libraries to test and algo trade. Consider it a welcome timesaver, that allows the user to concentrate on actually building strategies. I believe many will find it useful.
Amazon Verified reviewAmazon
TalJun 16, 2021
Full star iconFull star iconFull star iconFull star iconFull star icon5
The coverage of this book is great, from algorithmic trading, to presentation of data (charting) including discussion on digesting and manipulating the data for trading.The book uses a hands on approach and the latest Python packages. Highly recommended to anyone in the financial trading field.
Amazon Verified reviewAmazon
  • Arrow left icon Previous
  • 1
  • 2
  • 3
  • Arrow right icon Next

People who bought this also bought

Left arrow icon
Causal Inference and Discovery in Python
Causal Inference and Discovery in Python
Read more
May 2023466 pages
Full star icon4.5 (50)
eBook
eBook
$38.99$43.99
$53.99
Generative AI with LangChain
Generative AI with LangChain
Read more
Dec 2023376 pages
Full star icon4 (34)
eBook
eBook
$56.99$63.99
$79.99
Modern Generative AI with ChatGPT and OpenAI Models
Modern Generative AI with ChatGPT and OpenAI Models
Read more
May 2023286 pages
Full star icon4.2 (35)
eBook
eBook
$35.98$39.99
$49.99
Deep Learning with TensorFlow and Keras – 3rd edition
Deep Learning with TensorFlow and Keras – 3rd edition
Read more
Oct 2022698 pages
Full star icon4.6 (45)
eBook
eBook
$35.98$39.99
$49.99
Machine Learning Engineering  with Python
Machine Learning Engineering with Python
Read more
Aug 2023462 pages
Full star icon4.6 (38)
eBook
eBook
$35.98$39.99
$49.99
Right arrow icon

About the authors

Left arrow icon
Profile icon Pik
Pik
LinkedIn iconGithub icon
Jiri Pik is an artificial intelligence architect & strategist who works with major investment banks, hedge funds, and other players. He has architected and delivered breakthrough trading, portfolio, and risk management systems, as well as decision support systems, across numerous industries. Jiri's consulting firm, Jiri Pik—RocketEdge, provides its clients with certified expertise, judgment, and execution at the speed of light.
Read more
See other products by Pik
Profile icon Sourav Ghosh
Sourav Ghosh
Sourav Ghosh has worked in several proprietary, high-frequency algorithmic trading firms over the last decade. He has built and deployed extremely low latency, high-throughput automated trading systems for trading exchanges around the world, across multiple asset classes. He specializes in statistical arbitrage market-making and pairs trading strategies with the most liquid global futures contracts. He is currently the vice president at an investment bank based in São Paulo, Brazil. He holds a master's in computer science from the University of Southern California. His areas of interest include computer architecture, FinTech, probability theory and stochastic processes, statistical learning and inference methods, and natural language processing.
Read more
See other products by Sourav Ghosh
Right arrow icon
Getfree access to Packt library with over 7500+ books and video courses for 7 days!
Start Free Trial

FAQs

How do I buy and download an eBook?Chevron down iconChevron up icon

Where there is an eBook version of a title available, you can buy it from the book details for that title. Add either the standalone eBook or the eBook and print book bundle to your shopping cart. Your eBook will show in your cart as a product on its own. After completing checkout and payment in the normal way, you will receive your receipt on the screen containing a link to a personalised PDF download file. This link will remain active for 30 days. You can download backup copies of the file by logging in to your account at any time.

If you already have Adobe reader installed, then clicking on the link will download and open the PDF file directly. If you don't, then save the PDF file on your machine and download the Reader to view it.

Please Note: Packt eBooks are non-returnable and non-refundable.

Packt eBook and Licensing When you buy an eBook from Packt Publishing, completing your purchase means you accept the terms of our licence agreement. Please read the full text of the agreement. In it we have tried to balance the need for the ebook to be usable for you the reader with our needs to protect the rights of us as Publishers and of our authors. In summary, the agreement says:

  • You may make copies of your eBook for your own use onto any machine
  • You may not pass copies of the eBook on to anyone else
How can I make a purchase on your website?Chevron down iconChevron up icon

If you want to purchase a video course, eBook or Bundle (Print+eBook) please follow below steps:

  1. Register on our website using your email address and the password.
  2. Search for the title by name or ISBN using the search option.
  3. Select the title you want to purchase.
  4. Choose the format you wish to purchase the title in; if you order the Print Book, you get a free eBook copy of the same title. 
  5. Proceed with the checkout process (payment to be made using Credit Card, Debit Cart, or PayPal)
Where can I access support around an eBook?Chevron down iconChevron up icon
  • If you experience a problem with using or installing Adobe Reader, the contact Adobe directly.
  • To view the errata for the book, see www.packtpub.com/support and view the pages for the title you have.
  • To view your account details or to download a new copy of the book go to www.packtpub.com/account
  • To contact us directly if a problem is not resolved, use www.packtpub.com/contact-us
What eBook formats do Packt support?Chevron down iconChevron up icon

Our eBooks are currently available in a variety of formats such as PDF and ePubs. In the future, this may well change with trends and development in technology, but please note that our PDFs are not Adobe eBook Reader format, which has greater restrictions on security.

You will need to use Adobe Reader v9 or later in order to read Packt's PDF eBooks.

What are the benefits of eBooks?Chevron down iconChevron up icon
  • You can get the information you need immediately
  • You can easily take them with you on a laptop
  • You can download them an unlimited number of times
  • You can print them out
  • They are copy-paste enabled
  • They are searchable
  • There is no password protection
  • They are lower price than print
  • They save resources and space
What is an eBook?Chevron down iconChevron up icon

Packt eBooks are a complete electronic version of the print edition, available in PDF and ePub formats. Every piece of content down to the page numbering is the same. Because we save the costs of printing and shipping the book to you, we are able to offer eBooks at a lower cost than print editions.

When you have purchased an eBook, simply login to your account and click on the link in Your Download Area. We recommend you saving the file to your hard drive before opening it.

For optimal viewing of our eBooks, we recommend you download and install the free Adobe Reader version 9.


[8]ページ先頭

©2009-2025 Movatter.jp