Hands-On AI Trading with Python, QuantConnect, and AWS (eBook)
882 Seiten
Wiley (Verlag)
978-1-394-26766-8 (ISBN)
Master the art of AI-driven algorithmic trading strategies through hands-on examples, in-depth insights, and step-by-step guidance
Hands-On AI Trading with Python, QuantConnect, and AWS explores real-world applications of AI technologies in algorithmic trading. It provides practical examples with complete code, allowing readers to understand and expand their AI toolbelt.
Unlike other books, this one focuses on designing actual trading strategies rather than setting up backtesting infrastructure. It utilizes QuantConnect, providing access to key market data from Algoseek and others. Examples are available on the book's GitHub repository, written in Python, and include performance tearsheets or research Jupyter notebooks.
The book starts with an overview of financial trading and QuantConnect's platform, organized by AI technology used:
- Examples include constructing portfolios with regression models, predicting dividend yields, and safeguarding against market volatility using machine learning packages like SKLearn and MLFinLab.
- Use principal component analysis to reduce model features, identify pairs for trading, and run statistical arbitrage with packages like LightGBM.
- Predict market volatility regimes and allocate funds accordingly.
- Predict daily returns of tech stocks using classifiers.
- Forecast Forex pairs' future prices using Support Vector Machines and wavelets.
- Predict trading day momentum or reversion risk using TensorFlow and temporal CNNs.
- Apply large language models (LLMs) for stock research analysis, including prompt engineering and building RAG applications.
- Perform sentiment analysis on real-time news feeds and train time-series forecasting models for portfolio optimization.
- Better Hedging by Reinforcement Learning and AI: Implement reinforcement learning models for hedging options and derivatives with PyTorch.
- AI for Risk Management and Optimization: Use corrective AI and conditional portfolio optimization techniques for risk management and capital allocation.
Written by domain experts, including Jiri Pik, Ernest Chan, Philip Sun, Vivek Singh, and Jared Broad, this book is essential for hedge fund professionals, traders, asset managers, and finance students. Integrate AI into your next algorithmic trading strategy with Hands-On AI Trading with Python, QuantConnect, and AWS.
JIRI PIK: Founder and CEO of RocketEdge.com. A software architect and cloud computing expert, Jiri Pik specializes in designing high-performance trading systems. He has decades of experience in financial technologies and has worked with some of the world's leading financial institutions, including Goldman Sachs and JPMorgan Chase.
ERNEST P. CHAN: A pioneer in applying machine learning to quantitative trading, Ernest P. Chan founded Predictnow.ai and QTS Capital Management. He is author of books such as Quantitative Trading and Machine Trading.
JARED BROAD: Founder and CEO of QuantConnect?, Jared Broad has empowered over 300,000 algorithmic traders worldwide with a platform that simplifies strategy design, backtesting, and live deployment.
PHILIP SUN: CEO and Co-founder of Adaptive Investment Solutions, LLC, and a seasoned quantitative fund manager, Philip Sun and his team focus on building state-of-the-art AI-driven risk management platform for wealth advisors and institutional investors.
VIVEK SINGH: A product leader at Amazon Web Services (AWS), Vivek Singh spearheads the development of large language models (LLMs) and Generative AI applications, bringing cutting-edge AI technologies to the trading domain.
Master the art of AI-driven algorithmic trading strategies through hands-on examples, in-depth insights, and step-by-step guidance Hands-On AI Trading with Python, QuantConnect, and AWS explores real-world applications of AI technologies in algorithmic trading. It provides practical examples with complete code, allowing readers to understand and expand their AI toolbelt. Unlike other books, this one focuses on designing actual trading strategies rather than setting up backtesting infrastructure. It utilizes QuantConnect, providing access to key market data from Algoseek and others. Examples are available on the book's GitHub repository, written in Python, and include performance tearsheets or research Jupyter notebooks. The book starts with an overview of financial trading and QuantConnect's platform, organized by AI technology used: Examples include constructing portfolios with regression models, predicting dividend yields, and safeguarding against market volatility using machine learning packages like SKLearn and MLFinLab. Use principal component analysis to reduce model features, identify pairs for trading, and run statistical arbitrage with packages like LightGBM. Predict market volatility regimes and allocate funds accordingly. Predict daily returns of tech stocks using classifiers. Forecast Forex pairs' future prices using Support Vector Machines and wavelets. Predict trading day momentum or reversion risk using TensorFlow and temporal CNNs. Apply large language models (LLMs) for stock research analysis, including prompt engineering and building RAG applications. Perform sentiment analysis on real-time news feeds and train time-series forecasting models for portfolio optimization. Better Hedging by Reinforcement Learning and AI: Implement reinforcement learning models for hedging options and derivatives with PyTorch. AI for Risk Management and Optimization: Use corrective AI and conditional portfolio optimization techniques for risk management and capital allocation. Written by domain experts, including Jiri Pik, Ernest Chan, Philip Sun, Vivek Singh, and Jared Broad, this book is essential for hedge fund professionals, traders, asset managers, and finance students. Integrate AI into your next algorithmic trading strategy with Hands-On AI Trading with Python, QuantConnect, and AWS.
Chapter 1
Foundations of Capital Markets
This chapter introduces the core concepts of modern financial markets and how they’re represented in QuantConnect. We’ll cover the modern US markets, data feeds, and the asset classes used in later chapters. Readers who are familiar with QuantConnect may skip this chapter.
Market Mechanics
The United States has 11 major stock exchanges. The two largest are the New York Stock Exchange (NYSE) and the National Association of Securities Dealers Automated Quotations System (NASDAQ). Trades on these exchanges are compiled by the Securities Information Processor (SIP) into a single data feed. This feed helps the Securities and Exchange Commission (SEC) determine the national best bid or offer (NBBO), which shows the best prices posted on public markets in the United States. When a new quote for more than 100 shares offers a better price, it is flagged as the NBBO. Quotes or trades involving fewer than 100 shares, known as odd lots, are excluded from this pricing. Figure 1.1 illustrates this flow.
Figure 1.1 Flow of retail and institutional traffic across public and private markets, and the origin of national best pricing.
Brokerages often send orders to market makers to be executed “off the market.” Market makers executing these orders are required to provide fills within the NBBO price range. Furthermore, these off-market trades are reported to the Trade Reporting Facility (TRF) and eventually are included in the SIP data feed. Some brokers offer Direct Market Access (DMA), which allows your orders to be routed directly to a specific exchange. However, using DMA might not always get you the best national price for the asset, so it’s important to be careful when using this option.
Market Participants
Trading Is the “Play”
If markets are theaters, then trading is the “play.” Like a Shakespearean play, trading, especially algorithmic trading, is a highly coordinated and scripted activity. Comparing trading to the Bard’s plays will probably make Shakespeare turn in his grave. But he will forgive this literary enthusiast for the forced metaphor.
The Stage and Basic Rules of Trading—The Limit Order Book
To stretch this analogy further, the stage of trading is the “limit order book,” which is a ledger of some sort that lists limit order prices of a security in columns. On the left side is the column of bid prices, that is, prices traders are willing to buy a security at, and the amounts or “sizes” of the orders (for stocks, the sizes are typically in multiples of round lots of 100 shares; and for futures and options, in numbers of contracts). On the opposite side of this ledger is the column of ask prices, that is, prices traders are willing to sell a security at, and sizes. The prices are usually sorted from high to low from top to bottom, with the best bid and ask meeting in the middle. Bid prices cannot be higher than ask prices, that is, bid and ask prices do not cross, otherwise the buyers and sellers will be able to fulfill each other’s order in a way that benefits one or both sides. Any buy orders that enter the market higher than current best ask price is effectively a market order and will be matched up to the size of the best ask price, and then the next best ask price and so on, until entire buy orders are filled in a process called “walk-the-book,” or when remaining ask prices are above the best bid price. Because of this, a trader who posts limit orders will usually post bid prices below the best ask price and ask prices above the best bid price.
Because there is a spread between the best bid and ask prices, limit orders do not get filled right away, and indeed sometimes, not filled at all. To ensure immediacy of trades, in a sufficiently liquid market, a trader can post a “market order,” which gets matched with the best bid for a market sell order and matched with best ask for a market buy order. If there is not enough size at the current bid and asks, the market sell and buy orders will walk the book as described previously: the market buy order will pay progressively higher prices; and conversely, the market sell order will accept progressively lower prices. If the size of the market order is large compared to sizes of available limit orders, the order will walk deeper (i.e., higher for buyer or lower for seller) in the order book, causing an immediate rise or decline in the trade price of the securities. This is a form of adverse price impact of trading.
Actors—Liquidity Trader, Market Maker, and Informed Trader
Now that the stage is set, let’s introduce the actors, or more appropriately, the characters or roles in the play. Just like actors, traders can play multiple roles, sometimes in the same play or even at the same time.
Liquidity Trader
A “liquidity trader,” also called “fundamental trader” or derogatively “noise trader,” is a trader whose primary goal is to get in or out of a position for purposes other than profiting from advantaged information (not always insider information). For example, a mutual fund manager decides to rebalance her stock portfolio to match a benchmark index. The trader acting on the instruction of the fund manager is a liquidity trader. The same fund manager may be a macro forecaster, sector specialist, or stock picker basing her trades on publicly available information and deciding to buy or sell some stocks to profit from her mosaic view. Still, such a fund manager does not possess any advantaged information. The trader who executes her trades may be respectfully called a “fundamental trader,” even though fundamentally she is no different from a liquidity trader. Finally, you also have undisciplined traders who are trading for the sake of trading—and we can safely call them “noise traders”. Whether the traders are fundamental or noise, their objective is to complete buy or sell orders with no advantaged information.
Market Maker
If a liquidity trader wants liquidity, who is there to pour him a drink? Well, it could be the liquidity trader on the other side of the trade. It is likely that most liquid stock transactions occur by matching simultaneous market orders on opposite sides of the trade. And much of those orders are matched by your broker dealer before they reach the stock exchange. This is done by internally “crossing” or “netting” the orders, usually done at the mid-price, that is, halfway between best bid and ask in the limit order book.
If there is not enough market order from the opposite side, a market order will “hit the bid” or “lift the offer.” It will walk the book if there is not enough size at the best bid or ask, as we discussed previously. Here, it is the other limit orders that will fulfill the liquidity-seeking market order. Exchanges will pay a rebate on a filled limit order to reward the trader for liquidity.
Strategies that facilitate trading and improve transaction prices, or immediacy, are strategies typically deployed by a “market maker.” Traditionally, when trading was conducted on the floor of a stock exchange (e.g., NYSE), dedicated market makers were physically located in booths and their jobs were to match trades for their assigned list of stocks. They stood ready when the listed buy and sell (limit) orders were not sufficient to clear the market of open orders (e.g., when the market was at a standstill because the best bid and ask prices were too far apart). In situations like that, it was the market maker’s job and her opportunity to post orders that get in between the best bid and ask prices to encourage liquidity traders to transact at her better prices. In return, the market maker would profit from the bid and ask spread, that is, she bought at her bid price and sold higher at the current or improved ask price. The previous narrative is in the past tense because the majority of market-making activities have shifted to electronic trading platforms. Some floor trading still exists for less liquid stocks and other asset classes. For example, the Chicago Board of Options still operates a pit to trade equity and equity index options, while the Chicago Mercantile Exchange ceased pit trading in March 2020 due to COVID-19 and decided the closure would be permanent.
In the modern era of electronic trading, market makers are now almost exclusively algorithmic and high-frequency trading programs. There are still traders whose primary or exclusive job is to make markets in certain stocks, but anyone can make markets intentionally or unintentionally by deploying strategies that improve outcomes—better prices and immediacy—for liquidity traders.
Informed Trader
Wait, a market maker helps only liquidity traders? What about other types of traders? Doesn’t the market maker help everyone? Yes, market-making activity helps everyone, except other market makers who are competing against each other. That being said, market makers are more wary of “informed traders” than other market makers. To skirt the controversy about insider trading, we shall broadly define informed traders as ones who possess advantaged or privileged information that is only known to a small number of agents and is not released to the public. As we discussed previously, a trader or fund manager might have her unique opinion about the future outcome of financial markets and of individual securities. And she might have superior...
| Erscheint lt. Verlag | 22.1.2025 |
|---|---|
| Sprache | englisch |
| Themenwelt | Recht / Steuern ► Wirtschaftsrecht |
| Wirtschaft ► Betriebswirtschaft / Management | |
| Schlagworte | ai trading book • ai trading guide • Algorithmic trading guide • artificial intelligence trading • artificial intelligence trading book • artificial intelligence trading guide • hedging ai • large language model for trading • llm trading • risk management ai |
| ISBN-10 | 1-394-26766-5 / 1394267665 |
| ISBN-13 | 978-1-394-26766-8 / 9781394267668 |
| Informationen gemäß Produktsicherheitsverordnung (GPSR) | |
| Haben Sie eine Frage zum Produkt? |
Kopierschutz: Adobe-DRM
Adobe-DRM ist ein Kopierschutz, der das eBook vor Mißbrauch schützen soll. Dabei wird das eBook bereits beim Download auf Ihre persönliche Adobe-ID autorisiert. Lesen können Sie das eBook dann nur auf den Geräten, welche ebenfalls auf Ihre Adobe-ID registriert sind.
Details zum Adobe-DRM
Dateiformat: EPUB (Electronic Publication)
EPUB ist ein offener Standard für eBooks und eignet sich besonders zur Darstellung von Belletristik und Sachbüchern. Der Fließtext wird dynamisch an die Display- und Schriftgröße angepasst. Auch für mobile Lesegeräte ist EPUB daher gut geeignet.
Systemvoraussetzungen:
PC/Mac: Mit einem PC oder Mac können Sie dieses eBook lesen. Sie benötigen eine
eReader: Dieses eBook kann mit (fast) allen eBook-Readern gelesen werden. Mit dem amazon-Kindle ist es aber nicht kompatibel.
Smartphone/Tablet: Egal ob Apple oder Android, dieses eBook können Sie lesen. Sie benötigen eine
Geräteliste und zusätzliche Hinweise
Buying eBooks from abroad
For tax law reasons we can sell eBooks just within Germany and Switzerland. Regrettably we cannot fulfill eBook-orders from other countries.
aus dem Bereich