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

acorrtst.cpp

Go to the documentation of this file.
00001 
00007 
00008 #include <assert.h>
00009 #include <math.h>
00010 #include <stdio.h>
00011 
00012 #include "yahooTS.h"
00013 
00014 #include "autocorr.h"
00015 
00016 const size_t days = 10;
00017 // 2**10
00018 const size_t N = 1024 + days;
00019 // const size_t N = 1024;
00020 // 2**9
00021 // const size_t N = 512;
00022 
00023 static double v[ N ];
00024 static double returns[ N-days ];
00025 
00026 // static double v[] = {
00027 // #include "data/brown72.h"
00028   // #include "data/franses_data/data7.h"
00029   // #include "data/fgn8.h"
00030 // };
00031 //
00032 // const size_t N = sizeof( v ) / sizeof( double );
00033 
00034 
00035 int
00036 main()
00037 {
00038   autocorr acor(0.01, 256);
00039   autocorr::acorrInfo info;
00040   size_t i;
00050 
00051   yahooTS ts( "..\\data\\equities\\" );
00052   
00053   size_t n = N;
00054   if (ts.getTS( "aa.csv", v, n, yahooTS::Close )) {
00055     assert( n == N );
00056 
00057     for (i = days; i < N; i++) {
00058       // returns[i-1] = (v[i] - v[i-1])/v[i-1];
00059       returns[i-days] = log(v[i]) - log(v[i-days]);
00060       // printf("%9.6f\n", returns[i-days] );
00061     }
00062 
00063     acor.ACF( returns, N, info );
00064 
00065     const size_t len = info.points().size();
00066     for (i = 0; i < len; i++) {
00067       printf("%7.4f\n", (info.points())[i] );
00068     }
00069 
00070     // printf("slope = %7.4f, slopeErr = %7.4f\n", info.slope(), info.slopeErr());
00071   }
00072   else {
00073     fprintf(stderr, "main: getTS failed\n");
00074   }
00075 
00076   return 0;
00077 }

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