1 |
#!/bin/sh |
2 |
|
3 |
tmp=/var/tmp/stock4gp |
4 |
dir=/data/corp/esi |
5 |
|
6 |
do_gnuplot() { |
7 |
|
8 |
gnuplot -persist << EOF |
9 |
set terminal png color |
10 |
set output '$dir/out.png' |
11 |
set noclip points |
12 |
set clip one |
13 |
set noclip two |
14 |
set bar 1.000000 |
15 |
set border 31 lt -1 lw 1.000 |
16 |
set xdata time |
17 |
set ydata |
18 |
set zdata |
19 |
set x2data |
20 |
set y2data |
21 |
set boxwidth |
22 |
set dummy x,y |
23 |
set format x "%d.%m" |
24 |
set format y "%g" |
25 |
set format x2 "%g" |
26 |
set format y2 "%g" |
27 |
set format z "%g" |
28 |
set angles radians |
29 |
set nogrid |
30 |
set key title "" |
31 |
set key right top Right noreverse box linetype -2 linewidth 1.000 samplen 4 spacing 1 width 0 |
32 |
set nolabel |
33 |
set noarrow |
34 |
set nolinestyle |
35 |
set nologscale |
36 |
set offsets 0, 0, 0, 0 |
37 |
set pointsize 1 |
38 |
set encoding default |
39 |
set nopolar |
40 |
set noparametric |
41 |
set view 60, 30, 1, 1 |
42 |
set samples 100, 100 |
43 |
set isosamples 10, 10 |
44 |
set surface |
45 |
set nocontour |
46 |
set clabel '%8.3g' |
47 |
set mapping cartesian |
48 |
set nohidden3d |
49 |
set cntrparam order 4 |
50 |
set cntrparam linear |
51 |
set cntrparam levels auto 5 |
52 |
set cntrparam points 5 |
53 |
set size ratio 0 1,1 |
54 |
set origin 0,0 |
55 |
set data style points |
56 |
set function style lines |
57 |
set xzeroaxis lt -2 lw 1.000 |
58 |
set x2zeroaxis lt -2 lw 1.000 |
59 |
set yzeroaxis lt -2 lw 1.000 |
60 |
set y2zeroaxis lt -2 lw 1.000 |
61 |
set tics in |
62 |
set ticslevel 0.5 |
63 |
set ticscale 1 0.5 |
64 |
set mxtics default |
65 |
set mytics default |
66 |
set mx2tics default |
67 |
set my2tics default |
68 |
set xtics border mirror norotate autofreq |
69 |
set ytics border mirror norotate autofreq |
70 |
set ztics border nomirror norotate autofreq |
71 |
set nox2tics |
72 |
set noy2tics |
73 |
set title "" 0.000000,0.000000 "" |
74 |
set timestamp "" bottom norotate 0.000000,0.000000 "" |
75 |
set rrange [ * : * ] noreverse nowriteback # (currently [-0.00000:10.0000] ) |
76 |
set trange [ * : * ] noreverse nowriteback # (currently ["31.12.1999":"01.01.2000"] ) |
77 |
set urange [ * : * ] noreverse nowriteback # (currently ["31.12.1999":"01.01.2000"] ) |
78 |
set vrange [ * : * ] noreverse nowriteback # (currently [-5.00000:5.00000] ) |
79 |
set xlabel "" 0.000000,0.000000 "" |
80 |
set x2label "" 0.000000,0.000000 "" |
81 |
set timefmt "%d\.%m\.%Y" |
82 |
set xrange [ * : * ] noreverse nowriteback # (currently ["31.12.1999":"01.01.2000"] ) |
83 |
set x2range [ * : * ] noreverse nowriteback # (currently [-10.0000:10.0000] ) |
84 |
set ylabel "" 0.000000,0.000000 "" |
85 |
set y2label "" 0.000000,0.000000 "" |
86 |
set yrange [ * : * ] noreverse nowriteback # (currently [-10.0000:10.0000] ) |
87 |
set y2range [ * : * ] noreverse nowriteback # (currently [-10.0000:10.0000] ) |
88 |
set zlabel "" 0.000000,0.000000 "" |
89 |
set zrange [ * : * ] noreverse nowriteback # (currently [-10.0000:10.0000] ) |
90 |
set zero 1e-08 |
91 |
set lmargin -1 |
92 |
set bmargin -1 |
93 |
set rmargin -1 |
94 |
set tmargin -1 |
95 |
set locale "C" |
96 |
plot '/var/tmp/stock4gp' using 1:3:2:4 title 'LSE' with yerrorbars, '/var/tmp/stock4gp' using 1:3 title 'average' with lines |
97 |
EOF |
98 |
|
99 |
} |
100 |
|
101 |
# normal stocks |
102 |
|
103 |
psql -t -A -F " " corp -c "set datestyle='german' ; select date(date),min(current),avg(current),max(current),type,count(*) from stocks where type='LSE' group by date(date),type order by type,date(date)" -o $tmp |
104 |
do_gnuplot; |
105 |
convert $dir/out.png -quality 90 $dir/stocks.jpg |
106 |
|
107 |
# stocks in last 30 days |
108 |
|
109 |
psql -t -A -F " " corp -c "set datestyle='german' ; select date(date),min(current),avg(current),max(current),type,count(*) from stocks where type='LSE' and date(now())-date(date) < 30 group by date(date),type order by type,date(date)" -o $tmp |
110 |
do_gnuplot; |
111 |
convert $dir/out.png -quality 90 $dir/stocks-30.jpg |
112 |
|
113 |
# stocks in last 7 days |
114 |
|
115 |
psql -t -A -F " " corp -c "set datestyle='german' ; select date(date),min(current),avg(current),max(current),type,count(*) from stocks where type='LSE' and date(now())-date(date) < 7 group by date(date),type order by type,date(date)" -o $tmp |
116 |
do_gnuplot; |
117 |
convert $dir/out.png -quality 90 $dir/stocks-7.jpg |