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

FX Market Overview from a Developer's Standpoint

The FX market has long been very attractive for developers, mostly because there’s a lot of free stuff associated with this market, such as market data, trading software, and various third-party solutions. However, the quality of freely available solutions is frequently so low that it’s in fact not possible to use them for any serious trading.

The main problem with trading in the FX markets is their strong fragmentation. Historically, FX was an interbank market with no dedicated center. So, trading venues offer not only different trading platforms but also different market data, different types of orders, and different access to liquidity. This fragmentation may be quite confusing, so it’s essential to obtain a sufficient level of understanding in order to avoid making mistakes, which at times can be quite painful.

In this chapter, we will look at this market from a developer’s standpoint to discover...

Trading venues – where money meets… other money

First, let me note that despite the overall colloquial language used in this book, I am always trying to stick to the traditional academic approach that follows the same paradigm: definition | logical conclusions | theory | experiment | proof. Without proper definitions, especially when we talk about the foundation of the subject domain, we won’t be able to make logical conclusions, suggest a theory, or test and finally prove a theory – which in our case, means making money. In even simpler words, without a full understanding of the subject, we are unable to suggest appropriate methods to use it.

So, as we mentioned in Chapter 1, financial markets facilitate buying and selling assets at special marketplaces called trading venues. A bit too vague to be useful, right? Well, let’s go into specifics.

Organizing chaos – types of trading venues

A trading venue in the financial world is a place...

Trade mechanics – again, some terminology

A trade is made when two parties meet and agree to buy or sell from each other. These parties are called counterparties.

If I buy 1 million euros for the equivalent in US dollars and the exchange rate is 1.1, then I paid 1.1 million US dollars to have a position of 1 million EURUSD. I am going to have this position until I sell back this amount of euros for the equivalent amount of US dollars and, therefore, liquidate my position and become market neutral again until I open a new position.

If I improve the asking price by sending an offer that is lower than the previous best offer, then I provide liquidity to the market.

If I simultaneously improve ask and bid, and other traders become counterparties for both, then I make the market. Making the market means earning the spread (the difference between bid and offer) while remaining market neutral. The market participant whose main business is making the market is called a market...

Market makers – comfortable, sophisticated, expensive

The term market makers actually has two different meanings, although they lie quite close to each other.

In cases where both buyers and sellers need to meet each other at a single marketplace – which is an exchange in most cases, as we saw earlier – such a market is called a two-sided market. In two-sided markets, market makers provide liquidity to the market and this activity will be considered in the Liquidity providers – the whales that support this planet section.

In OTC markets, the situation is different. In these markets, only dedicated market participants can publish their bids or offers, and in some cases, they are not published at all. So, finding a counterparty for your trade could potentially be even more complex than in a two-sided market, and given that the quoting is not public, you can get your orders executed at really surprising prices (and of course, it’s not going to be...

Liquidity providers – the whales that support this planet

In the previous section, we already noted that some activities of market makers are similar to those of liquidity providers (LPs). An LP is a market participant whose business is to earn the spread by providing liquidity to the market, that is, always maintaining orders to buy or sell on both sides of the order book at the same time. Therefore, as in the case of market makers, LPs act as price givers earning the spread.

In two-sided exchange-traded markets, it’s hard to tell the difference between a market maker and a liquidity provider. However, in OTC markets it becomes fundamental.

In an OTC market, a market maker is an entity that has its own clients and quotes the market for them. A liquidity provider normally does have clients which trade directly with them, regardless of whether it’s a small retail client or a large fund. LPs only provide liquidity to an order book – or multiple order...

ECN – looks like a fair game, but is it?

When I speak about the structure of OTC markets, especially the fact that prices in them are offered by just select market participants and can vary significantly for different buy-side clients, many traders say, “This is not fair! Why won’t FX work in the same manner as other regulated markets with centralized exchanges where anyone can improve the price?”

There is no single and simple answer to this question.

First, the FX market trades money for money and not any asset for money. Its original purpose was to facilitate currency exchange rather than speculative trading with various financial instruments. And (fortunately!) we don’t have to go to an exchange to just get some British pounds for euros or Indian rupees for US dollars. Therefore, OTC trades are quite natural for this purpose and a currency exchange shop is an excellent example of trading OTC.

Second, the FX market consists of multiple...

Aggregation – in search of the best price

Do you remember that any OTC market in general, and the FX in particular, is highly fragmented? There are multiple market participants offering different prices for the same asset at the same moment in time.

This is true for any market participant and any trading venue, and ECNs are no exception. If ECNs were closed systems without any links to the outer world, then the price could potentially be very different from prices in the rest of the FX market. Indeed, if we have there an exchange-like trading venue then even though bids and asks are posted by only a small group of qualified members, the price will be determined by supply and demand, quite like in any other market. This means that price takers will be those who drive the price up or take it down. In a closed system, the price is determined only by members of this system.

It may seem that theoretically nothing prevents the price of the same euro versus the US dollar to be...

Trading the FX market – what and how

We have talked quite a lot about where it is possible to trade but wait! We totally forgot to discuss what is possible to trade and how it is possible to place trades. Let’s fill this gap immediately.

FX instruments

You probably heard that the FX market is the largest market in the world, with a daily turnover of over 2 trillion dollars. But have you ever wondered what instruments are traded in such enormous quantities? Do you imagine piles of cash or gold coins? Maybe instant transfers of money from one bank account to another?

No, of course, this is not the way this market operates. When we say forex we generally mean trading obligations to deliver one currency for another currency.

If I come to a currency exchange shop and exchange €100 for the equivalent amount of British pounds, then such a transaction is done immediately. My obligations to deliver the euro as the seller and the shop’s obligations to...

Why do I need all this?

Well, actually you don’t. Of course, you can just quickly download unclear historical price data from an unknown source, develop a model using tools you don’t fully understand and optimize it using this data, connect to an unknown broker and start trading. The question is: will this trading be successful? Most likely not.

If you read this chapter carefully, you’ll most likely already understand why.

Firstly, when you plan to use certain historical price data for your models you should realize what exactly you are going to use: whether it’s last trade, bid, ask, or both, or anything else. You should check if historical data contains correct timestamps and that no tick is dated earlier than the preceding one. You may want to make sure the data you use contains information about trading volume – otherwise, you won’t be able to develop a wide range of trading strategies. You should make sure that data is clean and...

Summary

In this chapter, we learned about the different ways a market can be organized and operated. We familiarized ourselves with key concepts such as exchange, order book, and liquidity, noted the possible impact of various factors on price behavior, and discovered important intrinsic factors that may negatively affect the performance of a trading strategy. With all this fundamental knowledge in mind, we’re ready to move on to study the architecture of a trading application in detail, to see what we should use in order to meet the challenges of the modern FX market. This is what we’re going to do in the next chapter.

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