Advanced Clustering Technique For High-Frequency Low-Latency Analysis
After configuring the backtesting scenario, data is streamed to ExSan to identify clusters that will subsequently be utilized for constructing the covariance matrix. This process is fundamental to modern portfolio theory, particularly due to the asynchronous nature of market data. Only clusters with overlapping time periods (i.e., concurrent in time) are eligible for inclusion in the estimation of the covariance matrix.
The aim of this work is to establish Covariance and Correlation of Asynchronous Market Tick Data Using Cluster Computing. An algorithm is implemented to correlate asynchronous tick data from the market using cluster computing. Each asset generates a unique number of ticks distributed over a given time frame, with some assets being more active and others less so, reflecting varying levels of volatility and activity.
Challenges Addressed
Performing some kind of extreme test under strict timing.
	Total Number of assets allocated: 40     clusters: 20 per asset(stock)     time lapse: 3333 microseconds  
	OLD Version Cluster NOT DECLARED STATIC
 
    xsnPortfolio_0222  Elapsed Time: 161 sec
  
    xsnPortfolio_0627  Elapsed Time:  30 sec
 
	xsnPortfolio_0906  Elapsed Time: 748 sec
 
	xsnPortfolio_3115  Elapsed Time: 484 sec
	xsnPortfolio_4504  Elapsed Time: 403 sec
	
	
	New Version Cluster DECLARED STATIC !
	xsnPortfolio_2903   Elapsed Time:  1.40  sec
	xsnPortfolio_2927   Elapsed Time:  2.93  sec
	xsnPortfolio_2951   Elapsed Time:  4.42  sec
	xsnPortfolio_3020   Elapsed Time:  2.75  sec
	xsnPortfolio_3045   Elapsed Time:  2.79  sec
	xsnPortfolio_4022   Elapsed Time:  4.24  sec
	xsnPortfolio_4112   Elapsed Time: 12.01  sec
 
    xsnPortfolio_4304   Elapsed Time:  6.21  sec
	
	
Pseudo Code
tau <- Set time lag
  startChrono
  while  endChrono - startChrono < tau   
      feed Data Market to ExSan into current cluster
  
  endChrono
  
  
  
  
  
  
   
  
  
  
  
  
  
  
        
  
    ExSan Abstract Structure
Clusters
ExSan + Clusters
Remark: All clusters are implemented as Red-Black Trees to ensure consistency with the earlier description of ExSan. This implementation leverages a single C++ master template, designed and implemented only once, eliminating the need for additional coding. The master template manages all cluster-related functionality, ensuring uniformity, efficiency, and maintainability across the system, which is central to ExSan's architecture.
ExSan was conceived 35 years ago, when it first started as a coding project. The original version was written in C and was later rewritten in C++. From the very beginning, the project was based on Red-Black Trees.
This LinkedIn post highlights the significance of Red-Black Trees as a foundational component in a series of articles focused on Quantitative Finance. During ExSan’s conception and development, it was not evident that similar concepts utilizing Red-Black Trees were being explored by others. This underscores the independent and innovative thought process behind ExSan’s creation.
Output
  
     
1      |ExSan| C++  |ExSan|                    Sun Dec 15 08:51:29 2024
    
2     JOB:  xsnPortfolio_5129        
    
3     <--------e-x-s-a-n---------->--------e-x-s-a-n---------->
    
4      Generate Exsan ( 23 ,  24 )
    
5     Total Number of assets allocated:  22  Lapse Microseconds:  7  
    
6     |<--------e-x-s-a-n---hft------->|--------e-x-s-a-n---hft------->
    
7     :2291: Catching Clusters This round ExSan(stocks: 22, 2 :clusters)
    
8     :2292: Selected Stocks |aryStockAux| Weighted Vals in Clusters ppDataIn: 9
    
9     WORKSHEET 9  I[5, 2] FLOAT
    
10                               A     B 
    
11                               >--------------<
    
12      0           0.00  ATLU    2:272.95 278.50 
    
13      0           0.00  ARNA    4: 62.00  63.20 
    
14      0           0.00  ANRA    5: 11.50  11.50 
    
15                               <-------------->-------------->
    
16                                    1      2
    
17     :2321: CATCHING CLUSTERS Clocking - Time Lapse Range  
    
