Main Page   Namespace List   Class Hierarchy   Compound List   File List   Compound Members   File Members  

hurst_stocks.cpp

Go to the documentation of this file.
00001 
00002 #include <assert.h>
00003 #include <stdio.h>
00004 
00005 #include "hurst_stocks.h"
00006 #include "rescaled_range.h"
00007 
00008 
00023 void hurst_stocks::test()
00024 {
00025   const size_t days = 10;
00026   // const size_t ReturnSize = 1024;
00027   const size_t ReturnSize = 8192;
00028   // const size_t DataSize = ReturnSize + days;
00029   const size_t DataSize = 8192;
00030 
00031   // These arrays have to be static to get around some Microsoft
00032   // wierdness with large stack allocated arrays.
00033   static double data[ DataSize ];
00034   static double returns[ ReturnSize ];
00035 
00036   rescaled_range hurst;
00037   rescaled_range::hurstInfo info;
00038 
00039   //
00040   // To test a single return period against the table of stocks
00041   // uncomment this for loop and assign a single n-day return
00042   // period to blockSize.  Comment out the enclosed for loop
00043   // (see below).
00044   //
00045   //  for (size_t tableEntry = 0; tableEntry < tableSize_; tableEntry++) {
00046   //  const char *fileName = equityTable_[tableEntry].file();
00047     const char *fileName = "ibm_30year.csv";
00048     size_t n = DataSize;
00049     if (ts.getTS( fileName, data, n, yahooTS::Close )) {
00050       assert(n == DataSize );
00051 
00052       //
00053       // Comment out the for loop if you are calculating returns
00054       // on a table of stocks and use a fixed return period.
00055       // The return period is defined by blockSize.
00056       //
00057       for (size_t blockSize = 1; blockSize <= 30; blockSize++) {
00058         for (size_t i = 0; i < ReturnSize; i++)
00059           returns[i] = 0;
00060 
00061         size_t numReturns;
00062         numReturns = blockedLogReturn( data, returns, DataSize, blockSize );
00063 
00064         hurst.calc_hurst_est( returns, numReturns, info );
00065 
00070 
00071       // const char *companyName = equityTable_[tableEntry].name();
00072 
00073         const char *companyName = "IBM Corp.";
00081 
00082         // printf("%2d %7.4f\n", blockSize, sigma );
00083         printf("%2d %7.4f\n", blockSize, info.slope());
00084       }
00085 
00093   } // for
00094 }

Generated at Thu May 22 21:12:35 2003 for Hurst Exponent Calculation and Supporting Statistics by doxygen1.2.8.1 written by Dimitri van Heesch, © 1997-2001