Free Quantitative Stock Trading Software: Statistical Arbitrage Trading Strategies

economic regulation

According to the theory proposed by Adam Smith in his book "An Inquiry into the Nature and Causes of the Wealth of Nations"[1] (The Wealth of Nations), all economic processes are automatically governed by the market economy according to the relationship between supply and demand regulation and thus remain in optimum condition.

Unfortunately, however, in practice it's a different story. Market supply and demand often distort financial relationships and cause economic crises.

In order to reduce the impact of economic imbalances, government regulatory agencies are involved in helping the market economy.

The goal of government regulatory agencies is to indirectly control economic processes by using:

  • Bank reserves, such as accumulated insurance funds
  • Import and Export Quotas
  • Subsidize certain sectors of the economy that cannot survive on their own in world competition
  • adjust interest rate

interest rate

Central banks use interest rates to control economic processes at the government level:

  • The Official Discount Rate (ODR) is the most effective government economic adjustment tool. This is the rate the central bank charges commercial banks that borrow money from it.
  • The repo rate is the rate used by the central bank to collect and repurchase government bonds from commercial banks.
  • The funds rate is the interest rate on reserves.
  • The Lombard rate is the rate charged on mortgage-backed loans

regulate the economy


Don't have the illusion of living in a "free" market economy. Adam Smith's ideas were too idealistic. Market participants do not necessarily regulate economic processes at their own risk. And for business reasons, they often invest in counter-markets, such as:

  • Invest in drug trafficking. The result was a partial disability of the population and an increase in crime.
  • Invest in bubbles. As a result, finance ceases to be part of economic production and consumption of goods and becomes part of lottery scams. Such investments end up costing a sizable portion of their savings.
  • Invest in derivatives. Derivatives act as destabilizers of market supply and demand, bringing about significant economic changes that ultimately lead to world crises.

Hertz quantitative trading software lives in the era of regulated economy. The government has not yet focused on where planning directly controls the economic process, although it is regulated.

official discount rate

The discount rate set by a country's central bank is one of the main investment factors. It provides investors, especially those from other countries, with an indicator of the percentage of return they can make on deposits in a country in that country's local currency or on purchases of that country's government bonds. The higher the discount rate, the more interest.

Therefore, the central bank uses the discount rate to regulate the country's economy, that is, by increasing the discount rate to attract investors (if necessary), or reducing the discount rate when the economy is overheating.

However, one should not indulge in fantasies. A higher discount rate does not necessarily increase the attractiveness of the currency. There is one important factor for investors to consider – inflation. If the inflation rate is much higher than the discount rate, there is no reason to invest in such an economy.

For example, the central bank of Zimbabwe once raised the discount rate to 950%, which only scared away investors, because the money printed by the country could not keep up with inflation, and the printing paper was more expensive than the face value of the banknotes.

A low discount rate is not always indicative of real economic overheating, but is usually a signal of extreme bubble epidemics.

Arbitrage Trading Strategy

A carry trade is a strategy to profit based on a positive swap rate.

In foreign exchange transactions, the discount rate is converted into the difference between the discount rate of the currency to be bought and the currency to be sold, that is, the swap rate. Therefore, for multiple buys or sells, the difference can be negative. Making money on positive swap rates is attractive to traders, especially given leverage. However, leverage is a double-edged sword, that is, if the price starts to move in the opposite direction to the open position, losses can exceed potential future profits and lead to additional margin calls. Therefore, making money trading Forex based on swaps is risky.

Arbitrage trading has some significant advantages, for example, as a low-frequency trading strategy, it does not have the problems associated with high-frequency trading, such as the need to constantly monitor trading signals, connection failures, etc. VPS hosting is not essential. You just need to keep an eye on the stats and news once in a while.

This article will present a carry trade protection strategy that compensates for the potential risk of price movements in the opposite direction of the open position.

The statistical carry trade strategy is a multi-currency strategy because it involves two or more currency pairs in order to compensate for potential losses from undesired price movements caused by correlation. However, it is implemented by gradually increasing the asset's profitability, even when prevented by negatively correlated financial instruments.

A Mathematical Algorithm for Statistical Arbitrage Trading