18     ATLU    1 [10.99  <-> 10.99]2 [11.30 <-> 12.03-> ]->
    
19     ARNA    1 [11.07 <-> 11.07]2 [11.42 <-> 11.42]->->
    
20     ANRA    1 [11.12 <-> 11.12 ]2 [12.00 <-> 12.00]->->
    
21  
    
22     *** The time range of Cluster j, defined as [min, max], falls within the overall time window *** 
  
   
  
    
23             [10.99 <-> 11.12-> ]   [11.30 <-> 12.03-> ]
    
24        
    
25     ENDS  xsnPortfolio_5129   Elapsed Time: 0.04  sec
    
26     Version BOOST: 1.83.0   EXSAN @ MS VSC 2022 (64b) - 17.11.5 -toolSet(v143)
    
27     EXIT FROM EXSAN 
    
28     
    
29     *************************************************************************   
    
30     |ExSan| C++  |ExSan|                                 Sun Dec 15 08:55:56 2024
    
31     JOB:  xsnPortfolio_5556
    
32     <--------e-x-s-a-n---------->--------e-x-s-a-n---------->
    
33      Generate Exsan ( 23 ,  24 )
    
34     Total Number of assets allocated:  22  Lapse Microseconds:  10  
    
35     |<--------e-x-s-a-n---hft------->|   --------e-x-s-a-n---hft------->
    
36     :2291: Catching Clusters This round ExSan(stocks: 22, 3 :clusters)
    
37     :2292: Selected Stocks |aryStockAux| Weighted Vals in Clusters ppDataIn: 9
    
38     WORKSHEET 9  I[14, 3] FLOAT
    
39                               A      B      C 
    
40                               >---------------------<
    
41      0           0.00  ATHN    5: 27.76  31.13  31.37 
    
42      0           0.00  AKSH    6: 97.88 103.79 106.30 
    
43      0           0.00  ARNA    7: 74.60  73.40  71.70 
    
44      0           0.00  ANRA    8: 13.40  11.50  11.90 
    
45      0           0.00  ADVN   10:139.33 144.56 151.75 
    
46      0           0.00  ARAC   12: 12.93  12.47  12.84 
    
47      0           0.00   ALV   13: 58.05  55.07  55.22 
    
48      0           0.00  ANUL   14: 10.90  10.88  10.78 
    
49                               <--------------------->--------------------->
    
50                                         1     2     3
    
51  
    
52     :2321: CATCHING CLUSTERS Clocking - Time Lapse Range  
    
53     ATHN    1 [
  10.43 
   <-> 10.55]2 [
  11.31 
   <-> 
  12.23 
  ]3 [12.81 <-> 12.81]->->->
    
54     AKSH    1 [10.51 <-> 10.51]2 [11.56 <-> 12.04]3 [13.13 <-> 13.13]->->->
    
55     ARNA    1 [10.59 <-> 11.16]2 [11.89 <-> 11.89]3 [12.50 <-> 12.92]->->->
    
56     ANRA    1 [10.72 <-> 
  11.23   
  ]2 [11.68 <-> 11.68]3 [12.74 <-> 12.96]->->->
    
57     ADVN    1 [10.84 <-> 10.84]2 [11.75 <-> 11.75]3 [
  12.43 
   <-> 12.84]->->->
    
58     ARAC    1 [10.96 <-> 10.96]2 [12.08 <-> 12.08]3 [12.47 <-> 13.10]->->->
    
59     ALV     1 [11.02 <-> 11.19]2 [12.01 <-> 12.01]3 [12.67 <-> 
  13.16 
  ]->->->
    
60     ANUL    1 [11.07 <-> 11.13]2 [11.79 <-> 11.98]3 [12.56 <-> 13.03]->->->
    
61  
    
62     *** The time range of Cluster j, defined as [min, max], falls within the overall time window *** 
    
63             
  
  [10.43 <-> 11.23]->   
  [11.31 <-> 12.23]->     
  [12.43 <-> 13.16]-> 
    
64     
    
65     ENDS  xsnPortfolio_5556   Elapsed Time: 0.04  sec
    
66     Version BOOST: 1.83.0   EXSAN @ MS VSC 2022 (64b) - 17.11.5 -toolSet(v143)
    
67     EXIT FROM EXSAN 
  
    
    
     
1      |ExSan| C++  |ExSan|                    Sun Dec 15 08:51:29 2024
    
2     JOB:  xsnPortfolio_5129        
    
3     <--------e-x-s-a-n---------->--------e-x-s-a-n---------->
    
4      Generate Exsan ( 23 ,  24 )
    
5     Total Number of assets allocated:  22  Lapse Microseconds:  7  
    
6     |<--------e-x-s-a-n---hft------->|--------e-x-s-a-n---hft------->
    
7     :2291: Catching Clusters This round ExSan(stocks: 22, 2 :clusters)
    
8     :2292: Selected Stocks |aryStockAux| Weighted Vals in Clusters ppDataIn: 9
    
9     WORKSHEET 9  I[5, 2] FLOAT
    
10                               A     B 
    
11                               >--------------<
    
12      0           0.00  ATLU    2:272.95 278.50 
    
13      0           0.00  ARNA    4: 62.00  63.20 
    
14      0           0.00  ANRA    5: 11.50  11.50 
    
15                               <-------------->-------------->
    
16                                    1      2
    
17     :2321: CATCHING CLUSTERS Clocking - Time Lapse Range  
    
18     ATLU    1 [10.99 <-> 10.99]2 [11.30 <-> 12.03]->->
    
19     ARNA    1 [11.07 <-> 11.07]2 [11.42 <-> 11.42]->->
    
20     ANRA    1 [11.12 <-> 11.12]2 [12.00 <-> 12.00]->->
    
21  
    
22     *** The time range of Cluster j, defined as [min, max], falls within the overall time window ***    
    
23             [10.99 <-> 11.12]   [11.30 <-> 12.03]->->
    
24        
    
25     ENDS  xsnPortfolio_5129   Elapsed Time: 0.04  sec
    
26     Version BOOST: 1.83.0   EXSAN @ MS VSC 2022 (64b) - 17.11.5 -toolSet(v143)
    
27     EXIT FROM EXSAN 
    
28     
    
29     
    
30     *************************************************************************   
    
31     |ExSan| C++  |ExSan|                                 Sun Dec 15 08:55:56 2024
    
32     JOB:  xsnPortfolio_5556
    
33     <--------e-x-s-a-n---------->--------e-x-s-a-n---------->
    
34      Generate Exsan ( 23 ,  24 )
    
35     Total Number of assets allocated:  22  Lapse Microseconds:  10  
    
36     |<--------e-x-s-a-n---hft------->|   --------e-x-s-a-n---hft------->
    
37     :2291: Catching Clusters This round ExSan(stocks: 22, 3 :clusters)
    
38     :2321: CATCHING CLUSTERS Clocking - Time Lapse Range  
    
39     ATHN    1 [10.43 <-> 10.55]2 [11.31 <-> 12.23]3 [12.81 <-> 12.81]->->->
    
40     AKSH    1 [10.51 <-> 10.51]2 [11.56 <-> 12.04]3 [13.13 <-> 13.13]->->->
    
41     ARNA    1 [10.59 <-> 11.16]2 [11.89 <-> 11.89]3 [12.50 <-> 12.92]->->->
    
42     ANRA    1 [10.72 <-> 11.23]2 [11.68 <-> 11.68]3 [12.74 <-> 12.96]->->->
    
43     ADVN    1 [10.84 <-> 10.84]2 [11.75 <-> 11.75]3 [12.43 <-> 12.84]->->->
    
44     ARAC    1 [10.96 <-> 10.96]2 [12.08 <-> 12.08]3 [12.47 <-> 13.10]->->->
    
45     ALV     1 [11.02 <-> 11.19]2 [12.01 <-> 12.01]3 [12.67 <-> 13.16]->->->
    
46     ANUL    1 [11.07 <-> 11.13]2 [11.79 <-> 11.98]3 [12.56 <-> 13.03]->->->
    
47  
    
48     *** The time range of Cluster j, defined as [min, max], falls within the overall time window ***    
    
49             [10.43 <-> 11.23]  [11.31 <-> 12.23]  [12.43 <-> 13.16]->->->
    
50     
    
51     ENDS  xsnPortfolio_5556   Elapsed Time: 0.04  sec
    
52     EXIT FROM EXSAN 
    
53     
    
54     
    
55     *************************************************************************
    
