Nei giorni scorsi in Spa c'è stata una discussione accesa sull'andamento di ENI.
Per provare a dipanare la questione, ho porvato a scrivere del codice per studiare il suo comportamento:
Codice:
function [mem kvec matperc] = nbehaviourtest ( matfeed )
[n m]=size (matfeed);
% n = number of stocks we are considering
% m = number of days we are considering
% this program in order to run needs to have in the stack a matrix called matfeed
% with different stocks columnwise and set of time row-wise. The smaller
% the set of time is, the better.
% mem is a ratio between number of times in tails and total days, a smaller ratio
% means a more perturbated behaviour
% kvec(i) is the number of times in the tails, at a given time i
for i = 1:n
for j =1:m
matvar(i, j)=matfeed(i,m+1-j);
end;
end;
for i=1:n
for j =m-1:-1:1
a=matvar(i,j+1);
b=matvar(i,j);
matperc(i,j)=100*(a-b)/b;
end;
end;
vecperc=reshape(matperc', 1, (m-1)*n);
[mu sigma]=normfit(vecperc);
disp('Trivial likelihood test: the smaller the better');
normlike([mu sigma], vecperc)
a=norminv([0.2 0.8], mu, sigma);
clear mem kvec;
k=0;
mem =[];
kvec=[];
for i=1:m-1
if ( vecperc(i) < a(1) || vecperc(i)>a(2) ) k=k+1;
end;
mem=[mem 1-k/i];
kvec=[kvec k];
end;
x=-200:.1:200;
figure('Name','Distribution of percentile asset prices variation, over time','NumberTitle','off')
plot(x, normpdf(x, mu, sigma*sigma));
grid on
figure('Name','Skewness index','NumberTitle','off')
area (1:length(mem), mem);
grid on
end
i dati presi da yahoo finance sono
Codice:
matfeed = [17.760 17.910 15.240 15.280 15.410 16.330 15.880 16.380 16.550 16 13.970 15.150 16.090 15.470 13.760 14.850 ] ; [1.40 1.370 1.30 1.370 1.410 1.40 1.40 1.410 1.380 1.370 1.40 1.390 1.440 1.530 1.320 1.40 ] ; [5.20 4.950 4.640 4.70 4.640 4.80 5.080 5.210 5.240 5.050 5.010 5.250 5.520 5.330 4.820 5.150 ] ; [14.350 14.710 14.510 14.460 14.650 14.580 14.350 14.550 14.620 13.370 13.040 13.250 13.860 13.470 13.220 13.110 ] ; [3.660 3.680 3.490 3.40 3.430 3.610 3.680 3.890 4.030 4 3.950 4.20 4.380 3.810 3.030 3.40 ] ; [1.440 1.410 1.30 1.280 1.340 1.420 1.410 1.470 1.50 1.460 1.530 1.550 1.590 1.580 1.50 1.650 ] ; [1.790 1.710 1.530 1.760 1.860 2.020 2.090 2.240 2.270 2.330 2.160 2.480 2.710 2.580 2.320 2.670 ] ; [5.270 5.290 4.940 4.820 5.080 5.30 5.080 5.230 5.490 5.20 5.010 5.310 5.860 5.450 4.60 5.030 ] ; [10.260 9.750 8.970 9.340 9.110 9.340 9.920 10.80 10.820 10.150 9.420 9.150 9.760 9.640 8.70 9.620 ] ; [5.970 5.660 5.290 5.360 5.850 6.450 6.540 6.670 7.20 7.280 7.350 7.720 8.10 7.70 6.680 6.880 ] ; [9.490 9.490 8.820 8.770 9.110 9.010 9.570 10.760 11.510 12.680 12.790 13.980 14.490 14.580 13.750 14.610 ] ; [19 19.170 18.170 18.890 19.670 20.90 20.950 21.60 21.80 21.090 20.970 21.680 21.840 21.60 20.650 21.080 ] ; [2.790 2.550 2.170 2.370 2.630 2.950 3.010 3.110 3.070 3.010 2.860 3.270 3.460 3.360 2.90 3.050 ] ; [16.710 16.720 16.530 16.090 16.290 16.550 15.50 16.180 16.550 15.70 15.450 15.950 16.830 16.190 15.690 16.150 ] ; [15.030 14.990 14.240 14.550 14.250 15.60 15.850 15.960 15.470 14.950 14.50 14.930 15.140 15.150 13.60 13.810 ] ; [8.760 8.620 8.510 8.60 8.730 8.80 8.750 8.820 8.870 8.820 8.810 8.850 8.940 8.80 8.510 8.690 ] ; [3.050 3.160 3.10 3.020 3.030 3.270 3.210 3.310 3.330 3.20 3.30 3.320 3.330 3.190 2.890 3.110 ] ; [4.250 4.020 3.840 4 3.890 4.110 4.260 4.270 4.180 3.960 3.820 3.990 4.20 4.110 3.80 3.880 ] ; [1.30 1.330 1.280 1.240 1.270 1.30 1.280 1.260 1.590 1.630 1.60 1.560 1.540 1.490 1.370 1.410 ] ; [4.340 4.160 4.030 4.160 4.630 4.610 4.840 4.930 4.820 4.70 4.680 4.60 4.80 4.480 3.660 3.990 ] ; [14.420 15.410 13.030 12.340 12.130 12.550 13.060 13.970 13 12.490 12.80 14.60 15.620 15.40 13.20 14.040 ] ; [6.220 6.470 6.230 6.060 6.20 6.250 6.30 6.350 6.540 6.170 5.950 6.240 6.880 6.930 6.470 6.730 ] ; [7.60 7.550 6.370 6.390 6.970 7.590 7.650 8.970 9.160 8.820 8.220 9.130 10.350 10.190 8.840 10.560 ] ; [0.880 0.870 0.820 0.840 0.860 0.90 0.890 0.930 0.950 0.880 0.830 0.860 0.90 0.860 0.750 0.830 ] ; [2.490 2.50 2.40 2.270 2.430 2.530 2.430 2.360 2.360 2.390 2.180 2.270 2.320 2.330 2.170 2.280 ] ; [1.790 1.710 1.530 1.760 1.860 2.020 2.090 2.240 2.270 2.330 2.160 2.480 2.710 2.580 2.320 2.670 ] ;
Considerando 15 giorni dopo il 10 ottobre il vettore rappresentante il numero di giorni in coda è:
Codice:
1 2 2 3 4 5 5 5 5 5 6 6 6 7 7