In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article mainly explains "what is the application method of CUSUM in timing trading". The explanation in the article is simple and clear, and it is easy to learn and understand. Please follow the editor's train of thought to study and learn "what is the application method of CUSUM in timing trading"?
Principle description: the design idea of CUSUM control chart is to accumulate information and add up the small offsets of the process to achieve magnified results, so as to improve the sensitivity of testing small offsets. As a statistic, CUSUM has strict mathematical reasoning. Generally speaking, it is a statistic derived from a change point hypothesis test by maximum likelihood method.
I will not study the specific derivation, but will directly look at the specific quotation.
Form an approximate positive etheric distribution of logarithmic returns. As shown in the figure above, there is an upper and lower offset k, which is set to k = 0.02. If the logarithmic rate of return for the next period in the timing queue is greater than 0.02, the difference will be positive. If the sum of the Ci of the difference cumulative yi is greater than h, for example, h is 0.5. Then trigger an upward trend.
In fact, if the rate of return exceeds the allowable deviation for many times, or a very large rate of return occurs, making the c value greater than h will trigger the upward trend judgment. If it is only occasionally greater than the allowable deviation, then the next time it is less than k (0.02), the difference is negative, and the sum value Ci becomes smaller, where the role of Max is to ensure that C is positive and will not be negative because it is lower than k many times. The same is true of downward trend judgment.
The code is as follows, here the ta-lib library is called to calculate the mean and standard deviation, which is faster than using numpy. Using the standard deviation as the allowable deviation, the standard deviation of 5 times the standard deviation is the h threshold.
# encoding: UTF-8import numpy as npimport pandas as pdimport matplotlib.pyplot as pltimport talibdef detect_via_cusum_lg (ts, istart=30 Threshold_times=5): "" detect a time series using cusum algorithm: param ts: the time series to be detected: param istart: the data from index 0 to index istart will be used as cold startup data to train: param threshold_times: the times for setting threshold: return: "Shumh = 0 Signorl = 0 S_list = np.zeros (istart) meanArray = talib.SMA (ts,timeperiod = istart) stdArray = talib.STDDEV (np.log (ts/meanArray)) Timeperiod = istart) for i in range (istart+1, len (ts)-1): tslog = np.log (TS [I] / meanArray [iMur1]) max (0, Schroh + tslog-stdArray [I-1]) Signorl = min (0 Signorl + tslog + stdArray [I-1]) if Scheh1 > threshold_times * stdArray [I-1]: S_list = np.append (SignorList 1) Signorh0 elif abs (I-1) > threshold_times * stdArray [I-1]: S_list = np.append (S_list) -1) df5min _ = 0 else: S_list = np.append (S_list, 0) Systh = SignorhSystl = Signorldata import df5min = pd.read_csv ("bar5rb8888.csv") dt0 = np.array (df5min ["close"]) listup,listdown = [], [] s_list = detect_via_cusum_lg (dt0,istart=30) Threshold_times=5) for i in range (0Len (s_list)): if slist [I] = 1: listup.append (I) elif sList [I] =-1: listdown.append (I) plt.subplot (2Power1) plt.plot (dt0, color='y', lw=2.) plt.plot (dt0,'^', markersize=5, color='r', label='UP signal', markevery=listup) plt.plot (dt0, 'vested, markersize=5, color='g' Label='DOWN signal', markevery=listdown) plt.legend () plt.legend () plt.subplot (2Magne1Magne2) plt.title ('sworn listings') plt.plot (scurvy listmings') plt.show () Thank you for your reading The above is the content of "what is the application method of CUSUM in timing trading". After the study of this article, I believe we have a deeper understanding of what is the application method of CUSUM in timing trading, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.