56     |ExSan| C++  |ExSan|                                 Sun Dec 15 08:55:56 2024
    
57     JOB:  xsnPortfolio_5556
    
58     :2321: CATCHING CLUSTERS Clocking - Time Lapse Range  
    
59     ANUL    1[ 9.74 <-> 10.04] 2[10.43 <-> 11.01] 3[11.66 <-> 11.96] 4[12.96 <-> 13.19] 5[13.88 <-> 13.88]->->->->->
    
60     ASCMA   1[ 9.89 <-> 9.89]  2[11.25 <-> 11.25] 3[11.80 <-> 11.80] 4[13.16 <-> 13.16] 5[13.39 <-> 13.72]->->->->->
    
61     ADVN    1[ 9.96 <-> 9.96]  2[10.46 <-> 10.99] 3[11.47 <-> 12.23] 4[12.63 <-> 12.63] 5[13.50 <-> 13.93]->->->->->
    
62     AMRN    1[10.13 <-> 10.19] 2[11.05 <-> 11.05] 3[12.13 <-> 12.13] 4[12.86 <-> 12.90] 5[14.19 <-> 14.19]->->->->->
    
63  
    
64     *** The time range of Cluster j, defined as [min, max], falls within the overall time window ***    
    
65             [9.74  <-> 10.19]  [10.43 <-> 11.25]  [11.47 <-> 12.23]  [12.63 <-> 13.19]  [13.39 <-> 14.19]->->->->->
    
66     ENDS  xsnPortfolio_4449   Elapsed Time: 0.04  sec
    
67     
    
68     
    
69     ----MORE RESULTS---       
    
70     *************************************************************************   
    
71     :2321: CLUSTERS CATCHING Clocking - Time Lapse Range  
    
74  
    
75     *** The time range of Cluster j, defined as [min, max], falls within the overall time window ***    
    
77     
    
78     EXIT FROM EXSAN 
    
79     *************************************************************************   
    
80     :2321: CLUSTERS CATCHING Clocking - Time Lapse Range  
    
81     ASCMA 4[215.40 <-> 215.40] 5[216.37 <-> 216.37] 1[217.81 <-> 217.81] 2[218.35 <-> 218.95] 3[219.88 <-> 219.88]->->->->->
    
82     CAR   2[215.83 <-> 216.02] 3[216.70 <-> 216.70] 4[217.33 <-> 217.41] 5[218.50 <-> 218.62] 1[220.01 <-> 220.01]->->->->->
    
83     ADVN  3[215.24 <-> 215.24] 4[216.95 <-> 216.95] 5[217.38 <-> 217.38] 1[218.87 <-> 218.87] 2[219.96 <-> 219.96]->->->->->
    
84     BMY   1[215.28 <-> 215.28] 2[216.42 <-> 216.58] 3[217.78 <-> 217.78] 4[218.43 <-> 218.69] 5[219.39 <-> 219.39]->->->->->
    
85  
    
86     *** The time range of Cluster j, defined as [min, max], falls within the overall time window ***    
    
87             [215.24 <-> 216.02]  [216.37 <-> 216.95]  [217.33 <-> 217.81]  [218.35 <-> 218.95]  [219.39 <-> 220.01]->->->->->
    
88     EXIT FROM EXSAN 
    
89     *************************************************************************
    
90     :2321: CLUSTERS CATCHING Clocking - Time Lapse Range  
    
91     CAR  5[21671.61 <-> 21671.61] 1[21672.59 <-> 21672.59] 2[21673.81 <-> 21673.81] 3[21674.74 <-> 21674.74] 4[21676.42...]->->->->
    
92     BF   2[21671.70 <-> 21671.70] 3[21673.39 <-> 21673.39] 4[21674.21 <-> 21674.21] 5[21675.02 <-> 21675.02] 1[21675.65...]->->->->
    
93     AKS  4[21671.77 <-> 21671.97] 5[21672.56 <-> 21672.89] 1[21673.65 <-> 21673.65] 2[21675.35<->21675.35] 3[21676.05<->...]->->->->->
    
94     ARNA 1[21672.09 <-> 21672.09] 2[21672.70 <-> 21673.10] 3[21674.29 <-> 21674.29] 4[21674.94 <-> 21674.94] 5[21675.86<...]->->->->
    
