Index correlation comparative analysis method and system
By calculating the time series data of financial indexes and industry indexes, determining their translational correlation and times, and using dual-axis charts to display the results, the problem of being unable to accurately identify the leading/lag situation of the index in the existing technology is solved, and the financial index and industry index are realized. Accurate correlation analysis between indices.
Patent Information
- Application Number
- CN202410875862.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-01
- Publication Date
- 2024-10-01
AI Technical Summary
Existing index correlation comparative analysis methods cannot accurately identify the true lead/lag situation between financial indexes and industry indexes, resulting in problems that are inconsistent with reality.
Using time series data, by calculating the correlation coefficient and number of times when the industry index shifts to the left and right relative to the financial index, comparing the correlation coefficient and the number of translations, determine the translation direction and correlation, and use dual-axis charts to display the results to achieve accurate Lead/lag days analysis.
This method can accurately determine the number of leading/lag days between the financial index and the industry index, evaluate the correlation strength between the two, determine the positive or negative relationship, and provide accurate index correlation comparative analysis results.
Smart Images

Figure CN118735347A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of shipping informationization and intelligent technology, and in particular to an index correlation comparative analysis method and system. Background Art
[0002] In the financial market, financial institutions will release various indices that reflect the operation of the financial market, such as the Shanghai Composite Index (SSE Index) released by the Shanghai Stock Exchange, which reflects the price changes of stocks listed on the Shanghai Stock Exchange, which is called the financial index. In the field of shipping informatization and intelligence, there are also various freight rate indices released by the Shanghai Shipping Exchange that reflect the "barometer" of the shipping market, such as the China Coastal Coal Freight Index (CBCFI), which specifically reflects the changes in spot freight rates in the coastal coal transportation market, which is called the industry index.
[0003] At present, in the comparative analysis of the two indices (financial index and industry index), the goal is to use the internal shipping index to predict the public index. In the prediction process, the internal shipping index is actively advanced by a certain number of days, so that the internal shipping index actively leads the public index, so that the internal shipping index can be used to predict the public index. However, there is a discrepancy between this actively created leading situation and the actual situation, which may be the opposite. Therefore, there is an urgent need for a method to identify the real leading / lagging situation between the two indices. Summary of the invention
[0004] In order to solve the problems existing in the existing index correlation comparison and analysis process, such as the discrepancy between the actual situation and the inability to identify the true and accurate leading / lagging situation between the two indexes, the present invention provides an index correlation comparison and analysis method, which is based on the financial index and the industry index of the time series, and uses a specific judgment method and calculation method to calculate the correlation coefficient of the industry index relative to the financial index when it is translated to the left and right, as well as the number of times it is translated to the left and right, and compares the correlation coefficient when it is translated to the left with the correlation coefficient when it is translated to the right to determine the translation correlation coefficient, the number of times it is translated, and the translation direction, and displays it through a dual-axis graph, so as to obtain the accurate leading / lagging days between the two indexes. The present invention also relates to an index correlation comparison and analysis system.
[0005] The technical solution of the present invention is as follows:
[0006] A comparative analysis method of index correlation, characterized by comprising the following steps:
[0007] Array acquisition and array length calculation steps: collect the time series data of the financial index and the industry index within a certain period of time, obtain the financial index array and the industry index array, and use the length function in the script language to calculate the length of the financial index array and the length of the industry index array;
[0008] The steps of calculating the correlation of the industry index shifting to the left relative to the financial index are as follows: the initial leftward shift correlation coefficient, the absolute value of the leftward shift correlation coefficient, the number of leftward shifts and the current number of shifts are set when the industry index shifts to the left relative to the financial index, and the current number of shifts is compared with the preset maximum number of shifts. If the current number of shifts is less than the preset maximum number of shifts, the starting subscript of the financial index subarray in the financial index array is calculated according to the length of the financial index array, the length of the industry index array and the current number of shifts, and the ending subscript of the financial index subarray is calculated according to the length of the financial index array and the current number of shifts; then, it is determined whether the value of the starting subscript is less than the preset numerical threshold value. If so, the starting subscript and the ending subscript are recalculated. If not, it is determined whether the difference between the ending subscript and the starting subscript is less than the preset minimum amount of comparison data. If the difference is greater than or equal to the preset minimum amount of comparison data, Then, the financial index subarray is cut out from the financial index array according to the start subscript and the end subscript of the financial index subarray, and the industry index subarray is cut out from the industry index array according to the length of the industry index array and the length of the financial index subarray; then, the average values of the financial index subarray and the industry index subarray are calculated respectively, and the correlation coefficient between the financial index subarray and the industry index subarray is calculated according to the value of each data in the financial index subarray and the value of each data in the corresponding industry index subarray, the average values of the financial index subarray and the industry index subarray and the Pearson correlation coefficient formula; then, it is determined whether the absolute value of the correlation coefficient is greater than the absolute value of the initial leftward translation correlation coefficient. If so, the leftward translation correlation coefficient is updated to the correlation coefficient, the absolute value of the leftward translation correlation coefficient is updated to the absolute value of the correlation coefficient, and the number of leftward translations is updated to the current number of translations;
[0009] Left shift parameter extraction step: add one to the current number of shifts and repeat the step of calculating the correlation of the industry index to the financial index to the left, until the current number of shifts is greater than or equal to the preset maximum number of shifts, or the difference between the end subscript value and the start subscript value is less than the preset minimum amount of comparison data, then the loop is stopped, and the number of left shifts, the left shift correlation coefficient, and the absolute value of the left shift correlation coefficient when the loop is stopped are obtained;
[0010] Parameter comparison and translation parameter judgment steps: Calculate the right translation correlation of the industry index relative to the financial index based on the same principles as the left translation correlation calculation steps and the left translation parameter extraction steps to obtain the number of right translations, the right translation correlation coefficient and the absolute value of the right translation correlation coefficient, and then compare the absolute value of the left translation correlation coefficient with the absolute value of the right translation correlation coefficient. If the absolute value of the left translation correlation coefficient is greater than the absolute value of the right translation correlation coefficient, the translation direction is left translation, the number of translations is the number of left translations, and the translation correlation coefficient is the left translation correlation coefficient; if the absolute value of the left translation correlation coefficient is less than or equal to the absolute value of the right translation correlation coefficient, the translation direction is right translation, the number of translations is the number of right translations, and the translation correlation coefficient is the right translation correlation coefficient;
[0011] Index display steps: Use a dual-axis chart to display the translation direction, translation times and translation correlation coefficient, obtain the relative trend of the financial index and the industry index, and realize the comparative analysis of the correlation between the financial index and the industry index.
[0012] Preferably, in the index display step, the leading situation of the financial index and the industry index is judged according to the translation direction. If the translation direction is to the left, the financial index is judged to be ahead of the industry index. If the translation direction is to the right, the industry index is judged to be ahead of the financial index.
[0013] Preferably, in the index display step, the translational correlation coefficient is compared with a preset threshold. If the translational correlation coefficient is greater than the preset threshold, the industry index is strongly correlated with the financial index. If the translational correlation coefficient is less than or equal to the preset threshold, the industry index is weakly correlated with the financial index.
[0014] Preferably, in the step of calculating the correlation of the leftward translation of the industry index relative to the financial index, if the current number of translations is greater than or equal to the preset maximum number of translations, the number of leftward translations, the leftward translation correlation coefficient and the absolute value of the leftward translation correlation coefficient are directly output.
[0015] An index correlation comparison and analysis system, characterized by comprising an array acquisition and array length calculation module, an industry index relative to a financial index leftward translation correlation calculation module, a leftward translation parameter extraction module, a parameter comparison and translation parameter judgment module and an index display module, which are connected in sequence.
[0016] The array acquisition and array length calculation module collects time series data of financial index and industry index in a certain period of time, obtains financial index array and industry index array, and calculates the length of financial index array and the length of industry index array by using the length function in the scripting language;
[0017] The module for calculating the correlation between the industry index and the financial index shifting to the left sets the initial left shift correlation coefficient, the absolute value of the left shift correlation coefficient, the number of left shifts and the current number of shifts when the industry index shifts to the left relative to the financial index, and compares the current number of shifts with the preset maximum number of shifts. If the current number of shifts is less than the preset maximum number of shifts, the starting subscript of the financial index subarray in the financial index array is calculated according to the length of the financial index array, the length of the industry index array and the current number of shifts, and the ending subscript of the financial index subarray is calculated according to the length of the financial index array and the current number of shifts; and the module for calculating the ending subscript of the financial index subarray is determined according to the length of the financial index array and the current number of shifts; and then determines whether the value of the starting subscript is less than the preset numerical threshold value. If so, the starting subscript and the ending subscript are recalculated. If not, it is determined whether the difference between the ending subscript and the starting subscript is less than the preset minimum amount of comparison data; if the difference is greater than or equal to the preset minimum amount of comparison data , then the financial index subarray is intercepted from the financial index array according to the start subscript and the end subscript of the financial index subarray, and the industry index subarray is intercepted from the industry index array according to the length of the industry index array and the length of the financial index subarray; then the average values of the financial index subarray and the industry index subarray are calculated respectively, and the correlation coefficient between the financial index subarray and the industry index subarray is calculated according to the value of each data in the financial index subarray and the value of each data in the corresponding industry index subarray, the average values of the financial index subarray and the industry index subarray and the Pearson correlation coefficient formula; then it is determined whether the absolute value of the correlation coefficient is greater than the absolute value of the initial leftward translation correlation coefficient. If so, the leftward translation correlation coefficient is updated to the correlation coefficient, the absolute value of the leftward translation correlation coefficient is updated to the absolute value of the correlation coefficient, and the number of leftward translations is updated to the current number of translations;
[0018] The left-shift parameter extraction module adds one to the current number of shifts and repeats the work of the left-shift correlation calculation module of the industry index relative to the financial index until the current number of shifts is greater than or equal to the preset maximum number of shifts, or the difference between the end subscript value and the start subscript value is less than the preset minimum amount of comparison data, and the loop is stopped to obtain the left-shift number, the left-shift correlation coefficient, and the absolute value of the left-shift correlation coefficient when the loop is stopped;
[0019] The parameter comparison and translation parameter judgment module calculates the right translation correlation of the industry index relative to the financial index according to the same principle as the left translation correlation calculation module and the left translation parameter extraction module, and obtains the number of right translations, the right translation correlation coefficient and the absolute value of the right translation correlation coefficient, and then compares the absolute value of the left translation correlation coefficient with the absolute value of the right translation correlation coefficient. If the absolute value of the left translation correlation coefficient is greater than the absolute value of the right translation correlation coefficient, the translation direction is left translation, the number of translations is the number of left translations, and the translation correlation coefficient is the left translation correlation coefficient; if the absolute value of the left translation correlation coefficient is less than or equal to the absolute value of the right translation correlation coefficient, the translation direction is right translation, the number of translations is the number of right translations, and the translation correlation coefficient is the right translation correlation coefficient;
[0020] The index display module uses a dual-axis graph to display the translation direction, translation times and translation correlation coefficient, obtains the relative trend of the financial index and the industry index, and realizes the comparative analysis of the correlation between the financial index and the industry index.
[0021] Preferably, in the index display module, the leading situation of the financial index and the industry index is judged according to the translation direction. If the translation direction is to the left, the financial index is judged to be ahead of the industry index. If the translation direction is to the right, the industry index is judged to be ahead of the financial index.
[0022] Preferably, in the index display module, the translational correlation coefficient is compared with a preset threshold. If the translational correlation coefficient is greater than the preset threshold, the industry index is strongly correlated with the financial index. If the translational correlation coefficient is less than or equal to the preset threshold, the industry index is weakly correlated with the financial index.
[0023] Preferably, in the leftward translation correlation calculation module of the industry index relative to the financial index, if the current number of translations is greater than or equal to the preset maximum number of translations, the number of leftward translations, the leftward translation correlation coefficient and the absolute value of the leftward translation correlation coefficient are directly output.
[0024] The technical effects of the present invention are as follows:
[0025] The present invention provides an index correlation comparative analysis method, which is used for comparative analysis of whether there is a relationship between a financial index and an industry index, and analyzing the number of days that the financial index leads / lags behind the industry index. First, the time series data of the financial index and the industry index in a certain time period are obtained to obtain a financial index array and an industry index array, and then a specific judgment method and calculation method are used to calculate the left translation correlation coefficient, the absolute value of the left translation correlation coefficient and the number of left translations when the industry index is translated to the left relative to the financial index, and the right translation correlation coefficient, the absolute value of the right translation correlation coefficient and the number of right translations when the industry index is translated to the right relative to the financial index, and then the absolute value of the left translation correlation coefficient is compared with the absolute value of the right translation correlation coefficient to obtain the translation direction, the number of translations and the translation Pearson correlation coefficient, and finally the translation direction, the number of translations and the translation Pearson correlation coefficient are displayed through a dual-axis graph to obtain the relative trend of the financial index and the industry index, and the accurate number of leading / lagging days between the two indexes can be obtained. The present invention is based on financial index and industry index, and through the collaborative work between various steps, it well solves the problems of how to judge the leading / lagging situation between the two, how to calculate the leading / lagging days, and how to display the index correlation comparison analysis results. The correlation result of the financial index and the industry index is obtained by this method. Through this result, the relationship between the two indexes can be effectively judged. The strength of the relationship between the two indexes can be further judged by the size of the correlation result. Whether the relationship between the two indexes is positive or negative can be judged by the positive or negative of the correlation result. In particular, the accurate leading / lagging days between the two indexes are obtained.
[0026] The present invention also relates to an index correlation comparative analysis system, which corresponds to the above-mentioned index correlation comparative analysis method, and includes an array acquisition and array length calculation module, an industry index relative to the financial index to the left translation correlation calculation module, a parameter comparison and translation parameter judgment module and an index display module which are connected in sequence. The modules work together to calculate the correlation coefficient of the industry index relative to the financial index when it is translated to the left and right, and the number of times it is translated to the left and right based on the financial index and the industry index in the time series, and compare the correlation coefficient when it is translated to the left with the correlation coefficient when it is translated to the right to determine the translation correlation coefficient, the number of translations and the translation direction, and display them through a dual-axis graph to obtain the accurate leading / lagging days between the two indexes. BRIEF DESCRIPTION OF THE DRAWINGS
[0027] Figure 1 It is a flow chart of the index correlation comparative analysis method of the present invention.
[0028] Figure 2 This is a flowchart of the correlation calculation of the industry index relative to the financial index shifted to the left in the present invention.
[0029] Figure 3-Figure 7 is a schematic diagram of an embodiment of the present invention.
[0030] Figure 8 It is a schematic diagram of the financial index and the industry index on a dual-axis graph of the present invention.
[0031] Fig. 9 It is a schematic diagram of the comparison results of the financial index and the industry index on the dual-axis graph of the present invention. DETAILED DESCRIPTION
[0032] The present invention will be described below in conjunction with the accompanying drawings.
[0033] The present invention relates to an index correlation comparative analysis method, which is used for comparative analysis of whether there is a relationship between a financial index and an industry index, and intelligently identifying the true leading / lagging situation between the two indexes. Two auxiliary technologies are mainly introduced: one is the Pearson Correlation Coefficient, which is used in statistics to measure the degree of correlation (linear correlation) between two variables X and Y, and its value is between [-1,1]. The larger the value, the higher the degree of correlation, the smaller the value, the lower the degree of correlation, and 0 indicates that they have no correlation. The other is a dual-axis chart, which is a data chart with two Y axes. It can display two sets of data in one icon, which is suitable for comparative analysis of two sets of data, and is also suitable for analyzing two data with large differences, and data year-on-year analysis scenarios. The flowchart of the method is as follows Figure 1 As shown, the following steps are included in sequence:
[0034] 1. Array acquisition and array length calculation steps: Collect the time series data of the financial index and industry index within a certain period of time, obtain the financial index array and the industry index array, and use the length function in the scripting language to calculate the length of the financial index array and the length of the industry index array.
[0035] Specifically, first collect the time series data of the financial index and the industry index within a certain period of time to obtain the financial index array and the industry index array, that is, collect a set of financial index arrays, recorded as X; collect a set of industry index arrays, recorded as Y. Use Xi and Yi to represent the financial index and industry index of the i-th day. For example, the financial index of the first day is recorded as X1, and the financial index of the fifth day is recorded as X5. The same is true for the industry index. Then determine the maximum number of translations, recorded as MAX_MOVE_COUNT. When the maximum number of translations is exceeded, it is considered that the financial index is seriously ahead / lags behind the industry index. At this time, it will be meaningless to study the relationship between them. And determine the minimum amount of comparison data, recorded as MIN_ELEMENT_SIZE. When the minimum amount of comparison data is less than the minimum amount of comparison data, the correlation coefficient calculated using the Pearson correlation coefficient formula cannot well reflect the correlation between the financial index and the industry index.
[0036] 2. Calculation steps of the correlation of the industry index with respect to the financial index to the left: set the initial left-shift correlation coefficient, the absolute value of the left-shift correlation coefficient, the number of left-shifts and the current number of shifts, compare the current number of shifts with the preset maximum number of shifts, if the current number of shifts is less than the preset maximum number of shifts, then calculate the starting subscripts of the financial index subarray in the financial index array and the industry index subarray in the industry index array according to the length of the financial index array, the length of the industry index array and the current number of shifts, and calculate the ending subscripts of the financial index subarray and the industry index subarray according to the length of the financial index array or the length of the industry index array and the current number of shifts; then determine whether the respective starting subscripts are less than the preset numerical threshold, if so (that is, the starting subscript is less than the preset numerical threshold), recalculate the starting subscript and the ending subscript, if not (that is, the starting subscript is greater than or equal to the preset numerical threshold), then determine whether the difference between the respective ending subscripts and the starting subscripts is less than the preset if not (i.e., the difference is greater than or equal to the preset minimum amount of comparison data), then the financial index subarray is cut out from the financial index array according to the start subscript and the end subscript of the financial index subarray, and the industry index subarray is cut out from the industry index array according to the length of the industry index array and the length of the financial index subarray; then the average values of the financial index subarray and the industry index subarray are calculated respectively, and the correlation coefficient between the financial index subarray and the industry index subarray is calculated according to the value of each data in the financial index subarray and the value of each data in the corresponding industry index subarray, the average values of the financial index subarray and the industry index subarray and the Pearson correlation coefficient formula; then it is determined whether the absolute value of the correlation coefficient is greater than the absolute value of the initial leftward translation correlation coefficient, and if so, the leftward translation correlation coefficient is updated to the correlation coefficient, the absolute value of the leftward translation correlation coefficient is updated to the absolute value of the correlation coefficient, and the number of leftward translations is updated to the current number of translations.
[0037] Specifically, calculate the correlation when the industry index array Y is shifted to the left relative to the financial index array X, such as Figure 2 As shown, the description is as follows:
[0038] S1: First, define the number of left shifts LEFT_MOVE_COUNT, the left shift correlation coefficient LEFT_SCORE, the absolute value of the left shift correlation coefficient LEFT_SCORE_ABS, and the current number of shifts count, and assign them all an initial value of 0;
[0039] S2: Determine whether the current number of translation count is less than the preset maximum number of translations MAX_MOVE_COUNT. If the current number of translation count is less than the preset maximum number of translations MAX_MOVE_COUNT, execute step S3; if not, end the calculation and directly output the number of left translations LEFT_MOVE_COUNT, the left translation correlation coefficient LEFT_SCORE and the absolute value of the left translation correlation coefficient LEFT_SCORE_ABS;
[0040] S3: Use the length function len() in the scripting language (Python) to calculate the length X.len() of the financial index array and the length Y.len() of the industry index array respectively, and calculate the starting subscript from of the financial index subarray according to the length of the financial index array, the length of the industry index array and the current number of translations, where from = X.len() - Y.len() - count; calculate the ending subscript to of the financial index subarray according to the length of the financial index array and the current number of translations, where to = X.len() - count;
[0041] S4: Determine whether the starting subscript value from is less than 0. If the starting subscript value from is less than 0, execute step S5; otherwise, execute step S6;
[0042] S5: Set the starting subscript value from to 0, and recalculate the ending subscript to;
[0043] S6: Determine whether the difference between the end subscript to and the start subscript from (i.e., to-from) is less than the preset minimum comparison data amount. If so, terminate the calculation and output the number of left translations, the left translation correlation coefficient, and the absolute value of the left translation correlation coefficient; otherwise, execute step S7;
[0044] S7: extract the financial index subarray, recorded as x; extract the industry index subarray, recorded as y; sub(from, to) means extracting a subarray from an array with the subscript starting from from and ending at to, with a length of to–from;
[0045] S8: Use the Pearson correlation coefficient formula to calculate the correlation coefficient between the financial index subarray x and the industry index subarray y, that is, the Pearson correlation coefficient of x and y, recorded as score; and calculate the absolute value of the correlation coefficient, recorded as score_abs;
[0046]
[0047] in, and is the average of X and Y;
[0048] S9: Compare the absolute value score_abs of the correlation coefficient between the financial index subarray and the industry index subarray with the absolute value LEFT_SCORE_ABS of the left shift correlation coefficient. If score_abs is greater than LEFT_SCORE_ABS, reset the number of left shifts LEFT_MOVE_COUNT to the current number of shifts count, reset the left shift correlation coefficient LEFT_SCORE to the correlation coefficient score between the financial index subarray and the industry index subarray, and reset the absolute value LEFT_SCORE_ABS of the left shift correlation coefficient to the absolute value score_abs of the correlation coefficient between the financial index subarray and the industry index subarray.
[0049] 3. Left shift parameter extraction step: add one to the current number of shifts and repeat the step of calculating the correlation of the industry index to the financial index to the left until the current number of shifts is greater than or equal to the preset maximum number of shifts, or the difference between the end subscript value and the start subscript value is less than the preset minimum amount of comparison data, and then stop the loop, and obtain the number of left shifts, the left shift correlation coefficient, and the absolute value of the left shift correlation coefficient when the loop stops. This step can be understood as the following step S10,
[0050] S10: Add 1 to the current number of translations, that is, the industry index Y continues to translate 1 step to the left, and continue to execute steps S2-S9 until the current number of translations count is greater than or equal to the preset maximum number of translations MAX_MOVE_COUNT, or the difference between the end subscript value and the start subscript value (that is, to-from) is less than the preset minimum amount of comparison data, then stop the loop, and obtain the number of left translations, left translation correlation coefficient, and absolute value of the left translation correlation coefficient when the loop is stopped.
[0051] The following is an example to describe the above calculation process. Assume that Figure 3 The numbers in the two sets of data X and Y shown here only indicate the subscript positions of the two sets of data and have nothing to do with the specific values. First, since the base period of the index, that is, the time of the first release, may be different, but the index from the base period to the current time can be obtained, so, for example Figure 4 As shown, align the right ends of X and Y.
[0052] Then, the overlapping parts of X and Y are taken as their respective subarrays, and the Pearson correlation coefficient of the subarrays of the overlapping parts of X and Y is calculated. The number of subarrays of the overlapping parts cannot be less than the minimum comparison data size MIN_ELEMENT_SIZE (here, the minimum comparison data size is set to 6). Figure 4 In the case of , the Pearson correlation coefficient between x = [X2, X3, X4, X5, X6, X7, X8] and y = [Y0, Y1, Y2, Y3, Y4, Y5, Y6] is calculated. At this time, Y is not translated, and the first comparison is performed.
[0053] When Y is shifted to the left once, a second comparison is performed, such as Figure 5 As shown, the correlation coefficient between x = [X1, X2, X3, X4, X5, X6, X7] and y = [Y0, Y1, Y2, Y3, Y4, Y5, Y6] is calculated. When Y is shifted to the left twice, the third comparison is performed, as shown in Figure 6 As shown, the correlation coefficient between x = [X0, X1, X2, X3, X4, X5, X6] and y = [Y0, Y1, Y2, Y3, Y4, Y5, Y6] is calculated. When Y is shifted to the left three times, the fourth comparison is performed, as shown in Figure 7 As shown, the correlation coefficient between x=[X0,X1,X2,X3,X4,X5] and y=[Y1,Y2,Y3,Y4,Y5,Y6] is calculated. When Y is shifted to the left 4 times, if the number of overlapping subarrays is less than 6, the calculation will stop and the final result will be output, that is, the correlation coefficient between x and y when Y is shifted to the left 3 times.
[0054] 4. Parameter comparison and translation parameter judgment steps: Calculate the right translation correlation of the industry index relative to the financial index based on the same principles as the left translation correlation calculation steps and the left translation parameter extraction steps to obtain the number of right translations, the right translation correlation coefficient and the absolute value of the right translation correlation coefficient, and then compare the absolute value of the left translation correlation coefficient with the absolute value of the right translation correlation coefficient. If the absolute value of the left translation correlation coefficient is greater than the absolute value of the right translation correlation coefficient, then the translation direction is left translation, the number of translations is the number of left translations, and the translation correlation coefficient is the left translation correlation coefficient; if the absolute value of the left translation correlation coefficient is less than or equal to the absolute value of the right translation correlation coefficient, then the translation direction is right translation, the number of translations is the number of right translations, and the translation correlation coefficient is the right translation correlation coefficient.
[0055] That is to say, according to the above calculation process, the left translation correlation coefficient, the absolute value of the left translation correlation coefficient, and the number of left translations can be calculated when the industry index Y is translated to the left relative to the financial index X. Similarly, due to symmetry, that is, the right translation of Y relative to X and the left translation of X relative to Y are symmetrical, the positions of X and Y can be exchanged, and the above steps can be re-executed to obtain the number of translations when the industry index Y is translated to the right relative to the financial index X, that is, the number of right translations RIGHT_MOVE_COUNT, the right translation correlation coefficient RIGHT_SCORE, and the absolute value of the right translation correlation coefficient RIGHT_SCORE_ABS.
[0056] Then, the parameters are compared and the translation parameters are judged: the absolute value of the left translation correlation coefficient LEFT_SCORE_ABS is compared with the absolute value of the right translation correlation coefficient RIGHT_SCORE_ABS. If LEFT_SCORE_ABS is greater than RIGHT_SCORE_ABS, the translation direction MOVE_DIRECTION is equal to the left translation LEFT; the number of translations MOVE_COUNT is equal to the number of left translations LEFT_MOVE_COUNT; the translation correlation coefficient MOVE_SCORE is equal to the left translation correlation coefficient LEFT_SCORE;
[0057] If LEFT_SCORE_ABS is less than or equal to RIGHT_SCORE_ABS, the translation direction MOVE_DIRECTION is equal to the right translation RIGHT; the number of translations MOVE_COUNT is equal to the right translation number RIGHT_MOVE_COUNT; the translation correlation coefficient MOVE_SCORE is equal to the right translation correlation coefficient RIGHT_SCORE;
[0058] 5. Index display steps: Use a dual-axis chart to display the translation direction, translation times and translation correlation coefficient, obtain the relative trend of the financial index and the industry index, and realize the comparative analysis of the correlation between the financial index and the industry index.
[0059] That is to say, by shifting the financial index X and the industry index Y to the left (or right, determined by the shift direction MOVE_DIRECTION) MOVE_COUNT times and displaying the data on a dual-axis chart, we can get the relative trends of the two indexes.
[0060] Example:
[0061] Assume that a set of time series data of financial index and industry index is obtained, as shown in Table 1.
[0062] Table 1:
[0063] date Financial Index Industry Index 2023-10-12 25 1000 2023-10-13 78 2000 2023-10-14 65 2600 2023-10-15 56 3500 2023-10-16 19 8800 2023-10-17 27 7500 2023-10-18 33 6600 2023-10-19 56 2900 2023-10-20 82 3700 2023-10-21 98 4300 2023-10-22 86 6600 2023-10-23 72 9200 2023-10-24 63 10800 2023-10-25 54 9600 2023-10-26 61 8200 2023-10-27 67 7300 2023-10-28 72 6000 2023-10-29 81 6900 2023-10-30 90 6300
[0064] They appear on the dual axis graph as follows Figure 8 As shown. Then calculate their translation correlation coefficient, translation direction and translation times. Select the maximum translation times MAX_MOVE_COUNT as 7 and the minimum comparison number MIN_ELEMENT_SIZE as 7. Then, when the industry index is translated to the left relative to the financial index, the correlation coefficient after each translation, the absolute value of the correlation coefficient and the number of translations to the left are shown in Table 2.
[0065] Table 2:
[0066] count LEFT_SCORE LEFT_SCORE_ABS LEFT_MOVE_COUNT 0 -0.08789960106709638 0.08789960106709638 0 1 0.20717553736612127 0.20717553736612127 1 2 0.6179246307005825 0.6179246307005825 2 3 0.9879492174514458 0.9879492174514458 3 4 0.9879492174514458 0.9879492174514458 3 5 0.9879492174514458 0.9879492174514458 3 6 0.9879492174514458 0.9879492174514458 3
[0067] Therefore, the left translation correlation coefficient LEFT_SCORE = 0.9879492174514458, the absolute value of the left translation correlation coefficient LEFT_SCORE_ABS = 0.9879492174514458, and the number of left translations LEFT_MOVE_COUNT = 3. When the industry index is translated to the right relative to the financial index, the right translation correlation coefficient, the absolute value of the right translation correlation coefficient, and the number of right translations are shown in Table 3.
[0068] Table 3:
[0069] count RIGHT_SCORE RIGHT_SCORE_ABS RIGHT_MOVE_COUNT 0 -0.08789960106709638 0.08789960106709638 0 1 -0.26344090475441856 0.26344090475441856 1 2 -0.26344090475441856 0.26344090475441856 1 3 0.4457605850264725 0.4457605850264725 3 4 0.7543397050772074 0.7543397050772074 4 5 0.797242542514972 0.797242542514972 5 6 0.797242542514972 0.797242542514972 5
[0070] Therefore, the rightward translation correlation coefficient RIGHT_SCORE=0.797242542514972, the absolute value of the rightward translation correlation coefficient RIGHT_SCORE_ABS=0.797242542514972, and the rightward translation count RIGHT_MOVE_COUNT=5. Comparing LEFT_SCORE_ABS and RIGHT_SCORE_ABS, it is found that the value of LEFT_SCORE_ABS is greater than the value of RIGHT_SCORE_ABS, as shown in Table 4.
[0071] Table 4
[0072] MOVE_DIRECTION MOVE_COUNT MOVE_SCORE LEFT 3 0.9879492174514458
[0073] It can be seen from Table 4 that the translation direction is to the left, which means that the industry index is translated to the left relative to the financial index, that is, the financial index is ahead of the industry index; the number of translations is 3, that is, the financial index is ahead of the industry index by 3 days; the correlation coefficient after translation is 0.9879492174514458, indicating that the industry index is strongly correlated with the financial index. Finally, these results are displayed using a dual-axis chart, as shown in Fig. 9 shown.
[0074] The present invention also relates to an index correlation comparison and analysis system, which corresponds to the above-mentioned index correlation comparison and analysis method, and can be understood as a system for implementing the above-mentioned method, including a sequential array acquisition and array length calculation module, an industry index relative to the financial index left translation correlation calculation module, a left translation parameter extraction module, a parameter comparison and translation parameter judgment module and an index display module. Specifically,
[0075] The array acquisition and array length calculation module collects time series data of financial index and industry index in a certain period of time, obtains financial index array and industry index array, and calculates the length of financial index array and the length of industry index array by using the length function in the scripting language;
[0076] The industry index is shifted to the left relative to the financial index. The workflow or calculation logic can be referred to in the correlation calculation module. Figure 2 As shown, the initial leftward translation correlation coefficient, the absolute value of the leftward translation correlation coefficient, the number of leftward translations and the current number of translations are set when the industry index is translated to the left relative to the financial index, and the current number of translations is compared with the preset maximum number of translations. If the current number of translations is less than the preset maximum number of translations, the starting subscript of the financial index subarray in the financial index array is calculated according to the length of the financial index array, the length of the industry index array and the current number of translations, and the ending subscript of the financial index subarray is calculated according to the length of the financial index array and the current number of translations; then, it is determined whether the value of the starting subscript is less than the preset numerical threshold value. If so, the starting subscript and the ending subscript are recalculated. If not, it is determined whether the difference between the ending subscript and the starting subscript is less than the preset minimum comparison data amount; if the difference is greater than or equal to the preset minimum comparison data amount, the ending subscript of the financial index subarray is calculated according to the length of the financial index array and the current number of translations. The start subscript and the end subscript of the group are used to extract the financial index subarray from the financial index array, and the industry index subarray is extracted from the industry index array according to the length of the industry index array and the length of the financial index subarray; then the average values of the financial index subarray and the industry index subarray are calculated respectively, and the correlation coefficient between the financial index subarray and the industry index subarray is calculated according to the value of each data in the financial index subarray and the value of each data in the corresponding industry index subarray, the average values of the financial index subarray and the industry index subarray and the Pearson correlation coefficient formula; then it is determined whether the absolute value of the correlation coefficient is greater than the absolute value of the initial leftward translation correlation coefficient. If so, the leftward translation correlation coefficient is updated to the correlation coefficient, the absolute value of the leftward translation correlation coefficient is updated to the absolute value of the correlation coefficient, and the number of leftward translations is updated to the current number of translations;
[0077] The left-shift parameter extraction module adds one to the current number of shifts and repeats the work of the left-shift correlation calculation module of the industry index relative to the financial index until the current number of shifts is greater than or equal to the preset maximum number of shifts, or the difference between the end subscript value and the start subscript value is less than the preset minimum amount of comparison data, and the loop is stopped to obtain the left-shift number, the left-shift correlation coefficient, and the absolute value of the left-shift correlation coefficient when the loop is stopped;
[0078] The parameter comparison and translation parameter judgment module calculates the right translation correlation of the industry index relative to the financial index according to the same principle as the left translation correlation calculation module and the left translation parameter extraction module, and obtains the number of right translations, the right translation correlation coefficient and the absolute value of the right translation correlation coefficient, and then compares the absolute value of the left translation correlation coefficient with the absolute value of the right translation correlation coefficient. If the absolute value of the left translation correlation coefficient is greater than the absolute value of the right translation correlation coefficient, the translation direction is left translation, the number of translations is the number of left translations, and the translation correlation coefficient is the left translation correlation coefficient; if the absolute value of the left translation correlation coefficient is less than or equal to the absolute value of the right translation correlation coefficient, the translation direction is right translation, the number of translations is the number of right translations, and the translation correlation coefficient is the right translation correlation coefficient;
[0079] The index display module uses a dual-axis graph to display the translation direction, translation times and translation correlation coefficient, obtains the relative trend of the financial index and the industry index, and realizes the comparative analysis of the correlation between the financial index and the industry index.
[0080] Preferably, in the index display module, the leading situation of the financial index and the industry index is judged according to the translation direction. If the translation direction is to the left, the financial index is judged to be ahead of the industry index. If the translation direction is to the right, the industry index is judged to be ahead of the financial index.
[0081] Preferably, in the index display module, the translational correlation coefficient is compared with a preset threshold. If the translational correlation coefficient is greater than the preset threshold, the industry index is strongly correlated with the financial index. If the translational correlation coefficient is less than or equal to the preset threshold, the industry index is weakly correlated with the financial index.
[0082] Preferably, in the leftward translation correlation calculation module of the industry index relative to the financial index, if the current number of translations is greater than or equal to the preset maximum number of translations, the number of leftward translations, the leftward translation correlation coefficient and the absolute value of the leftward translation correlation coefficient are directly output.
[0083] The present invention provides an objective and scientific index correlation comparative analysis method and system, which adopts specific judgment method and calculation method to calculate the correlation coefficient of the industry index relative to the financial index when it is translated to the left and right, as well as the number of times of translation to the left and right, and compares the correlation coefficient when translated to the left with the correlation coefficient when translated to the right to determine the translation correlation coefficient, the number of translations and the translation direction, and displays them through a dual-axis graph, so as to obtain the accurate leading / lagging days between the two indexes.
[0084] It should be noted that the above-described specific implementations can enable those skilled in the art to more fully understand the invention, but do not limit the invention in any way. Therefore, although this specification has described the invention in detail with reference to the drawings and embodiments, those skilled in the art should understand that the invention can still be modified or replaced by equivalents. In short, all technical solutions and improvements that do not deviate from the spirit and scope of the invention should be included in the protection scope of the patent for the invention.
Claims
1. A comparative analysis method of index correlation, It is characterized in that The following steps are involved: Array acquisition and array length calculation steps: collect the time series data of the financial index and the industry index within a certain period of time, obtain the financial index array and the industry index array, and use the length function in the script language to calculate the length of the financial index array and the length of the industry index array; The steps of calculating the correlation of the industry index shifting to the left relative to the financial index are as follows: the initial leftward shift correlation coefficient, the absolute value of the leftward shift correlation coefficient, the number of leftward shifts and the current number of shifts are set when the industry index shifts to the left relative to the financial index, and the current number of shifts is compared with the preset maximum number of shifts. If the current number of shifts is less than the preset maximum number of shifts, the starting subscript of the financial index subarray in the financial index array is calculated according to the length of the financial index array, the length of the industry index array and the current number of shifts, and the ending subscript of the financial index subarray is calculated according to the length of the financial index array and the current number of shifts; then, it is determined whether the value of the starting subscript is less than the preset numerical threshold value. If so, the starting subscript and the ending subscript are recalculated. If not, it is determined whether the difference between the ending subscript and the starting subscript is less than the preset minimum amount of comparison data. If the difference is greater than or equal to the preset minimum amount of comparison data, Then, the financial index subarray is cut out from the financial index array according to the start subscript and the end subscript of the financial index subarray, and the industry index subarray is cut out from the industry index array according to the length of the industry index array and the length of the financial index subarray; then, the average values of the financial index subarray and the industry index subarray are calculated respectively, and the correlation coefficient between the financial index subarray and the industry index subarray is calculated according to the value of each data in the financial index subarray and the value of each data in the corresponding industry index subarray, the average values of the financial index subarray and the industry index subarray and the Pearson correlation coefficient formula; then, it is determined whether the absolute value of the correlation coefficient is greater than the absolute value of the initial leftward translation correlation coefficient. If so, the leftward translation correlation coefficient is updated to the correlation coefficient, the absolute value of the leftward translation correlation coefficient is updated to the absolute value of the correlation coefficient, and the number of leftward translations is updated to the current number of translations; Left shift parameter extraction step: add one to the current number of shifts and repeat the step of calculating the correlation of the industry index to the financial index to the left, until the current number of shifts is greater than or equal to the preset maximum number of shifts, or the difference between the end subscript value and the start subscript value is less than the preset minimum amount of comparison data, then the loop is stopped, and the number of left shifts, the left shift correlation coefficient, and the absolute value of the left shift correlation coefficient when the loop is stopped are obtained; Parameter comparison and translation parameter judgment steps: Calculate the right translation correlation of the industry index relative to the financial index based on the same principles as the left translation correlation calculation steps and the left translation parameter extraction steps to obtain the number of right translations, the right translation correlation coefficient and the absolute value of the right translation correlation coefficient, and then compare the absolute value of the left translation correlation coefficient with the absolute value of the right translation correlation coefficient. If the absolute value of the left translation correlation coefficient is greater than the absolute value of the right translation correlation coefficient, the translation direction is left translation, the number of translations is the number of left translations, and the translation correlation coefficient is the left translation correlation coefficient; if the absolute value of the left translation correlation coefficient is less than or equal to the absolute value of the right translation correlation coefficient, the translation direction is right translation, the number of translations is the number of right translations, and the translation correlation coefficient is the right translation correlation coefficient; Index display steps: Use a dual-axis chart to display the translation direction, translation times and translation correlation coefficient, obtain the relative trend of the financial index and the industry index, and realize the comparative analysis of the correlation between the financial index and the industry index.
2. The index correlation comparative analysis method according to claim 1, It is characterized in that In the index display step, the leading situation of the financial index and the industry index is judged according to the translation direction. If the translation direction is to the left, it is judged that the financial index leads the industry index. If the translation direction is to the right, it is judged that the industry index leads the financial index.
3. The index correlation comparative analysis method according to claim 1, It is characterized in that In the index display step, the translational correlation coefficient is compared with a preset threshold. If the translational correlation coefficient is greater than the preset threshold, the industry index is strongly correlated with the financial index. If the translational correlation coefficient is less than or equal to the preset threshold, the industry index is weakly correlated with the financial index.
4. The index correlation comparative analysis method according to claim 1, It is characterized in that In the step of calculating the correlation of the leftward shift of the industry index relative to the financial index, if the current number of shifts is greater than or equal to the preset maximum number of shifts, the number of leftward shifts, the leftward shift correlation coefficient and the absolute value of the leftward shift correlation coefficient are directly output.
5. An index correlation comparative analysis system, It is characterized in that It includes an array acquisition and array length calculation module, an industry index relative to the financial index left translation correlation calculation module, a left translation parameter extraction module, a parameter comparison and translation parameter judgment module and an index display module. The array acquisition and array length calculation module collects time series data of financial index and industry index in a certain period of time, obtains financial index array and industry index array, and calculates the length of financial index array and the length of industry index array by using the length function in the scripting language; The module for calculating the correlation between the industry index and the financial index shifting to the left sets the initial left shift correlation coefficient, the absolute value of the left shift correlation coefficient, the number of left shifts and the current number of shifts when the industry index shifts to the left relative to the financial index, and compares the current number of shifts with the preset maximum number of shifts. If the current number of shifts is less than the preset maximum number of shifts, the starting subscript of the financial index subarray in the financial index array is calculated according to the length of the financial index array, the length of the industry index array and the current number of shifts, and the ending subscript of the financial index subarray is calculated according to the length of the financial index array and the current number of shifts; and the module for calculating the ending subscript of the financial index subarray is determined according to the length of the financial index array and the current number of shifts; and then determines whether the value of the starting subscript is less than the preset numerical threshold value. If so, the starting subscript and the ending subscript are recalculated. If not, it is determined whether the difference between the ending subscript and the starting subscript is less than the preset minimum amount of comparison data; if the difference is greater than or equal to the preset minimum amount of comparison data , then the financial index subarray is intercepted from the financial index array according to the start subscript and the end subscript of the financial index subarray, and the industry index subarray is intercepted from the industry index array according to the length of the industry index array and the length of the financial index subarray; then the average values of the financial index subarray and the industry index subarray are calculated respectively, and the correlation coefficient between the financial index subarray and the industry index subarray is calculated according to the value of each data in the financial index subarray and the value of each data in the corresponding industry index subarray, the average values of the financial index subarray and the industry index subarray and the Pearson correlation coefficient formula; then it is determined whether the absolute value of the correlation coefficient is greater than the absolute value of the initial leftward translation correlation coefficient. If so, the leftward translation correlation coefficient is updated to the correlation coefficient, the absolute value of the leftward translation correlation coefficient is updated to the absolute value of the correlation coefficient, and the number of leftward translations is updated to the current number of translations; The left-shift parameter extraction module adds one to the current number of shifts and repeats the work of the left-shift correlation calculation module of the industry index relative to the financial index until the current number of shifts is greater than or equal to the preset maximum number of shifts, or the difference between the end subscript value and the start subscript value is less than the preset minimum amount of comparison data, and the loop is stopped to obtain the left-shift number, the left-shift correlation coefficient, and the absolute value of the left-shift correlation coefficient when the loop is stopped; The parameter comparison and translation parameter judgment module calculates the right translation correlation of the industry index relative to the financial index according to the same principle as the left translation correlation calculation module and the left translation parameter extraction module, and obtains the number of right translations, the right translation correlation coefficient and the absolute value of the right translation correlation coefficient, and then compares the absolute value of the left translation correlation coefficient with the absolute value of the right translation correlation coefficient. If the absolute value of the left translation correlation coefficient is greater than the absolute value of the right translation correlation coefficient, the translation direction is left translation, the number of translations is the number of left translations, and the translation correlation coefficient is the left translation correlation coefficient; if the absolute value of the left translation correlation coefficient is less than or equal to the absolute value of the right translation correlation coefficient, the translation direction is right translation, the number of translations is the number of right translations, and the translation correlation coefficient is the right translation correlation coefficient; The index display module uses a dual-axis graph to display the translation direction, translation times and translation correlation coefficient, obtains the relative trend of the financial index and the industry index, and realizes the comparative analysis of the correlation between the financial index and the industry index.
6. The index correlation comparative analysis system according to claim 5, It is characterized in that In the index display module, the leading situation of the financial index and the industry index is judged according to the translation direction. If the translation direction is to the left, it is judged that the financial index leads the industry index. If the translation direction is to the right, it is judged that the industry index leads the financial index.
7. The index correlation comparative analysis system according to claim 5, It is characterized in that In the index display module, the translational correlation coefficient is compared with a preset threshold. If the translational correlation coefficient is greater than the preset threshold, the industry index is strongly correlated with the financial index. If the translational correlation coefficient is less than or equal to the preset threshold, the industry index is weakly correlated with the financial index.
8. The index correlation comparative analysis system according to claim 5, It is characterized in that In the leftward translation correlation calculation module of the industry index relative to the financial index, if the current number of translations is greater than or equal to the preset maximum number of translations, the number of leftward translations, the leftward translation correlation coefficient and the absolute value of the leftward translation correlation coefficient are directly output.
Citation Information
Patent Citations
Electric power economic index construction method and system based on electric power data
CN112598227A
Ship transport capacity index generation and similarity coefficient calculation method and system
CN114819635A
Electric power index evaluation method and system
CN115239201A
Correlation analysis method and device based on time sequence, equipment and medium
CN115358628A
Dynamic characteristic-considered prosperity index screening method
CN117933806A
