3.1 Quantitative trading programming language evaluation

Author: , Created: 2019-04-18 15:03:37, Updated: 2019-04-27 11:54:49

Summary

In Chapters 1 and 2, we learned the basics of quantitative trading and the uses of FMZ Quant tools. In this chapter, we will implement the actual trading strategies. If a worker wants to do something good, he must first sharpen his tools. To implement a trading strategy, you must first master a programming language. This section first introduces the mainstream programming languages ​​in quantitative trading, as well as the characteristics of each programming language itself.

What is a programming language?

Before learning a programming language, you must first understand the concept of “programming language.” A programming language is a language that both humans and computers can understand. It is a standardized communication code. The purpose of a programming language is to use a human language to control a computer and tell the computer what we are going to do. The computer can execute instructions according to the programming language, and we can also write code to issue instructions to the computer.

Just as parents taught us to speak and teach us how to understand what other people are saying. After a long period of edification and self-learning, we have learned to speak without knowing it, and can understand the meaning of other children talking. There are many languages, including Chinese, English, French, etc., such as:

  • Chinese: 世界你好

  • English: Hello World

  • French: Bonjour tout le monde

If you use the programming language to display “Hello World” on your computer screen, this is the case:

  • C language: puts (“Hello World”);

  • Java language: System.out.println(“Hello World”);

  • Python language: print (“Hello World”)

You can see that computer languages ​​have their own specific rules, and there are many languages, and these language rules are the classification of programming languages ​​that we need to explain for you today. In each category, we only need to remember the most basic rules. We can use these programming languages ​​to communicate with the computer and let the computer run the corresponding strategy according to our instructions.

Programming language classification

In order to facilitate reference and comparison, choose the quantitative trading programming language that suits you. We will categorize the six most commonly used programming languages: Python, Matlab/R, C++, Java/C#, EasyLanguage, and Visual programming Language ( As shown below).

img

We rate them by functional ability, speed, extension and learning difficulty. A score from 1 to 5, for example, a score of 5 on the functional range means powerful, and 1 point means less functionality. (As shown above) Visual programming and EasyLanguage are easy to learn and very new; Python has powerful extension capabilities and is suitable for developing more complex trading strategies; C++ programming is the fastest and more suitable for high-frequency traders.

But for each programming language, the evaluation is mainly for the application in the field of quantitative trading. And with the subjective component of the individual. You are also welcome to explore them yourself, Next, we will start to introduce these programming languages ​​one by one.

Visual programming

Visual programming has been around for a long time, This kind of “what you see is what you get” programming idea, equipped with a variety of control modules, just by drag and drop, you can build code logic, complete the trading strategy design, the process is like building blocks.

img img

As shown above, the same procedure is only a few lines of code on the FMZ Quant trading platform visual programming. This greatly reduces the programming threshold, especially for traders who don’t understand programming at all, which is a great operating experience.

Because the underlying implementation strategy of this visual programming is converted to C++, it has little effect on the running speed of the program. However, the functionality and scalability are weak, and it is impossible to develop a trading strategy that is too complicated and too refined.

EasyLanguage

img

The so-called EasyLanguage refers to the programming language unique to some commercialized quantitative trading software. Although these languages ​​also have some object-oriented features, they are mainly scripted in the application. In terms of grammar, it is also very close to our natural language. For beginners of quantitative trading, using EasyLanguage as a starting point is a good choice. For example, the M language on FMZ Quant platform.

This kind of scripting language has no problem in strategy backtesting and real market in its specific software, but in terms of expansion, it is often limited. For example, strategy developers cannot call external APIs. And at the speed of running, this scripting language runs on its own virtual machine, and performance optimization is as good as Java/C#.

Python

As shown in the figure below, on Stackoverflow, the number of mainstream programming language accesses has not changed much in recent years, and only Python is on a tremendous rise. Python can be used for web development, machine learning, deep learning, data analysis, etc. It has become the most versatile language because of its flexibility and openness. The same is true in the field of quantitative investment. At present, the global quantitative platforms are mostly based on Python.

img

Python’s basic data structure lists and dictionaries are very powerful and can meet almost all needs of data analysis. If you need a faster, more comprehensive data structure, NumPy and SciPy are recommended. These two libraries are basically called the standard library for Python scientific computing.

For financial engineering, the more targeted library is Pandas, with two data structures, Series and DataFrame, which are ideal for processing time series.

In terms of speed, Python is in the middle of the game, slower than C++, and faster than the EasyLanguage, mainly because Python is a dynamic language that runs at the normal speed as a pure Python language. But you can use Cython to statically optimize some functions to get close to the speed of C++.

As a glue language, Python is the number one in terms of scalability. In addition to being able to interface with other languages ​​extensively, the design of the extension API is very easy to use. In terms of learning difficulty, Python has a simple syntax, high code readability, and easy entry.

Matlab/R

Then there is Matlab and R language. These two languages ​​are mainly oriented to data analysis. Language creator have done a lot of design for scientific operations in grammar, which is characterized by natural support for quantitative trading operations. However, the application range is limited, and it is generally used for data analysis and strategy backtesting. For trading system and strategy algorithm development, its ease of use and stability are less.

In addition, their speed and scalability are relatively poor, because Matlab and R language run on a unique language virtual machine. In terms of performance, their virtual machines are much worse than Java and C#. But because their grammar is closer to the mathematical expression formula, it is relatively easy to learn.

C++

C++ is a general-purpose programming language that supports multiple programming patterns such as procedural programming, data abstraction, object-oriented programming, generic programming, and design patterns. You can implement all the functions you want to achieve in C++, but the biggest drawback of such a powerful language is that it is very difficult to learn, such as templates, pointers, memory leaks, and so on.

At present, C++ is still the preferred programming language for high-capacity, high-frequency trading. The reason is simple. Because C++ language features are easier to access the underlying layer of the computer, it is the most effective tool for developing high-performance backtesting and execution systems that process large amounts of data.

Java/C#

Java/C# are static languages ​​that run on virtual machines. Compared with C++, there is no array out of bounds, no coredump, thrown exceptions can accurately locate the error code, bring automatic garbage collection mechanism, no need to worry about memory Leak and so on. So in terms of grammar learning difficulty, they are also easier than C++. In terms of speed, because their virtual machines come with JIT functions compiled at runtime, the speed is just second only to C++.

But in terms of functionality, it is impossible to optimize the underlying trading system like C++. In terms of expansion performance, it is weaker than C++, because their extension needs to pass the C bridge, and the two languages ​​themselves run on the virtual machine, so when expanding the function module, you need to cross one more Layer wall.

To sum up

However, in the end, the quantitative programming language is not important, the important thing is the idea. The FMZ Quant M language and visual programming language are completely no problem as a stepping stone to the entry of quantitative trading. After the basics, the improvement is to continuously explore different market conditions and try to use more underlying language, such as C++.

“Design your strategy and trade your ideas.” From this perspective, the core of quantitative trading is still trading ideas. As a quantitative trader, you not only need to master the basic grammar and functions of the strategy writing platform, but also need to understand the trading concept in actual combat. Quantitative trading is only a tool and a carrier to embody different trading concepts.

After-school exercises

  1. What are the advantages of the Python language as a quantitative trading tool?

  2. Try to write a few commonly used APIs by the M language?

Next section notice

I believe that with the above introduction to the programming language, you must know how to choose it, then in the next few chapters, we will develop a quantitative trading strategy based on the classification of programming languages.


More