Statistical arbitrage trading is based on the following assumptions:

  1. The price of the currency pair will move in the direction of a positive swap rate.
  2. Two or more currency pairs are positively correlated if they are quoted in highly circulated currencies. Therefore, price movements can be offset by an inverse positively correlated position.

However, assumptions are not treated as fixed principles; therefore, the above two points are merely assumptions that need to be proven using statistical methods. Probably because most investors, for one reason or another, differ on fundamentals and prefer to avoid risk regardless of positive swap rates.

Since the carry trade protection strategy involves several currency pairs that offset each other for unwanted price movements, the statistical analysis of the quotation process using historical data should be very thorough.

In a very simple case with n currency pairs, the statistical model of the quotation process is a linear equation as follows:

v1 * d1 + v2 * d2 + … + vn * dn = profit
where:
n is the total number of financial instruments.
v1, v2, ..., vn are the positions to be opened in the corresponding financial instruments. If the value of the position volume is negative, a sell position is opened.
d1, d2, ..., dn are the average price changes of a certain financial instrument during a trading day.
profit is the average profit for a trading day.

If the simplification is done for two financial instruments, the formula becomes shorter:

v1 * d1 + v2 * d2 = profit


Transform it:

d1  =  (-v2 * d2 + profit) / v1


In this example, if we assume:

v1 = 1
y = d1
a = -v2
b = profit

We get the classical linear equation with one independent variable and two unknowns:

y = a * x + b
can use the classic least squares method to calculate the unknowns a and b.

After that, you should specify the profit size using the swap rate and get the final result of the potential profit for one trading day:

b' = b - swap1 + a * swap2
where:

swap1 and swap2 are the swap rates of the currency pairs calculated within one trading day in the corresponding opening direction.
Because the algorithm strategy introduced in this article assumes that two conditions are met at the same time:
  1. The volume and direction of currency pairs are chosen so that they are profitable on average.
  2. The swap rate is positive for all currency pairs involved in the strategy.

Additional tests using the last formula against the above conditions become unnecessary.

example

Why in our formula we get y = a*x + b, b = profit?
Suppose   the daily price movement of two currency pairs denoted by identifiers y  and  x can be described by the following formula:

y = 2 * x + 1
transforms this into a similar formula:

y – 2 * x = 1
That is, Hertz quantification requires opening a long position (positive sign) in the first financial instrument and a short position (negative sign) in the second financial instrument, the size of which is Double the first position (because a = 2).

In our example, the prices of the current instruments are 10 and 8 respectively.

Suppose the price of two financial instruments increases by 1 in one trading day, i.e. reaches 9. Therefore, the price of the first financial instrument will, on average, move by 2*x+1 = 2*1+1=3, reaching 13 (prices of both financial instruments increase at the same time, because there is a positive correlation). Since the position of the second financial instrument is a short position, its loss will be 2, while the position of the first financial instrument is a long position, which will earn 3. The difference, i.e. profit, will be +1.

Suppose that after the next trading day, the price of the second financial instrument decreases by 1, returning to the previous value of 8. In this case, the price of the first financial instrument will also decrease by the value 2*x + 1 = 2 * -1 + 1 = -1, which is equal to 12. Calculation result: loss of 1 on the first financial instrument, profit of 2 on the second financial instrument. The end result is still +1. That is, regardless of the direction and range of price movement, on average we still get the profit specified in the formula and   denoted by the identifier b .

Thus, knowing the formula expressed as a linear equation, we can determine the direction and amount of opening a position in two correlated financial instruments, thereby obtaining an average return regardless of the price direction.
But don't lose your self-control, because the formula is calculated by the method of least squares, that is, following statistical methods and using historical data. It cannot guarantee any future profitability. When using historical data and doing arbitrage trading, we need statistics to ensure that the chosen market entry direction is profitable. If in the future things do not go as expected based on calculations, Hertz Quant will still be able to profit from the swap rate difference.

implement

Manual calculation is too time-consuming and labor-intensive, it is better to leave the least squares calculation to an EA.

The EA calculates the direction and volume of positions in two financial instruments to obtain an average profit. Then, it requests the server for information about the value of the swap rate for the selected opening direction and, in case both swap rates are positive, provides a proposal.

Guess you like

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