Stock Quantitative Trading Software: Discretization of Price Series Random Components and Noise

Overview
Long ago, in the early days of financial markets, without computers, and when actual commodities were traded in real markets, the classical method of representing price series as time intervals (or time frames) emerged. All the price changes in a day are too much to store. Even, it doesn't work because the price doesn't change quickly. So the obvious solution is to log the price values ​​at regular intervals. Sounds logical: "The price of wheat today is 90 cents, and yesterday it was 80 cents". Everything is crystal clear: demand is growing, prices are going up. Compared to what the market is trading today, there aren't many transactions, which is why price redefinitions are rare.

With the advent and development of price data analysis, which aims to better predict price action, and as the number of trading operations increases, it becomes important for people to know the highest and lowest prices for a specific time period. In other words, the relevant price information of 80 cents yesterday and 90 cents today is no longer enough. One wants to know where the highest and lowest prices were reached during a given time period. That's when the famous candlesticks and bars were invented.

As the number of trading operations increases, the discretization of the price series becomes more and more accurate. Now, Hertz quantitative trading software has used minute discretization, and sometimes even smaller frame rates, such as one second and ten seconds.

The main advantages of time-discretization of price series are as follows:

convenient. Hertz quantitative trading software can know exactly that the next bar will be formed in the next minute, and we will receive the new opening price, closing price, highest price and lowest price.
resource efficiency. Candlestick notation can only store 4 digits for a time period if greater precision is not required. If you're going to store every change in bid, ask, and final price, then a year's worth of history is huge, running into gigabytes. This is a real hassle if you need to download and store 10-20 years of price history and you are concerned with not just one but 200-500 symbols. Or, huge computer resources are required to process gigabytes of history. This is why candlestick analysis and processing looks much more attractive nowadays.
Easy zooming and intuitive analysis. When you need to view a large picture, you can increase the discretization scale to weeks or even months, and when displaying, you can display data for multiple years as needed. If you need more precision, you can reduce the scale and even see what's happening over the course of a minute. 
time linear. Probably the most convenient thing in this rendition is that the yearly spaced histories visually take up about the same amount of screen space. Finding the previous year or hour on the chart is easy and intuitive. Intuitively, linearity in time seems to be a very important parameter, but sometimes the "correct" decision is counterintuitive.
Easy to compare prices of different products.
Signal discretization function
Data discretization is not only needed in trading, but also in many other signal processing fields. For example, in music, the original continuous signal is digitized. Time discretization is used when encoding. Writes signal amplitude values ​​to memory at regular intervals. This signal can then be converted back to a continuous signal using certain operations. Discretization of continuous signals is a well-studied field. For example, a rule following the Kotelnikov (Nyquist-Shannon Nyquist) theorem states: "If the discrete frequency is 2 times or more the signal frequency, the signal can be fully recovered". Therefore, if a signal has a frequency of 1 Hz, its amplitude value must be read at least 2 times per second (ie a frequency of 2 Hz). Only in this case is it possible to regain its original form after discretization. Figure 1 shows what happens if we discretize a 1 Hz sine wave with a sampling rate of 2 Hz. The signal is shown in green and the discretized result is shown in red.

After discretization, the sine wave will be converted to a triangle wave. Of course there will be some error, but a low pass filter can be used to convert this triangular signal back to a sine wave. This means that we can recover the signal, preserving its mind, period and amplitude, albeit with some error. Such distortion would be considered critical in music, but irrelevant in trading. But what if the discrete frequency is smaller than the original signal frequency? An example is shown in Figure 2 below.


This schematic shows that if the discrete frequency is less than twice the signal frequency, the resulting signal will be greatly distorted, and in effect we receive a random signal that has nothing to do with the original signal. When applied in trading, the first case will allow us to sell when we see a high and buy when we see a low. Also, the Hertz quantitative trading software has a known frequency. After wrong discretization, we lose information about the magnitude and frequency of the signal. A definite periodic signal of known characteristics changes into a random aperiodic signal of unknown characteristics due to the wrong discrete frequency selection.

Two logical questions follow from the above knowledge: "Did we make a mistake when discretizing the price series?" and "Is the price series a discrete signal or a continuous signal, and what are its parameters?" 

The answer is not simple, but very important.

Is the price series discrete or continuous?
If the Hertz quantitative trading software knows the market price formation mechanism, it can answer this question. I won't go into detail about it, as it is already provided in the article "Prices of Transaction Pricing in the Example of Moscow Exchange's Derivatives Market". Some participants place orders in the depth of market, while others buy the required amount at the desired price. This is what happens when the price chart is formed. These levels are discrete, ie orders can be placed at prices 1, 2, 3, etc. with a certain precision. Since you can buy 1, 2, 3 or more units, the price set in the bid and the quantity bought by the buyer are also discrete. Figure 3 below shows an example of Depth of Market; you will see both price and quantity as discrete values. 

Figure 3.

Therefore, Hertz quantitative trading software can conclude that the price series chart is actually discrete. Prices move along discrete levels after participants buy discrete amounts. 

What is the role of price?
We found that the price series itself is discrete, but which parameter is the price change a function of?

Discretizing the audio signal into regular intervals is an acceptable solution because the audio signal is a time-varying function. The signal itself is time dependent in magnitude. This signal property is fundamental. That's why there is no problem here.

Price series have different properties. Here, magnitude (price) changes over time, but time is not the cause of price change. If you're trying to figure out why prices are moving, the problem is not so simple. Several assumptions can be made:

Price is a function of transactions. Prices will change as trades are executed, as trade operations drive prices. But trading operations may not result in price changes. For example, 10 stocks are available at a price of $1. The participant buys 4 stocks and the remaining 6 stocks are at the same price. Therefore, although the trade operation was performed, the price did not change. However, this operation reduces the volume available for this price, which may cause further price changes when the next participant buys the entire remaining volume. The price changes only after the $1 available stock of shares is insufficient to meet demand, and the availability is fully bought. In this case, the ASK (Ask) price will rise to $1.1. However, other participants were still able to place orders at $1 and pull back the ASK price.
Price is a function of all trading operations on the market. Prices change not only when participants buy out the price of volume at a certain price, but also when they simply cancel an order, or move it to another price. Therefore, with no trade operations, BID (bid) and ASK (ask) prices will also change.
Price is a function of "yield". Prices can change as participants redefine asset values ​​for themselves. There can be entirely different reasons for redefining asset value. In any case, the redefinition of asset value is closely related to the interests of participants. In theory, a given price is in the best interest (even if the benefit is negative) for all participants, including buyers and sellers. Markets were originally created to maximize revenue and determine the best equilibrium price acceptable to both buyers and sellers. The return may not be tied to an asset. For example, an investment foundation needs to sell an asset urgently. They are prepared to do this even if there is a loss, because they can gain other benefits by doing this, for example, they can buy other assets, or pay dividends to customers. The nature of the benefit can vary. In this case, for each participant, price is a function that is redefined each time for revenue.
Price is a function of itself. Obviously, every price change results in a change in the earnings of market participants. Earnings can vary while prices remain constant, but when prices change, participants' earnings also change. This is not the most accurate description of price changes, but it allows us to approximate the ideal model roughly, and to make some assumptions that do not have a significant impact on future results. Basic transaction price changes. Even if we choose the dividend strategy (ignoring the price), paying the dividend will eventually cause the price to change. In this case, the price change is the signal to shift the chart to the left. A price change is recorded only when the price moves by 1 pip. Any step size can be used, depending on the preferred scale: every time n points are moved up or down, the price value can be recorded. 
I think the third option is the most likely, stating that price is a function of redefining returns. But it is not possible to calculate each participant's payoff for a discrete sequence. In the first two cases, trading and non-trading operations in the exchange market can be calculated, but there are difficulties. For example, an asset can be traded on two or more different exchanges. Or, if there are derivatives of the asset, such as futures and options, do we need to count the operations indirectly related to the asset? These questions require a great deal of research individually. In any case, the four cases are indirectly related. The fourth option, that price is a function of itself, can be studied further, provided we assume this is a rough model.

The rate of change in the price of an asset depends on the number of transactions. The more trading operations, the more frequent the price changes, which means there is a direct correlation. Correspondingly, if there are many participants in the market, they will conduct many trading operations, which will lead to more frequent redefinition of each participant's return. Thus, each participant will try to redefine the price more frequently, resulting in more transactions, so the frequency of asset price changes will be high.

Features of discretization of price series by time interval and random components According
to the rough model of Hertz quantitative trading software, the price is its own function, and the price is discretized only when the price changes by a certain number of points. Even if this is not quite true, this assumption will give you further insight into the topic without affecting the final result. Or even, in order to be profitable, we need to know that the price has changed. Also, we need to know how it changes to search for patterns accordingly. 

Every 1 pip the price moves (where a pip is the smallest possible price movement) will be equal to one step. Let's see what happens when the time series is discretized. Obviously, the number of pips covered by the price per unit of time depends on the trading activity. The higher the trading activity (the number of trading operations performed), the more steps the price will eventually go through. Trading activity is not directly related to price changes, but price changes depend on trading activity: the higher the trading activity, the more price changes. Dependence is indirect, but correlation is positive. Suppose the step size is 10 points. One-hour candlesticks will be used in the example. The two diagrams below show prices represented by bricks. These bricks are similar to Renko bars, but they are based on slightly different construction principles. They use the highs and lows of classic candlesticks to show the highs and lows at the time of the brick formation. Like candlesticks, Renko has 4 characteristics: Open, High, Low and Close. The difference from candlesticks is that the distance between the opening and closing prices is always fixed and expressed in points. The Renko closes when the price covers N points vertically. For example, the block size is 10 points. Once the price moves 10 points vertically, the Renko closes and a new Renko begins.
————————————————
Copyright statement: This article is an original article of CSDN blogger "Hertz Quantification Software", following the CC 4.0 BY-SA copyright agreement, please attach the original source link and this statement.
Original link: https://blog.csdn.net/herzqthz/article/details/131769212

Guess you like

Origin blog.csdn.net/herzqthz/article/details/131770558