ExSan & Interactive Brokers C++ API CODING 002

      Previous Post       Next Post

CLUSTERING

    1 //*----------------------------------

    2 // cluster traversal 

    3 cout << "\n\t:Begin --- cluster traversal----- nStocks: " << nStocksMg;

    4 

    5 for (i = 0; i <= nPointers - 1; i++) { 

    6    aryStockPtr[i] = nullptr;

    7    aryPtr[i]     = nullptr;

    8    aryStockPtr[i] = net->goto_row(net, ppDataIn, i + 1, 'f');                  

    9    pltM.idStockInQue(aryStockPtr[i]->get_stock_name());

   10    aryPtr[i] = aryStockPtr[i]->get_ptrLasTick();

   11 }

   12 

   13 for (j = 1; j <= net->get_cols_in_page(ppDataIn, 'f'); j++) {//OK revised Aug 27                                                

   14    for (i = 0; i <= nPointers - 1; i++) {//OK revised Aug 27                                          

   15       //doNodeClustering

   16       aryPtr[i]->Tree_nt_CandleParameters( aryPtr[i], aryPtr[i]->getHead(), ppdata, 

   17            ppopenVal, pplowVal, pphighVal, ppcloseVal, superMin, superMax);

   18 

   19       aryPtr[i] = aryPtr[i]->get_next_ptr();

   20       if(aryPtr[i]->get_col() > net->get_cols_in_page(ppDataIn)) 

   21          aryPtr[i] = aryStockPtr[i]->get_forward_ptr();                     

   22    }      

   23 }

   24 

   25 unsigned short idGraph(0);

   26 pltM.set_titleMg("HISTORICAL DATA - Snapshot of Market, sometime after 2000 " + idGraph);

   27 string plot_data = "d:\\\\xxxdirectory\\\\";

   28                

   29 pltM.set_path(plot_data);

   30 pltM.set_idPlotmG(++idPlotG);

   31 

   32 unsigned short * indexNtNodeAry = new unsigned short[nStocksMg];

   33 fstream* fAry     = new fstream[nStocksMg];  //candle

   34 fstream* fAryData = new fstream[nStocksMg];  //full data

   35 

   36 string* AryDataFileName  = new string[nStocksMg];  //full data

   37 string* AryDataFileName2 = new string[nStocksMg];  //full data

   38 

   39 double* minfAryData = new double[nStocksMg];  //full data

   40 double* maxfAryData = new double[nStocksMg];  //full data

   41 

   42 double* minfAry = new double[nStocksMg];  //candle

   43 double* maxfAry = new double[nStocksMg];  //candle

   44 

   45 for (unsigned short ff = 0; ff < nStocksMg; ff++) {

   46    minfAry[ff] = minfAryData[ff] = 10000000.;

   47    maxfAry[ff] = maxfAryData[ff] = 0;

   48    indexNtNodeAry[ff] = 0;                                 

   49    

   50    AryDataFileName[ff] = 

plot_data + "_cndlData_" + to_string(idPlotG) + to_string(ff) + "_" + topic_id_job + ".txt";   

   51    fAry[ff].open(AryDataFileName[ff], ios::out);

   52 

   53    AryDataFileName2[ff] = plot_data + "_rawData_" + to_string(idPlotG) + to_string(ff) + "_" + topic_id_job + ".txt";   

   54    fAryData[ff].open(AryDataFileName2[ff], ios::out);

   55 }

   56 

   57 for (i = 0; i <= nPointers - 1; i++) {                  

   58    aryPtr[i] = aryStockPtr[i]->get_ptrLasTick();   

   59 }

   60 

   61 for (j = 1; j <= net->get_cols_in_page(ppDataIn, 'f'); j++) {//OK revised                                                                 

   62    for (i = 0; i <= nPointers - 1; i++) {//OK revised Mar 7                     

   63          switch (aryPtr[i]->get_row()) {

   64             case 1:  

   65             if (j == 1)   fAry[0] <<  ntNodes / 2 ;    else fAry[0] << ntNodes / 2 + j * ntNodes;

   66             fAry[0] <<  "\t" <<  aryPtr[i]->get_data(pp_openVal) << "\t" << aryPtr[i]->get_data(pp_lowVal) <<  

   67             "\t " << aryPtr[i]->get_data(pp_highVal) << "\t" << aryPtr[i]->get_data(pp_closeVal) << endl;

   68 

   69             if (aryPtr[i]->get_data(pp_lowVal) < minfAry[0])  minfAry[0] = aryPtr[i]->get_data(pp_lowVal);

   70             else if (maxfAry[0] < aryPtr[i]->get_data(pp_highVal)) maxfAry[0] = aryPtr[i]->get_data(pp_highVal);

   71             break;

   72 

   73             case 2:  

   74             aryPtr[i]->get_data(pp_lowVal) << aryPtr[i]->get_data(pp_highVal) << aryPtr[i]->get_data(pp_closeVal);

   75             if (j == 1)   fAry[1] << ntNodes / 2;    else fAry[1] << ntNodes / 2 + (j-1) * ntNodes;

   76             fAry[1] << "\t" << aryPtr[i]->get_data(pp_openVal) << "\t" << aryPtr[i]->get_data(pp_lowVal) << 

   77             "\t " << aryPtr[i]->get_data(pp_highVal) << "\t" << aryPtr[i]->get_data(pp_closeVal) ;

   78 

   79             if (aryPtr[i]->get_data(pp_lowVal) < minfAry[1])       minfAry[1] = aryPtr[i]->get_data(pp_lowVal);

   80             else if (maxfAry[1] < aryPtr[i]->get_data(pp_highVal)) maxfAry[1] = aryPtr[i]->get_data(pp_highVal);

   81             break;

   82             

   83             case 3:  

   84             if (j == 1)   fAry[2] << ntNodes / 2;    else fAry[2] << ntNodes / 2 + (j-1) * ntNodes;

   85             fAry[2] << "\t" << aryPtr[i]->get_data(pp_openVal) << "\t" << aryPtr[i]->get_data(pp_lowVal) << "\t " 

   86             << aryPtr[i]->get_data(pp_highVal) << "\t" << aryPtr[i]->get_data(pp_closeVal) << endl;

   87 

   88            if (aryPtr[i]->get_data(pp_lowVal) < minfAry[2])       minfAry[2] = aryPtr[i]->get_data(pp_lowVal);

   89            else if (maxfAry[1] < aryPtr[2]->get_data(pp_highVal)) maxfAry[2] = aryPtr[i]->get_data(pp_highVal);

   90            break;

   91 

   92            case 4:  

   93            if (j == 1)   fAry[2] << ntNodes / 2;    else fAry[3] << ntNodes / 2 + (j - 1) * ntNodes;

   94            fAry[3] << "\t" << aryPtr[i]->get_data(pp_openVal) << "\t" << aryPtr[i]->get_data(pp_lowVal) << "\t " 

   95            << aryPtr[i]->get_data(pp_highVal) << "\t" << aryPtr[i]->get_data(pp_closeVal) << endl;

   96            

   97            if (aryPtr[i]->get_data(pp_lowVal) < minfAry[2])       minfAry[2] = aryPtr[i]->get_data(pp_lowVal);

   98            else if (maxfAry[1] < aryPtr[2]->get_data(pp_highVal)) maxfAry[2] = aryPtr[i]->get_data(pp_highVal);

   99            break;

  

130             ...;

  

135    }   

  

136 }

  

137 //*/

  

138 //-------------cluster traversal--------------------

Comments

Popular posts from this blog

Interactive Brokers tick by tick Data Market - C++ API & ExSan jobID 106391

Systematic Forex Trading

Interactive Brokers C++ API & ExSan xsn 279947