Performance: speeding up a terminal for stock trading with undocumented features

    The main means of working in the stock market for most traders is a special trading terminal - even algorithmic traders who launch special trading robots use it to control the state of the account. At the junction of HFT and “regular” trading, sometimes problems arise - often the terminal cannot “digest” information for tens of thousands and millions of applications and deals in trading software and starts to work more slowly.

    In conditions when every millisecond can cost real and very big money, this is unacceptable. Today we will talk about a small life hack that dramatically improves the performance of the SmartX trading terminal (our development) in five minutes.

    Several million applications: what to do?

    When developing your project of the SmartX trading terminal (you can read more about the project in a separate topic ), special attention was paid to performance. In particular, it took a lot of effort to make fast-running graphics (the terminal was developed on the basis of the M4 platform on COM +) - for this I had to connect third-party developments and switch to .NET.

    Attention was also paid to the creation of a special DataManager module, which is responsible for the interaction of the terminal with the brokerage trading system. In the previous version of the terminal, it was single-threaded, which created performance problems in case of large volumes of "pumped" data. The new module has become multi-threaded and asynchronous, which allows the terminal to display 2 million applications. In addition, according to test data, the terminal is faster and sends applications - during a comparative test with another terminal popular on the market, SmartX sent 100 applications in 0.0099 seconds, and its rival - 1.018 seconds (this is the time before callback registration of applications) .

    However, as mentioned above, sometimes these capabilities are not enough for demanding traders - some robots can quite easily make over 2 million orders per day. There are not so many such users of the program, but they exist, and they needed to be given some opportunities to increase work productivity.


    As a result, it was decided to provide them with the ability to disable certain parameters that affect performance using a special configuration file - technically advanced HFT merchants are familiar with this method, and for other users it was not necessary to make additional menus in the settings that could confuse them .

    Performance Improvement and Configuration File

    In the folder that is created after installing the trading terminal, there is a file (smartx_exe.config) - it contains a small XML-code with options. Changing them allows you to configure the terminal more flexibly and get rid of possible performance problems.

    The content file looks like:


    Changing the value of the three fields from True to False helps to significantly increase the performance of the program. Let us dwell on each of the three points.


    The stream containing the bid data and the flow of information about changes in quotes in the terminal “merge” - in the “bid” field in the program, the user sees not only information directly about it, but also some information about the bidding — purchase and sale prices (bid, ask, ) and some other data (for example, the price of the last transaction). This is necessary, in particular, for the operation of one of the functions of the integrated risk management - the “moving stop order”.

    What is a trailing stop
    Traders limit losses and take profits using orders like STOP. For example, when buying stocks or futures, a trader can set a stop at a certain price mark, upon reaching which his position is liquidated - in this case, stocks or futures will be sold at the current market price. Such orders have one minus - they must periodically be removed and re-set with the edited conditions. If the price "went up", then leaving the original order is unprofitable, since if it falls, potential profit will be lost.

    Using the function of a moving stop order, you can automatically “pull up” the stop value after the changed price of a financial instrument. In the case of a long position (the presence of purchased shares or futures), a trailing stop on the sale of shares (sell operation) will increase with the price increase and will not change when it decreases. In the case of a short position (sold “borrowed” shares with the expectation of a drop in their value for further redemption), a sliding stop to close it (closeshort) will, on the contrary, decrease with a fall in price and will not change if it grows.

    In addition, the merging of application flows and trading information is necessary to calculate information on collateral that should be withheld from the client to guarantee his obligations under the transaction - the state of the account depends on the number of applications submitted (the more there are, the less free funds, since future transactions are necessary than to provide).

    If you set this item to False, then orders and quotes will not merge, which will improve productivity. This method is well suited for those traders who submit a lot of applications and work with tools that often change market parameters. Failure to process them saves system resources.


    Disabling this feature prevents the program from storing canceled requests in memory. In general, they do not carry much value for a trading strategy, but especially active traders can have a lot of them (up to millions). Failure to store this information allows you to save system memory, as well as speed up the drawing of the table of applications and schedules (in case current applications are displayed on it with lines).


    Refusal from this item brings the greatest gain in productivity if the connection to the auction occurs in the middle of the trading session. In addition, this function is closely related to the previous paragraph.

    When a trader has a lot of canceled orders (which were issued and withdrawn by a trading robot, for example), when connected by a trading terminal, it requests information about all requests of a particular user from the broker's database. In the event that these applications are millions, their “pumping” needs time and memory to store them. Accordingly, the rejection of this function allows you to speed up the terminal

    There were no such capabilities in the terminal of the previous generation. As a result, in the presence of several tens of thousands of applications, he began to greatly “slow down”. The new product is faster by itself and can cope with about 2 million applications without any particular problems, and when you turn off the above settings, its performance grows even more significantly. At the same time, you need to spend a little time on making changes to the configuration file.

    These items are not available through the standard terminal settings menu, so “undocumented features” can be used by those who really need it, and most users can use the program without complicating its interface.

    PS If you find a typo or mistake, write us a personal message, and we will quickly fix it.

    Related posts and links:

    Also popular now: