00001
00002 #include <math.h>
00003 #include <stdio.h>
00004 #include <string.h>
00005 #include "hurst_test_base.h"
00006
00012 hurst_test_base::equityEntry hurst_test_base::equityTable_[] =
00013 { hurst_test_base::equityEntry( "Alcoa", "aa", "aa.csv" ),
00014 hurst_test_base::equityEntry( "Applied Mat.", "amat", "amat.csv"),
00015 hurst_test_base::equityEntry( "Boeing", "ba", "ba.csv" ),
00016 hurst_test_base::equityEntry( "Capital One", "cof", "cof.csv" ),
00017 hurst_test_base::equityEntry( "GE", "ge", "ge.csv" ),
00018 hurst_test_base::equityEntry( "General Mills","gis", "gis.csv"),
00019 hurst_test_base::equityEntry( "IBM Corp.", "ibm", "ibm.csv" ),
00020 hurst_test_base::equityEntry( "Intel", "intc", "intc.csv" ),
00021 hurst_test_base::equityEntry( "3M Corp.", "mmm", "mmm.csv" ),
00022 hurst_test_base::equityEntry( "Merck", "mrk", "mrk.csv"),
00023 hurst_test_base::equityEntry( "Wal-Mart", "wmt", "wmt.csv"),
00024 };
00025
00026 const size_t hurst_test_base::tableSize_ =
00027 sizeof( hurst_test_base::equityTable_ ) / sizeof( hurst_test_base::equityEntry );
00028
00034 hurst_test_base::equityEntry &
00035 hurst_test_base::findTableEntry( const char *ticker )
00036 {
00037 for (size_t i = 0; equityTable_[i].ticker() != 0; i++) {
00038 if (strcmp(equityTable_[i].ticker(), ticker) == 0)
00039 break;
00040 }
00041 return equityTable_[i];
00042 }
00043
00044
00058 size_t hurst_test_base::blockedLogReturn( const double *v,
00059 double *ret,
00060 const size_t N,
00061 const size_t block_size )
00062 {
00063 size_t ix = 0;
00064 for (size_t i = block_size; i < N; i = i + block_size) {
00065 ret[ix] = log(v[i]) - log(v[i-block_size]);
00066
00067 ix++;
00068 }
00069
00070 return ix;
00071 }
00072
00087 size_t hurst_test_base::blockedPercentReturn( const double *v,
00088 double *ret,
00089 const size_t N,
00090 const size_t block_size )
00091 {
00092 size_t ix = 0;
00093 for (size_t i = block_size; i < N; i = i + block_size) {
00094 ret[ix] = (v[i] - v[i-block_size]) / v[i-block_size];
00095 ix++;
00096 }
00097 return ix;
00098 }