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


    Previously, we examined the stages of development of trading systems and studied ways to test the robot's performance using historical data , but did not pay attention to another important aspect - the creation of a strategy for working on the market. Today we will fill this gap and talk about what you need to consider when developing a strategy for a trading robot.

    What to consider first

    In order to succeed in the stock market, the developer of an algorithmic trading system needs to consider his own personal qualities. Algorithmic trading requires a lot of discipline, patience and emotional stability. You need to remember that the robot will carry out transactions - and you should not get into its work by how much in vain (and this can be difficult, especially if the so-called “drawdown” moment has arrived and the algorithm temporarily works in minus).

    In addition to character traits, several other important aspects must be taken into account:

    • Time availability - does the future investor work full time or remotely, live near the office or have to spend several hours on the road? Answers to these questions will help determine the “frequency” of the trading strategy that should be chosen. Obviously, people who spend most of the day on the road and in the office should not create high-frequency strategies because they will not be able to control the work of the robot. If the investor has a significant amount of time, then it may be more interesting for him to plunge into the world of high-frequency trading (HFT)
    • The importance of constant market research - very rarely trading strategies can work successfully for a long time. As a rule, they constantly need to make changes that reflect the current situation on the market. As a result of this, the creators of trading systems devote a significant part of their time to market research and the search for new trading ideas.
    • The amount of available funds - transaction costs for algorithmic traders can be quite significant ( direct connection to the exchange, renting servers to run the robot, exchange commissions and brokers - ITinvest tariffs by reference ). It is believed that for an algorithmic strategy, the average starting capital should be approximately $ 50 thousand - such an opinion, in particular, is shared by “quantum”, developer and investor Mike Halls-Moore.
    • The ability to program - knowledge of programming languages such as C ++, C # Java, Python, R (or TradeScript - here are examples of robots in this scripting language) will allow you to create all the elements of the robot - from the trading engine to the backtesting system.
    • The financial goal is, contrary to popular myth, algorithmic traders do not bathe in money (at least getting rich very quickly, creating a trading robot, most likely will not work). This is a long and painstaking work that must be taken into account. If a trader hopes to receive a stable income and monthly withdraw a certain amount of money from a brokerage account, then he must choose the “frequency” of the strategy accordingly - the need to constantly withdraw funds will require a higher frequency strategy with little volatility, long-term investors can afford a more “calm” behavior strategy for the market.

    How to search for ideas for trading strategies

    Before starting 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). The above Mike Hals-Moore also recommends the following books (in English):

    A lot of interesting information can be found in thematic communities, forums and blogs. Here are just a few of them:

    You need to understand that very often traders posting on forums rely too much on technical analysis and the use of a variety of indicators that help detect trends and “reversal patterns”. This is a very popular method, however, algorithmic trading professionals consider it not the most effective (Halls-Moore calls it "as effective for an algo trader as reading a horoscope or fortune telling on 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 are described (for example, what type of orders is used - “by market” or “limit”?).

    A streamlined process of monitoring a variety of thematic resources will help the merchant create a “knowledge machine” (as defined by Dropbox founder Drew Houston) and constantly expand his horizons and set of trading strategies. However, it is also obvious that not all strategies obtained in this way are worth trying to implement in real life.

    Trading Strategy Evaluation

    The most important moment - you must immediately clearly give yourself the answer to the question "Do I understand this strategy?". You also need to analyze the strategy for its realism (how often the market encounters situations that can lead to events described by the strategy). sustainability (how the strategy will behave if a new law governing the market appears), the presence of complex statistical and mathematical rules in it, whether it depends on the classes of financial instruments or financial time series . It is necessary to study all these factors, otherwise the risk is great to spend a large amount of time programming and testing on historical data a completely inoperative strategy.

    After the strategy has passed the primary filter, it is necessary to analyze once again how much it suits a particular trader by his personal qualities. If it will be difficult for a person to survive long drawdowns in the deposit (that is, periods when work is “in the red”), which are laid down in some strategies, then he can “fail” and stop the robot, fixing losses exactly before the moment the strategy comes out in plus. No emotions should be present in the evaluation of the strategy; only clearly defined criteria should be used.


    Here is a list of some of these criteria suggested by Michael Hulz-Moore:


    How complicated is the strategy? How many parameters need to be considered 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 coefficient, the ratio of potential 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 accepted risks.


    Does the strategy involve leverage (that is, borrowed funds) for successful trading? Do derivatives traded 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?


    Higher-frequency strategies require more capital and are more difficult to implement than more “quieter” strategies. However, most often they have a higher Sharpe ratio.


    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 revenue and the number of losing trades

    There are generally profitable strategies in which the number of loss-making transactions can even exceed the number of profitable ones - the main thing is that, if successful, the profit is much larger than the possible losses.

    Maximum drawdown

    The size of the largest allowable reduction in capital 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 the strategy and does not affect its profitability, it will be difficult for a trader to not close positions at the time of serious losses.

    Number of parameters

    The greater the number of parameters used in the strategy, the higher the probability of receiving incorrect data during the optimization process, since in this case it will be difficult to qualitatively test the strategy on historical data.


    The productivity of most strategies is measured in comparison with some benchmark, the role of which is most often played by some 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 is the material on why stock indices are needed ).


    Dynamics of the RTS Index

    Profitability of a strategy at a particular 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 consider not only possible profits, but also risks, as well as related parameters, such as drawdowns.

    At this stage, a significant number of previously selected strategies will be rejected, as 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 it, and also to understand if it will not be too expensive.

    Fundamental data

    Data on macroeconomic trends, such as open interest , inflation, corporate actions (dividend payments, etc.), IPO applications, financial statements of companies, weather 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 exchanges, companies and government agencies, while other long-term fundamental data can be very expensive. Their storage does not require spending a lot of resources (if there is no need to simultaneously analyze the shares of many companies).

    News data

    There is no doubt that the news affects the stock market - and much more such information. This includes news articles from large and small media, blog posts, and microblogging. NoSQL DBMSs are well suited for storing such unstructured data.

    Asset Price Data and Frequency

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


    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”. Working with such data is very difficult technologically. Among other things, the strategies described above will certainly be compared with benchmarks (S & P500 and FTSE100 index), which means that data on these benchmarks will be needed.


    As can be seen from everything described above, in order to create a successful strategy, it is necessary not only to study a large number of 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 will be needed in order to obtain consistent and correct results, as well as how much you will have to pay for all this. Only after that we can proceed to the testing itself - we described this process in detail here .

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

    Also popular now: