Reader small image

You're reading from  Getting Started with Forex Trading Using Python

Product typeBook
Published inMar 2023
PublisherPackt
ISBN-139781804616857
Edition1st Edition
Right arrow
Author (1)
Alex Krishtop
Alex Krishtop
author image
Alex Krishtop

Alexey Krishtop is a quantitative trader and researcher with 20 years of experience in developing automated trading solutions. He is currently the head of trading and research at Edgesense Technologies and CTO at ForexVox Ltd. He develops market models and trading algorithms for FX, commodities, and crypto. He was one of the first traders who started using Python as the ultimate environment for quantitative trading and suggested a few approaches to developing trading apps that, today, have become standard among many quant traders. He has worked as a director of education with the Algorithmic Traders Association, where he developed an exhaustive course in systematic and algo trading, which covers the worlds of both quantitative models and discretionary approaches.
Read more about Alex Krishtop

Right arrow

Trading Strategies and Their Core Elements

In previous chapters, we considered algorithmic (algo) and systematic trading from two standpoints: we learned about the market itself, its participants, the way it operates, and how all this is reflected in the pricing; on the other hand, we did some preparation work in programming, so now we can retrieve and process market data, build technical indicators, and do some charts and plots. In other words, we have the heart and the bones of the body of our future trading application, and now it’s time to add brains and limbs: the trading logic that generates orders, and the order execution control mechanism that finally connects the app with the final destination – an exchange, a broker, or an electronic communication network (ECN).

In this chapter, we will consider the most important classes of trading strategies that are typically used to trade the FX markets. We will learn about the sources of profit generation, consider typical...

Alpha and beta – widely used, widely confused

If you have ever read any article or book on algo or systematic trading or just ever listened to CNBC, most likely you have already heard about alpha- and beta-generating programs (strategies, systems, funds, you name it). And as is quite often the case with heavily used terms, not everyone who uses them really understand their meaning. Let’s shed some light on this terminology, as understanding it will really help sort out the kaleidoscopic variety of trading strategies.

Alpha – earn from changes in price