95     AAL  5[21672.18 <-> 21672.18] 1[21672.77 <-> 21672.77] 2[21674.25 <-> 21674.25] 3[21674.55 <-> 21675.32] 4[21676.29<...]->->->->
    
96     BLGS 5[21672.28 <-> 21672.32] 1[21673.18 <-> 21673.18] 2[21673.78 <-> 21673.78] 3[21674.63 <-> 21674.63] 4[21676.13<...]->->->->
    
97     C    3[21671.66 <-> 21671.66] 4[21673.01 <-> 21673.01] 5[21674.33 <-> 21674.33] 1[21674.90 <-> 21675.27] 2[21675.82<...]->->->->
    
98  
    
99     *** The time range of Cluster j, defined as [min, max], falls within the overall time window ***    
    
100        [21671.61 <-> 21672.32]  [21672.56 <-> 21673.39]  [21673.65 <-> 21674.33]  [21674.55 <-> 21675.35]  [21675.65...->->->->
  
   
101      NO OVERLAPPING TIME FRAMES, ALL CLUSTER FIT PROPERLY
  
   
101     EXIT FROM EXSAN 
   
102     ***************************  E  N   D  *****************************************
   
103     
      
    
Traversing data for each cluster
   
     
1  
    
2     |ExSan| C++  |ExSan|                                 Mon Dec 16 07:27:53 2024
    
3  
    
4     JOB:  xsnPortfolio_2753
    
5     <--------e-x-s-a-n---------->--------e-x-s-a-n---------->
    
6      Generate Exsan ( 7 ,  8 )
    
7     CLUSTERING ENABLE
    
8     microSecTimeLapse:   1000  Lapse Microseconds:  1000   minTics:  77777  maxTics:  77777   
    
9     |<--------e-x-s-a-n---hft------->|--------e-x-s-a-n---hft------->
    
10  
    
11      I[6, 3] *Matrix of Weighted Clusters*
    
12                                     A      B      C 
    
13                               >---------------------<
    
14      0           0.00  TFSM    2: 71.77  69.80  71.21 
    
15      0           0.00  MSFT    3: 24.40  23.09  23.47 
    
16      0           0.00  AAPL    4: 22.30  21.45  21.18 
    
17      0           0.00  XLFN    6:158.75 146.25 158.02 
    
18                               <--------------------->--------------------->
    
19                                      1     2     3
    
20  
    
21     :2321: CLUSTERS CATCHING Clocking - Time Lapse Range  
    
22     TFSM 1[9.95 <-> 10.65] 2[10.98 <-> 11.74] 3[11.90 <-> 13.56]->->->
    
23     (2  ,1  ):
    
24     pp: 9  71.77   -> 
    
25        1   2024-Dec-16 07:27:53.294270   pnt: 0  71.77  
    
26        2   2024-Dec-16 07:27:53.294270   pnt: 0  71.15  
    
27        4   2024-Dec-16 07:27:53.294270   pnt: 0  69.99  
    
28        6   2024-Dec-16 07:27:53.294270   pnt: 0  69.98  
    
29        8   2024-Dec-16 07:27:53.294270   pnt: 0  69.46  
    
30  
    
31     (2  ,2  ):
    
32     pp: 9  69.80   -> 
    
33        1   2024-Dec-16 07:27:53.295271   pnt: 0  68.57  
    
34        3   2024-Dec-16 07:27:53.295271   pnt: 0  69.08  
    
35        5   2024-Dec-16 07:27:53.295271   pnt: 0  68.17  
    
36        7   2024-Dec-16 07:27:53.295271   pnt: 0  68.93  
    
37        9   2024-Dec-16 07:27:53.295271   pnt: 0  68.49  
    
38        11   2024-Dec-16 07:27:53.295271   pnt: 0  69.80  
    
39  
    
40     (2  ,3  ):
    
41     pp: 9  71.21   -> 
    
42        1   2024-Dec-16 07:27:53.296276   pnt: 0  69.21  
    
43        3   2024-Dec-16 07:27:53.296276   pnt: 0  70.53  
    
44        5   2024-Dec-16 07:27:53.296276   pnt: 0  71.21  
    
45        7   2024-Dec-16 07:27:53.296276   pnt: 0  70.26  
    
46        9   2024-Dec-16 07:27:53.296276   pnt: 0  70.27  
    
47        11   2024-Dec-16 07:27:53.297269   pnt: 0  69.91  
    
48        13   2024-Dec-16 07:27:53.297269   pnt: 0  70.87  
    
49        15   2024-Dec-16 07:27:53.297269   pnt: 0  70.00  
    
50        17   2024-Dec-16 07:27:53.297269   pnt: 0  69.90  
    
51  
    
52     MSFT 1[10.00 <-> 10.28] 2[11.38 <-> 11.78] 3[11.99 <-> 13.74]->->->
    
53     (3  ,1  ):
    
54     pp: 9  24.40   -> 
    
55        1   2024-Dec-16 07:27:53.294270   pnt: 0  24.40  
    
56        2   2024-Dec-16 07:27:53.294270   pnt: 0  24.10  
    
57        4   2024-Dec-16 07:27:53.294270   pnt: 0  24.02  
    
58        6   2024-Dec-16 07:27:53.294270   pnt: 0  23.45  
    
59        8   2024-Dec-16 07:27:53.294270   pnt: 0  22.99  
    
60  
    
61     (3  ,2  ):
    
62     pp: 9  23.09   -> 
    
63        1   2024-Dec-16 07:27:53.295271   pnt: 0  23.00  
    
64        3   2024-Dec-16 07:27:53.295271   pnt: 0  22.68  
    
65        5   2024-Dec-16 07:27:53.295271   pnt: 0  22.92  
    
66        7   2024-Dec-16 07:27:53.295271   pnt: 0  23.09  
    
67        9   2024-Dec-16 07:27:53.295271   pnt: 0  22.66  
    
68  
    
69     (3  ,3  ):
    
70     pp: 9  23.47   -> 
    
71        1   2024-Dec-16 07:27:53.296276   pnt: 0  23.11  
    
72        3   2024-Dec-16 07:27:53.296276   pnt: 0  23.12  
    
73        5   2024-Dec-16 07:27:53.297269   pnt: 0  23.47  
    
74        7   2024-Dec-16 07:27:53.297269   pnt: 0  22.92  
    
75        9   2024-Dec-16 07:27:53.297269   pnt: 0  22.46  
    
76        11   2024-Dec-16 07:27:53.297269   pnt: 0  22.40  
    
77        13   2024-Dec-16 07:27:53.297269   pnt: 0  22.19  
    
78        15   2024-Dec-16 07:27:53.297269   pnt: 0  22.06  
    
79  
    
80     AAPL 1[10.04 <-> 10.80] 2[11.17 <-> 11.26] 3[11.87 <-> 13.60]->->->
    
81     (4  ,1  ):
    
82     pp: 9  22.30   -> 
    
83        1   2024-Dec-16 07:27:53.294270   pnt: 0  22.30  
    
84        2   2024-Dec-16 07:27:53.294270   pnt: 0  22.17  
    
85        4   2024-Dec-16 07:27:53.294270   pnt: 0  21.31  
    
86        6   2024-Dec-16 07:27:53.294270   pnt: 0  21.46  
    
87        8   2024-Dec-16 07:27:53.295271   pnt: 0  20.90  
    
88  
    
89     (4  ,2  ):
    
90     pp: 9  21.45   -> 
    
91        1   2024-Dec-16 07:27:53.295271   pnt: 0  21.45  
    
92        3   2024-Dec-16 07:27:53.295271   pnt: 0  20.52  
    
93  
    
94     (4  ,3  ):
    
95     pp: 9  21.18   -> 
    
96        1   2024-Dec-16 07:27:53.296276   pnt: 0  20.92  
    
97        3   2024-Dec-16 07:27:53.296276   pnt: 0  19.92  
    
98        5   2024-Dec-16 07:27:53.296276   pnt: 0  20.27  
    
99        7   2024-Dec-16 07:27:53.296276   pnt: 0  20.63  
    
100        9   2024-Dec-16 07:27:53.297269   pnt: 0  20.51  
   
101        11   2024-Dec-16 07:27:53.297269   pnt: 0  20.21  
   
102        13   2024-Dec-16 07:27:53.297269   pnt: 0  19.77  
   
103        15   2024-Dec-16 07:27:53.297269   pnt: 0  20.73  
   
104        17   2024-Dec-16 07:27:53.297269   pnt: 0  21.18  
   
105        19   2024-Dec-16 07:27:53.297269   pnt: 0  21.10  
   
106  
   
107     XLFN 1[10.33 <-> 10.71] 2[11.36 <-> 11.36] 3[12.05 <-> 13.78]->->->
   
108     (6  ,1  ):
   
109     pp: 9  158.75  -> 
   
110        1   2024-Dec-16 07:27:53.294270   pnt: 0  158.75 
   
111        2   2024-Dec-16 07:27:53.294270   pnt: 0  154.33 
   
112        4   2024-Dec-16 07:27:53.294270   pnt: 0  152.67 
   
113        6   2024-Dec-16 07:27:53.294270   pnt: 0  150.18 
   
114  
   
115     (6  ,2  ):
   
116     pp: 9  146.25  -> 
   
117        1   2024-Dec-16 07:27:53.295271   pnt: 0  146.25 
   
118  
   
119     (6  ,3  ):
   
120     pp: 9  158.02  -> 
   
121        1   2024-Dec-16 07:27:53.296276   pnt: 0  147.61 
   
122        3   2024-Dec-16 07:27:53.296276   pnt: 0  146.17 
   
123        5   2024-Dec-16 07:27:53.296276   pnt: 0  149.41 
   
124        7   2024-Dec-16 07:27:53.296276   pnt: 0  150.09 
   
125        9   2024-Dec-16 07:27:53.296276   pnt: 0  153.41 
   
126        11   2024-Dec-16 07:27:53.297269   pnt: 0  151.03 
   
127        13   2024-Dec-16 07:27:53.297269   pnt: 0  157.50 
   
128        15   2024-Dec-16 07:27:53.297269   pnt: 0  158.02 
   
129        17   2024-Dec-16 07:27:53.297269   pnt: 0  154.89 
   
130        19   2024-Dec-16 07:27:53.297269   pnt: 0  155.03 
   
131        21   2024-Dec-16 07:27:53.298268   pnt: 0  152.05 
   
132  
   
133  
   
134     *** The time range of Cluster j, defined as [min, max], falls within the overall time window ***    
   
135             [9.95  <-> 10.80]  [10.98 <-> 11.78]  [11.87 <-> 13.78]->->->
   
136        
   
137     ENDS  xsnPortfolio_2753   Elapsed Time: 0.05  sec   
   
138     EXIT FROM EXSAN 
Some Pseudo Code of ExSan Cluster
IF loadNtimeLapse == 1 THEN
    // Use auxiliary tree to process data
    Initialize ndptrAry[0] and ndptrAry[1] with ptrAry[0]'s ntHead
    Find minimum value in the tree and assign to ndptrAry[0]
    Find maximum value in the tree and assign to ndptrAry[1]
    Calculate spreadCenter as the average of minimum and maximum data
    IF ntCounter is odd THEN
        Calculate kth as middle index of the tree
        Find kth node using InOrderFindKth_nt
        Set data and time from the kth node's data
    ELSE
        Calculate kth for left and right midpoints
        Find nodes for left and right midpoints using InOrderFindKth_nt
        Set data and time as the average of left and right midpoint nodes
    ENDIF
    Discard the auxiliary tree to free resources
    Validate tree cleanup and output results if required
ELSE
    // Handle new version without deleting nodes
    Initialize ndptrAry[0] and ndptrAry[1] to null
    Find minimum and maximum keys using rangeKeyFindMinMax_nt
    Calculate spreadCenter as the average of minimum and maximum data
    IF key_index is odd THEN
        Find the middle node using rangeKeyFind_nt
        Set data and time from the middle node's data
    ELSE
        Find left and right midpoint nodes using rangeKeyFindPair_nt
        Set data and time as the average of the two midpoint nodes
    ENDIF
ENDIF
    
Some ExSan Cluster Code
   
     
1  
    
2  
    
3  /*Some ExSan Code Clocking Clusters*/
    
4  fout << "\n\t:2321: CATCHING CLUSTERS Clocking - Time Lapse Range  ";
    
5  stockPtr = net->goto_row(net, ppDataIn, firstRow, 'f'); 
    
6  for (i = firstRow; i <= lastRow; ++i) {
    
7     if (!aryStockAux[i]) { stockPtr = stockPtr->get_down_ptr();  continue; }   
    
8     ptr = stockPtr->get_forward_ptr();
    
9     
    
10     cout << "\n\t" << setw(5) << left  << stockPtr->get_stock_name()  << "\t";
    
11  
    
12     for (j = 1; j <= net->get_cols_in_page(ppDataIn, 'f'); j++) { /             
    
13        if (loadNtimeLapse == 1) {          
    
14           ndptrAry[0] = ndptrAry[1] = nullptr;         
    
15           ptrAry[0]->get_ntHead()->rangeKeyFindMinMax_nt(  ... /* some parameters*/... ); 
    
16           cout  << setw(2) << ptrAry[0]->get_col() << "[" <<  ...
    
17  
    
18           if (ndptrAry[0]->get_nt_data(ppnt_time) < ptrAry[0]->get_data(ppTime))  
    
19              ptrAry[0]->set_data(ppTime,  ndptrAry[0]->get_nt_data(ppnt_time));
    
20           if (ndptrAry[1]->get_nt_data(ppnt_time) > ptrAry[0]->get_data(ppRTime)) 
    
21              ptrAry[0]->set_data(ppRTime, ndptrAry[1]->get_nt_data(ppnt_time));
    
22        }
    
23        else {/                
    
24           ndptrAry[0] = ndptrAry[1] = nullptr;
    
27                 << " <-> " << setw(7) << ndptrAry[1]->get_nt_data(ppnt_time) << "]"->
    
28        }      
    
29        ptrAry[0] = ptrAry[0]->get_next_ptr();
    
30        if (ptrAry[0]->get_col() > net->get_cols_in_page(ppDataIn, 'f')) ptrAry[0] =  ....;
    
31     }   
    
32  }                     
    
33  
    
34  ptr   = net->net_point_to(net, net->get_net_rows(), 1);                         
    
35  
    
36  for (j = 1; j <= net->get_cols_in_page(ppDataIn, 'f'); j++) { /                    
    
37     ptr->set_data(ppTime, ptrAry[0]->get_data(ppTime));
    
38     ptr->set_data(ppRTime, ptrAry[0]->get_data(ppRTime));   
    
39     ptrAry[0] = ptrAry[0]->get_next_ptr();
    
40     if (ptrAry[0]->get_col() > net->get_cols_in_page(ppDataIn, 'f')) 
    
41        ptrAry[0] = stockPtr->get_forward_ptr();
    
42     ptr = ptr->get_next_ptr();
    
43  }
    
44  cout << endl;
    
45                       
    
46  stockPtr = net->goto_row(net, ppTime, firstRow, 'f');  /                        
    
48     if (!aryStockAux[i]) { 
    
49        stockPtr = stockPtr->get_down_ptr();  
    
50        continue; 
    
51     }
    
52  
    
53     ptrAry[0] = stockPtr->get_ptrLasTick();  /                                
    
54     ptr = net->net_point_to(net, net->get_net_rows(), 1);
    
55     for (j = 1; j <= net->get_cols_in_page(ppTime, 'f'); j++) { /              
    
56        
    
57        if(ptrAry[0]->get_data(ppTime)  < ptr->get_data(ppTime))  { 
    
58           ptr->set_data(ppTime,  ptrAry[0]->get_data(ppTime)); 
    
59        }
    
60        if(ptrAry[0]->get_data(ppRTime) > ptr->get_data(ppRTime)) { 
    
61           ptr->set_data(ppRTime, ptrAry[0]->get_data(ppRTime)); 
    
62        }                              
    
63        
    
64        ptrAry[0] = ptrAry[0]->get_next_ptr();
    
65        if (ptrAry[0]->get_col() > net->get_cols_in_page(ppDataIn, 'f')) 
    
66           ptrAry[0] = stockPtr->get_forward_ptr();
    
67        ptr = ptr->get_next_ptr();
    
68     }   
    
69     stockPtr = stockPtr->get_down_ptr();
    
70  }
    
71  
    
73  for (j = 1; j <= net->get_cols_in_page(ppTime, 'f'); ++j) { /                   
    
75     ptr = ptr->get_next_ptr();
    
76  }
    
77  cout endl;
    
  
Some Outputs
ExSan's Quant Finance Backtesting Suite: Performance & Outcomes
Comments
Post a Comment