Book Image

Getting Started with Forex Trading Using Python

By : Alex Krishtop
Book Image

Getting Started with Forex Trading Using Python

By: Alex Krishtop

Overview of this book

Algorithm-based trading is a popular choice for Python programmers due to its apparent simplicity. However, very few traders get the results they want, partly because they aren’t able to capture the complexity of the factors that influence the market. Getting Started with Forex Trading Using Python helps you understand the market and build an application that reaps desirable results. The book is a comprehensive guide to everything that is market-related: data, orders, trading venues, and risk. From the programming side, you’ll learn the general architecture of trading applications, systemic risk management, de-facto industry standards such as FIX protocol, and practical examples of using simple Python codes. You’ll gain an understanding of how to connect to data sources and brokers, implement trading logic, and perform realistic tests. Throughout the book, you’ll be encouraged to further study the intricacies of algo trading with the help of code snippets. By the end of this book, you’ll have a deep understanding of the fx market from the perspective of a professional trader. You’ll learn to retrieve market data, clean it, filter it, compress it into various formats, apply trading logic, emulate the execution of orders, and test the trading app before trading live.
Table of Contents (21 chapters)
1
Part 1: Introduction to FX Trading Strategy Development
5
Part 2: General Architecture of a Trading Application and A Detailed Study of Its Components
11
Part 3: Orders, Trading Strategies, and Their Performance
15
Part 4: Strategies, Performance Analysis, and Vistas

Developing Trading Strategies – Why They Are Different

For many years, I traded in various markets, educated developers in trading, and taught some essential programming and algorithm (algo) development to traders. Eventually, I concluded that the main problem for both groups (the developers and traders) was not a lack of knowledge in programming, but an incorrect or insufficient understanding of the subject domain, that is, financial markets and their mechanics.

This was quite a surprise for me. I thought that coding, debugging, and handling errors should be the main obstacle, but in reality, the problem is in finding useful, correct, and adequate information about markets, their structure, and operations, especially in regard to algo trading. I don’t mean that it’s somehow undisclosed or otherwise hidden from the general audience – not at all. The problem is that it’s really hard to find a source that not only covers everything – from the market structure to money and risk management – but also shows clear connections between very specific features of a market and less-specific features that a trading algorithm should have in order to be successful in this market.

For example, many authors consider entries and exits in a trading strategy as something that can be executed immediately and with equal success at any moment, any time of the day. However, in the real market, this is not the case. I saw lots of strategies that only worked on paper because their developers didn’t take into consideration the fact that they were dealing with a real, complex structure with lots of limitations and shortcomings, and not with an abstract idealistic model.

This example is really primitive, but I hope it explains the most important point that is missed by many researchers and developers: we do not deal with abstract datasets and time series where each data point has an equal value and where any action can be taken at any moment with equal possibility; we work with a very complex structure that has lots of features that make this structure a dynamic non-stationary system. And to be successful in algo trading, these features should be accounted for.

Without knowing how markets are organized and how they operate, our trading algorithms will inevitably fail sooner or later.

If put in a more positive manner, understanding the market will help us in making trading algorithms more robust.

This book is my humble attempt to bridge the gap between the world of quantitative trading (driven by numbers) and the real market (driven by humans). I am convinced that today, any long-term success in trading can be achieved only with good knowledge of both.

Let’s begin with the basics. We will learn about the very basic market terminology and the essential concept of a trading strategy, get familiar with the risk in various forms and aspects with a special focus on ordering and transactional risk, and also mention market data processing in a very general sense.

In this chapter, we will discuss the following topics:

  • Trading strategies – it’s all about how you manage risk
  • Automated trading – operational risk and regulatory limitations
  • Making actual trading decisions – trading logic and credit risk
  • Ordering – transactional risk
  • The general architecture of a trading application