📜 ⬆️ ⬇️

How-to: What to consider when developing a strategy for a trading robot

image

Previously, we considered the stages of developing trading systems and studied ways to test the operation of the robot using historical data , but did not pay attention to another important aspect - the creation of the very strategy of working in the market. Today we fill this gap and talk about what needs to be considered when developing a strategy for a trading robot.

What you need to consider first


In order to succeed in the stock market, the developer of an algorithmic trading system must take into account their own personal qualities. Algorithmic trading requires a lot of discipline, patience and emotional stability. It is necessary to remember that the robot will carry out transactions - and it is necessary not to get involved in its work for good reason (and this can be difficult, especially if the so-called “drawdown” moment has arrived and the algorithm temporarily runs negative).
')
In addition to the nature of the character, several other important aspects need to be considered:


How to look for ideas for trading strategies


Before you begin work on creating a trading strategy, you need to get general information about the stock market (here are our top 10 best books for this purpose), work on it in test mode (with virtual money). Mike Hulse-Moore mentioned above also recommends the following books (in English):


A large amount of interesting information can be found in thematic communities, forums and blogs. Here are just some of them:


It should be understood that very often traders who post messages on forums too rely on technical analysis and the use of various indicators that help to detect trends and “reversal patterns”. This is a very popular method, but professionals in algorithmic trading consider it to be not the most effective (Halls-Moore calls it “as effective for an algorithm trader as reading a horoscope or guessing the coffee grounds”).

You can go further and study the so-called “academic strategies” that are published in scientific journals - this is also very useful and interesting, but there are also disadvantages: to get access to some journals you need a subscription, the strategies presented in them are often outdated and not always detailed described (for example, what type of orders is used - “by market” or “limit”?).

The streamlined process of monitoring a variety of thematic resources will help the trader to create a “knowledge machine” (as defined by Dropbox founder Drew Houston) and to constantly expand their horizons and a set of trading strategies. However, it is also obvious that not all strategies obtained in this way should even be tried to implement in real life.

Evaluation of trading strategy


The most important thing is to immediately give yourself an answer to the question “Do I understand this strategy?”. You also need to analyze the strategy for its realism (how often on the market there are situations that can lead to events described by the strategy). sustainability (how the strategy will behave if a new law regulating the market appears), the presence of complex statistical and mathematical rules in it, whether it depends on classes of financial instruments or financial time series . It is necessary to study all these factors, otherwise there is a high risk to spend a large amount of time on programming and testing on historical data of an absolutely unworkable strategy.

After the strategy has passed the primary filter, it is necessary to analyze once more how it suits a particular trader according to his personal qualities. If it is difficult for a person to survive long drawdowns of a deposit (that is, periods when work goes “in the minus”) that are embedded in some strategies, then he can “break” and stop the work of the robot, fixing losses just before the strategy in plus. There should be no emotion in the evaluation of the strategy; only well-defined criteria should be used.

image

Here is a list of some of the criteria proposed by Michael Hulse-Moore:

Methodology

How complicated is the strategy? How many parameters must be taken into account for its implementation (the more there are, the greater the likelihood of “optimization errors”)? Will the strategy be able to survive significant changes in the market (for example, changing laws or tightening regulation of financial markets)?

Sharpe Ratio

Using this ratio, the ratio of the possible profit to the riskiness of the strategy is estimated. The higher the Sharpe ratio, the better the results that the investment portfolio shows in relation to the risks taken.

Shoulder

Does the strategy involve the use of "leverage" (that is, borrowed funds) for the successful implementation of trade? Do derivative instruments that bargain with leverage participate in the strategy (such instruments usually have high volatility, which can lead to margin calls)? Does the trader have enough capital that can be conveyed to avoid closing positions?

Frequency

Higher frequency strategies require more capital, as well as more difficult to implement, than more "quiet" strategies. However, most often they have a higher Sharpe ratio.

Volatility

Volatility affects the riskiness of a strategy. The higher the volatility of the financial instruments used, the lower the Sharpe ratio, as a rule.

Total income and number of losing trades

There are generally profitable strategies in which the number of losing trades can even exceed the number of profitable ones - the main thing is that in case of success, the profit should be significantly greater than the possible losses.

Max drawdown

The value of the largest allowable capital reduction during the execution of the strategy. Momentum strategies are characterized by significant and long periods of deposit drawdown - even if backtesting proved that such behavior is normal for a strategy and does not affect its profitability, it will be hard for a trader not to close positions at the time of serious losses.

Number of parameters

The greater the number of parameters used in the strategy, the higher the likelihood of obtaining incorrect data in the optimization process, since in this case it will be hard to qualitatively test the strategy on historical data.

Benchmarks

The performance of most strategies is measured in comparison with some benchmark, the role of which is most often an index characterizing a large segment of financial assets similar to those used in the strategy. Such benchmarks can be the S & P 500 index, in Russia - the MICEX and RTS indices (here’s the material on why stock indices are needed ).

image

RTS Index Dynamics

The profitability of a strategy at a specific point in time cannot be a significant criterion in its evaluation, since it provides somewhat limited information about its effectiveness. It is always necessary to take into account not only possible profits, but also risks, as well as associated parameters, such as drawdowns.

At this stage, a significant number of previously selected strategies will be rejected, since they will not meet the criteria for capital availability, restrictions on leverage or drawdown. Strategies that have passed this filter can be tested on historical data.

Work with historical data


Before you start testing on historical data, you need to determine what data you need to get, where to get it, how and where to store, and also to understand whether it will not be too expensive.

Basic data

Data on macroeconomic trends, such as open interest , inflation, corporate actions (dividend payments, etc.), applications for IPOs, financial statements of companies, meteorological data, and so on. Such data is often used to evaluate specific companies or asset classes at a fundamental level. Some of this information can be found for free on the websites of stock exchanges, companies and government agencies, while other long-term fundamental data can be very expensive. There is no need to spend a lot of resources on their storage (if there is no need to simultaneously analyze the shares of many companies).

News data

There is no doubt that news affects the stock market - and there is much more such information. This includes news bulletins of large and small media, blog posts and microblogs. NoSQL databases are well suited for storing such unstructured data.

Data on asset price and frequency

This type includes true price series of specific assets - stocks, bonds, commodities and foreign stock indices. The simpler the asset (for example, a share), the easier it is to get such data (often this can be done for a small amount of money - here is the information about the fee for accessing the data on the Moscow Exchange trading). However, the volume of such data may require significant investment in their storage.

image

The higher the frequency of the data, the higher their cost and storage requirements. Some strategies require tick data and even copies of the so-called “order book” (order book). Work with such data is very difficult technologically. Among other things, the strategies described above will most likely be compared with benchmarks (S & P500 and FTSE100 index), which means that we will need data on these benchmarks.

Conclusion


As can be seen from the above, in order to create a successful strategy, it is necessary not only to study a large number of very different strategies, but also to take into account a large number of risks and other parameters. In addition, even before the stage of testing on historical data, you should think about what specific information you will need in order to get consistent and correct results, as well as how much you will have to pay for all this. Only after that you can proceed to the actual testing - this process we described in detail here .

Thanks for attention! We will be happy to answer questions in the comments.

Source: https://habr.com/ru/post/249299/


All Articles