The resource loading... loading...

Quantitative fractional rate trading strategy

Author: homily, Created: 2020-02-05 13:23:07, Updated: 2023-10-17 21:19:29

img

About us

This trading system is泊宇量化I've been a part of a team that's been working on quantitative strategies for a long time. Last year, the Tokeninsight quantification contest was a great success.

I am also very grateful to the FMZ community for providing such a platform. In order to better support quantitative community building, the design concepts and design ideas for this strategy are now publicly available here. I hope you can learn from it about the design and use of quantitative trading.

The origin of the quantitative fractional rate trading strategy

The quantum spectral rate system was inspired mainly by physics Physics defines velocity as the distance travelled in units of time. If price is viewed as distance, then in financial markets, speed is defined as the magnitude of price change per unit of time. If the price variation is large in unit time, it is usually called a fast market; if the price variation is small in unit time, it is called a slow market. Therefore, speed is a natural law that combines time and price. If the rate rises, it represents an increase in energy, which can effectively predict the upward trend of the market. If the rate drops, it represents a power failure, which can be perceived as a risk of a slowdown or fall in the market. Each transaction uses a certain number of hands, so it is called a quantitative fractional rate trading system.

Knowledge needed to prepare

Highest price (HHV): the highest price reached in a given cycle.The lowest price (LLV): the lowest price reached in a given cycle.Moving Average (MA)The following is a link to the average closing price for a particular period.The slope of regression (SLOPE): slope of linear regression of a particular period.

The slope formula for the linear equation OLS is as follows:imgThe mathematical formulas are very complicated, but the FMZ platform has already written a syntactical formula for us in Malayalam (SLOPE). The following algorithms can be found in the Malayalam grammar manual:

imgThe process is a bit complicated, but you don't have to think about it at all.

Design of indicators:

1. Calculate the highest and lowest price in a given time period 2. Take the average of these two prices. 3. Calculate a moving average for the mean 4. The slope of the regression of the straight line

img

By designing the indicator, we run a regression, and as you can see in the main diagram, we get the high point of 35 cycles (yellow line) and the lowest point of the cycle (yellow line). The lows (green lines), their averages (red lines), and the smooth price averages (purple lines) calculated for the red linesimg

We can then calculate the regression slope ss in the appendix, which represents the rate of rise and fall of the straight line.img

How to design a trading strategy:

As can be seen from the above diagram, the green arrows indicate the bends at the lowest slope, and the orange arrows indicate the bends at the highest slope, respectively. The reaction sequence is on the k-line, and the upward weakening and downward weakening positions can also be clearly felt. If you buy and sell at a turning point, you can effectively trade the market early, rather than chasing highs or lows.

The idea behind the design is:The slope continues to rise, which means that the market momentum increases, which can lead to a stop or a rise. The slope continues to fall, which means that the market momentum is weak, which can lead to stagnation or decline.

The following is a description of the design in Ma' language:img

Review and summary

So we're done with the design of the algorithm, and then we use the system to go back a year and see what happens.

The item is the OKEX quarterly contract btc; The retest cycle is 1 hour from January 1, 2019 to today; The initial account is 3 BTC, with a processing fee of $5,000. Set the number of hands to 200 per trade.

imgIn fact, the results of this study show that the benefits are relatively smooth and stable. In this review, 1,261 transactions were made throughout the year. The projected earnings are 4.68 yen. Annual earnings of about 140%; The maximum withdrawal rate is 14%. Sharp is 0.117.

The source code shared:

Click to go to copy policy https://www.fmz.com/strategy/183416The above are some of the ideas and content I have designed, and the following is the full code of the Mac language. Please provide reference for learning research. If you need to translate, please note where thank you.

(*backtest
start: 2019-01-01 00:00:00
end: 2020-02-03 00:00:00
period: 1h
exchanges: [{"eid":"Futures_OKCoin","currency":"BTC_USD"}]
args: [["TradeAmount",200,126961],["ContractType","quarter",126961]]
*)

len:=35;//设计周期数

hh^^HHV(H,len);//取一定周期内的最高价
ll^^LLV(L,len);//取一定周期内的最低价
hl2^^(hh+ll)/2;//最高价、最低价的平均值
avg^^MA(hl2,5);//对平均值计算平滑移动均线

ss:SLOPE(avg,len);// 对均线计算回归斜率

ss<REF(ss,1),SPK;//当斜率变小说明行情动能减弱,有下跌趋势,平多做空
ss>REF(ss,1),BPK;//当斜率变大说明行情动能不断增加,有上升趋势,平空做多
AUTOFILTER;

Related

More

dsaidasiIn a year, more than a thousand transactions are made, and the cost of handling the transaction explodes.

Difficult to quantifyGreat, so concise and nice code. There is a question why the same code and retest conditions would have a large gap in retest results on different exchanges. For example, OKEX futures and huobiDM, the former and the latter are expected to earn 4.68 and 1.99 cents respectively.

grootAnd this reassessment, which is fixed at 200 pieces, is equivalent to reducing stocks close to the cap, doing more is leveraging, and in general, it's still a big head.

grootIf it's a derivative of the rate, shouldn't it be the maximum minus the minimum, the average of the maximum plus the minimum to get the maximum?

homilyThere is a difference between the quarterly and the permanent prices, and there may be a difference in the calculation of the number of invoices.

homilyThis is the middle track of the Dongjian channel, and the maximum minus minimum is just a negative value.

homilyI'm not sure what to do about it.