Algorithm

Ref: E x S a n
This algorithm is being used in this Code LINE 3231

Algorithm

Matrix correlation is an important concept in portfolio theory because it allows investors to measure the degree to which the returns of different assets are related to each other. In other words, it helps investors understand how different assets move in relation to each other and how they might behave together in different market conditions.

By calculating the correlation between the returns of different assets, investors can construct portfolios that are more diversified and potentially less risky. This is because assets that are highly correlated with each other tend to move in the same direction, which means that if one asset performs poorly, others in the portfolio are likely to perform poorly as well. On the other hand, assets that are negatively correlated or uncorrelated with each other can provide more diversification benefits, as they are less likely to move in the same direction at the same time.

Furthermore, the matrix correlation allows investors to construct efficient portfolios that aim to maximize returns for a given level of risk. This is because the correlation between assets affects the risk and return of a portfolio. A portfolio with assets that have low correlation can have a higher return for a given level of risk, as compared to a portfolio with highly correlated assets.

In summary, matrix correlation is an important tool in portfolio theory because it helps investors understand the relationships between different assets and construct portfolios that are more diversified and efficient.

ExSan is a software application that utilizes the Binary Tree Abstract Data Structure in its lower layer. The application has implemented an algorithm consisting of two recursive traversal tree functions that perform row and column traversals, respectively, which make mutual calls to each other. Developing this algorithm was a challenging and time-consuming endeavor.

One of the topics in portfolio theory is the correlation matrix. The ExSan simulator of the Markowitz portfolio theory has been coded using the algorithm described previously.

If any element of the correlation matrix does not satisfy the imposed restrictions, such as leverage or hedging, it must be set to zero (Corr(i,j) = 0). This adjustment forces the correlation matrix to create a debugged matrix where all entries meet the requirements.

Setting an element (i, j) to zero in the correlation matrix forces all corresponding elements in row i and column j to also be set to zero. This set of new elements (Corr_new(i, j) = 0) undergoes a recursive process to ensure that all corresponding rows and columns are also zero. This process could be time-consuming, especially for portfolios with a large number of entries. However, the algorithm described previously does it quite efficiently.

To handle this problem efficiently in a huge sparse correlation matrix, ExSan uses two recursive traversal tree functions.

    2 

Markowitz Portfolio Simulation - Low Latency Trading

    3 If an element of a huge sparse Correlation Matrix does not comply with a particular requirement and needs to be set

    4 to zero Corr(i, j) = 0, all corresponding elements of the row i and col j are forced to be set to zero; this new set 

    5 of elements Corr_new(i, j) = 0 is forced to a recursive process

    6 

    7 ExSan is built upon Binary Tree Abstract Data Structure in its lower layer. Two recursive Traversal Tree functions 

    8 are implemented to handle the above stated  problem in a huge sparse correlation  matrix.

    9 ///---BEGIN Code

   10 /******pseudoCode **********************/

   11 main() {

   12    // some code

   13    variable parameter, main_parameters;

   14    Tree - Walk_rows(X, main_parameters);

   15    // some code

   16 }

   17 

   18 //recursiveRowCol

   19 Tree - Walk_rows(X_row, parameter_x_row) {

   20    Tree - Walk_rows(X_row_left, parameter_row)

   21    // some code

   22    Tree - Walk_cols(X_row_to_col, parameter_row_to_col)

   23    // some code

   24    Tree - Walk_rows(X_row_right, parameter_row)

   25 }

   26 

   27 //recursiveRowColSlave

   28 Tree - Walk_cols(X_col, parameter_x_col) {

   29    Tree - Walk_cols(X_col_left, paramenter_col)

   30    //some code

   31    Tree - Walk_rows(X_col_to_row, parameter_col_to_row) 

   32    //some code

   33    Tree - Walk_cols(X_col_right, parameter_col)

   34 }

   35 /**************************/

   36 

   37 The actual C++ code

   38 /***********START ***************/

   39 void Net::recursiveRowCol(NETPTR net,

   40    CELLPTR head,

   41    unsigned short ppCorr,

   42    bool* ary,

   43    unsigned short indexRow) {

   44 

   45    if (head) {

   46       net->recursiveRowCol(net, head->get_db_left_ptr(), ppCorr, ary, indexRow);

   47       //...............

   48       if (head->get_row() == indexRow && head->get_bool(pp_bscorr)) {

   49          ary[head->get_row()] = 0;

   50          head->set_bool(pp_bscorr, 0);

   51          if (ary[head->get_col()])

   52             net->recursiveRowColSlave(net, head, ppCorr, ary, head->get_row(), head->get_col());

   53       }

   54       //...............

   55       net->recursiveRowCol(net, head->get_right_ptr(), ppCorr, ary, indexRow);

   56    }

   57 }

   58 /********************* recursiveRowCol ****************************/

   59 

   60 /***********START InOrderInCol***************/

   61 void Net::recursiveRowColSlave(NETPTR net,

   62    CELLPTR head,

   63    unsigned short ppCorr,

   64    bool* ary,

   65    unsigned short indexRow,

   66    unsigned short indexCol) {

   67 

   68    if (head) {

   69       net->recursiveRowColSlave(net, head->get_left_ptr(),

   70          ppCorr, ary, indexRow, indexCol);

   71 

   72       //.... some code

   73       if (head->get_col() == indexCol) {

   74          ary[head->get_col()] = 0;

   75 

   76          if (head->get_bool(pp_bscorr)) {

   77             if (ary[head->get_row()])

   78               net->recursiveRowCol(net, head->get_root(), ppCorr, ary, head->row(), head->col()); 

   79          }

   80       }

   81       //... some code

   82       net->recursiveRowColSlave(net, head->get_right_ptr(),

   83          ppCorr, ary, indexRow, indexCol);

   84    }

   85 }

   86 /********************* recursiveRowColSlave ****************************/

   87 ///---Code END.

   

ExSan's lower layer is based on the Binary Tree abstract data structure. The implemented algorithm consists of two recursive functions that call each other, with one performing row traversal and the other performing column traversal. This approach significantly reduces computational time. However, implementing and coding the algorithm in C++ was a time-consuming task.

+ + C   E x S a n     C + +

Flag Counter

Comments

Popular posts from this blog

About ExSan

PerseverĪ±nce