According to the general definition of alpha (which you can find, for example, at InvestmentU – https://investmentu.com/what-is-alpha-investing/), alpha (α) “is a specific measurement of the worth of an investment based on its performance relative to the market. Specifically, alpha measures the ability of an investment to beat market returns.

Sounds familiar? Most likely yes if...

Options – stable income with unlimited risk

This subheading sounds ridiculous, doesn’t it? How can stable income go hand in hand with unlimited risk?

To understand it, let’s first understand what an option is and how it’s possible to trade them.

An option is a derivative (see Chapter 1, Developing Trading Strategies – Why They Are Different, for a brief explanation of the underlying and derivatives) that gives its holder the right but not the obligation to buy or sell the underlying asset at a certain price in the future.

I know that it’s really hard to understand at first, so let’s consider an example. Say, it’s October and a kilo of apples costs $1 at the moment. I think that its price will grow to $2 by December, but another market participant thinks that even if it grows, it won’t exceed $1.5. So, this market participant writes an option to buy apples at $1.5 in December and sells this option to me for a premium...

Alpha classics – trend-following, mean reversion, breakout, and momentum

Let’s quickly recap the idea of generating alpha: we want to beat the market or perform better than an index (or just the rate itself in FX trading) by actively managing the position in the market. This means we try to buy when we expect the price to go up and we try to sell when we expect the price to go down.

Therefore, in order to successfully generate alpha, we basically have only two options: either we suppose that the price will continue moving in an already established direction, or we anticipate a change. In the former case, we make an attempt to buy when prices go higher and sell when they go down. In the latter case, we try to buy when prices go down and sell when they go up.

Note for nerds

In all the discussions and examples here, I intentionally don’t go deep into mathematics. We are focusing on the qualitative side of these phenomena to better understand their nature...

Arbitrage – let’s earn from others’ mistakes

Arbitrage in financial markets means taking advantage of situations when the same asset is priced differently at different trading venues. Such a situation is usually called mispricing (there are other meanings of this term, and we will get back to it in the very next section about statistical arbitrage). Due to the colossal fragmentation of the FX market (see Chapter 3, FX Market Overview from a Developer’s Standpoint) mispricing there is not infrequent, so an arbitrage strategy looks pretty straightforward: as soon as we see that, say, EURUSD is priced at 1.00012 at LMAX and 1.00013 at IS Prime, then we simultaneously buy at LMAX and sell at IS Prime, pocketing one-tenth of a pip.

I think you can clearly see some problems with arbitrage, which directly follow from its description.

First, the potential profit from a single trade is ridiculously small, so you have to make lots of trades in order to be consistently...

Statistical arbitrage

As we saw in the previous section, arbitrage is based on the idea of mispricing: a situation in which an asset is priced incorrectly. But to say whether something is priced incorrectly or correctly, we need a reference that is known to be priced correctly, don’t we?

In classical arbitrage, such a reference is the asset price itself, and we take advantage of mispricing across different trading venues trading the same asset. Statistical arbitrage (stat arb) uses the concept of fair value to determine whether the asset is mispriced. In simple terms, with classical arbitrage, we compare the price of the asset versus another price of the asset that exists at the same moment in time. With stat arb, we compare the price of the asset to a theoretical fair value to which we expect the price to revert in the future.

In a certain sense, stat arb is a modification or extension of the concept of mean reversion. Indeed, a successful mean reversion strategy is based...

Event-driven trading strategies

An event-driven strategy mostly relies on non-market data such as economic or political news. We already considered the impact of these events on the market price (see Chapter 6, Basics of Fundamental Analysis and Its Possible Use in FX Trading). So, an event-driven strategy can attempt to enter when significant news hits the market and exit soon after.

The problem with strategies of this kind was also considered in detail in the same chapter: due to insufficient liquidity around the time of a news release, the price may jump in virtually any direction at an arbitrary distance, so you have no chance to place a trade at the desired price. At the same time, the return of liquidity may drive the price in the opposite direction, completely eliminating the potential for a profit in a few minutes (see Chapter 6 again for an example with the British pound and the release of the UK’s GDP figures).

I can confirm that profitable news traders used...

Market-making – profiting on liquidity provision and associated risks

We already considered market-making in detail in the Market makers – comfortable, sophisticated, expensive section in Chapter 3, FX Market Overview from a Developer’s Standpoint, so there’s no need to repeat ourselves here. We will mention market-making here only for consistency as an example of a sell-side trading strategy. If we want to classify market-making as pertaining to alpha- or beta-generating strategies, probably we could qualify it as beta-generating. However, at the same time, high values of beta are harmful to market-making. In general, market making requires the trader not only to be sufficiently funded but also to meet various regulatory requirements, which makes this activity available mostly to institutions.

This is no surprise that market making requires not only direct access to the order book, with the ability to update the best bid and ask there, but also assumes...

High frequency, low latency – where Python fails

Our overview would be incomplete without mentioning HFT. Its roots are in the financial crisis of 2008 when liquidity became the main issue in most, if not all, developed markets. Exchanges started to offer an incentive to those who provided liquidity, waiving many restrictions that previously required liquidity providers to be regulated. As a result, many market participants started to offer liquidity, or, rather, demonstrated this liquidity in the order book – because they sent an order only to withdraw it from the book some milliseconds later. In other words, they started to bluff creating an illusion of liquidity.

Of course, to be successful here, you need to be able to process thousands of transactions per second and reduce the latency (that is, the time between the order is sent to the exchange and the time it appears in the order book) to the absolute minimum. That’s why HFT requires very expensive computers...

Summary

In this chapter, we learned about the key terms and concepts of systematic and algo trading. We familiarized ourselves with alpha and beta as risk metrics in investment and at the same time, as different methods for profit generation in algo trading. We considered a few popular alpha-generating trading strategies and learned about their advantages, shortcomings, and associated risks. We also touched on the complex domain of options trading as the primary method to earn on market beta and gave a quick look at other trading strategies, such as arbitrage and stat arb, market-making, and HFT.

Now that we know the conditions under which a certain strategy may enter or exit the market, the last obstacle on our way to a first trading application is the mechanism that generates orders according to the strategy rules, sends them to the market, and controls their execution. Recalling the analogy at the beginning of this chapter, now we have added the brains to our trading app, and...

lock icon
The rest of the chapter is locked
You have been reading a chapter from
Getting Started with Forex Trading Using Python
Published in: Mar 2023Publisher: PacktISBN-13: 9781804616857
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
undefined
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $15.99/month. Cancel anytime

Author (1)

author image
Alex Krishtop

Alexey Krishtop is a quantitative trader and researcher with 20 years of experience in developing automated trading solutions. He is currently the head of trading and research at Edgesense Technologies and CTO at ForexVox Ltd. He develops market models and trading algorithms for FX, commodities, and crypto. He was one of the first traders who started using Python as the ultimate environment for quantitative trading and suggested a few approaches to developing trading apps that, today, have become standard among many quant traders. He has worked as a director of education with the Algorithmic Traders Association, where he developed an exhaustive course in systematic and algo trading, which covers the worlds of both quantitative models and discretionary approaches.
Read more about Alex Krishtop