How to Generate & Test Your Hypotheses on the Real Time Market Data

When people talk about trading in the market using robots, they often refer to the concept of “algorithmic trading”. Classic algorithms are based on price, time and volume. They detail when to buy and sell and may include chart analysis, volatility, price arbitrage, or price trend. Investment banks and large hedge funds spend millions of dollars annually on developing trading algorithms. To create, mathematicians, physicists, engineers with advanced degrees are involved – such people are called quants.

Quants describe algorithms for a deal using probability theory. They calculate the probability that the future price will rise or fall within a particular range based on the analysis of the previous price movement. Quants only create an algorithm – they program the rules for the desired parameters of the stock price, the time of order execution and its volume. The transaction itself is carried out by an automated system, which is usually called a robot. Algo traders can control the work of the robot, or they may not.

There’s a fair bit of overlap between the terms ‘Quant’ and ‘Algorithmic trader’. Quants deal specifically with Quantitative Finance which is a field of applied mathematics. We aren’t going to dive into the details, but you can check this Wiki page for a decent explanation: Mathematical finance – Wikipedia. You could say that its origins are from the old Black Scholes Options pricing formula. Quantitative Finance is very useful for determining risk.

An Algorithmic Trader is someone who has a very clearly defined trading system based on explicit rules. We’d call someone a trader if they were spending more of their time sourcing current market data, and managing a suite of algorithms. Turning them on or off or tweaking their triggers and limits in response to current market data or other drivers.

If it’s the time to automate the trading

Suppose that after your experience in the stock market (or even with cryptocurrencies), you’d like to go further since you decided that “manual control” is no longer effective and you should automate your bright ideas and turn work into something more technological.

Right at this moment a question arises, namely: what are the available solutions for generating and backtesting trading ideas.

Automation of even simple trading strategies (momentum trade, trend following, etc.) will always begin with the most important stage of creating a trading robot. You start by forming a hypothesis and algorithmizing it.

The development of a trading algorithm should begin with a search for a pricing pattern that will allow us to get a positive expectation of profit during trading. The pattern can be a consequence of a previously developed pricing hypothesis or found by chance.

For traders who do not have programming skills, there are special solutions on the market for creating an algorithm through drag-and-drop interfaces. For example, using TSLab, the robot’s logic can be implemented and changed using a library of indicators and functions.

Next step is manual testing. You formulate entry / exit conditions and examine how they work on the charts of previous sessions. It is advisable to consider as many days as possible, including periods of different volatility. Some trading software allows users to test their trading hypothesis with the real-time market data, which is very important – you cannot rely 100% on the historical data because the market changes every day.

For example, you can simply create a virtual stock exchange account on MarketWatch to test the trading scenario “on the fly” using the current exchange data but for virtual transactions with virtual cash.

Historical or real-time testing?

Testing strategies on historical data is one of the fundamental points. Hypothesis testing gives you a probabilistic assessment of how our strategy will behave in the future when you decide to launch it into trading on a real account.

So, we came up with a strategy, performed testing and optimization of parameters, if necessary. We checked the stability of the results obtained by a forward test and, for example, by probabilistic modeling using the Monte Carlo method and are ready to launch our strategy into trading in real time.

How much will the results obtained during the testing process coincide with what we will receive in the future in real trading? It usually depends on the following factors:

  • How correct we have created our strategy, in terms of programming?
  • Wasn’t the strategy parameters over-optimized?
  • Will the market retain its dynamic characteristics that were observed on the historical data that we used in the testing process? Will volatility be at approximately the same levels?

If with the growth of experience in developing trading strategies, the first two factors can be completely eliminated, then the third one does not completely depend on us and is “in the hands” of the market. However, you can still rely on your hypothesis if it has been tested properly both with historical and real-time data.

The use of complex algorithms is common among institutional investors such as investment banks, pension funds, and hedge funds due to the large volume of stocks they trade on a daily basis. This allows them to get the best possible price at the lowest cost and without significantly impacting the value of the stock.

Results from The TRADE’s 2020 Algorithmic Trading Survey showed that the hedge funds are very likely to use algorithmic trading to reduce market impact. Assuming that hedge funds have huge sums under management, proper back- and forward testing of trading strategies plays a crucial role there.

Moreover, under both International and U.S. accounting standards, there is a requirement to test hedge effectiveness on both a prospective and retrospective basis. This means each fund should conduct a proper audit to show the proper evaluation of its trading hypothesis so that it’s expected and has been highly effective.

MetaQuotes Corporation, the software developer of trading platforms for brokers and exchanges worldwide, has decades of experience running backtesting for client trading hypotheses. Last year, the company launched a specific version of its known trading platform, precisely oriented to hedge funds.

Using the new MetaTrader 5 hedge fund version, fund managers can test their trading strategy with initial parameters on history or real market data during the initial testing period. After that, during optimization, the trading strategy is run several times with different sets of parameters which allows selecting the most appropriate combination thereof.

Visual testing makes it possible to track the strategy operations in real-time:

An important note

In order to create a successful algo trading solution, you need to get your broker’s data and do your backtests on the data that actually you’re gonna work with. This is tremendously important, because at the end your system will trade what it sees. You should consider that working with different data might give you non reliable results, a very dangerous situation for your account. If you work with instruments actually traded on exchanges the data will probably be the same, but if you need other kinds such as Forex, it could be pretty different, so be cautious.

Get the right data, design your strategy, do your backtest, then real time simulations to evaluate not only your algo but its executions. In summary: don’t rush. Good luck with your hypothesis!