-
Notifications
You must be signed in to change notification settings - Fork 0
/
driftlib.bash
68 lines (50 loc) · 2.29 KB
/
driftlib.bash
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
function bomb {
echo
echo error: $@
echo
exit 1
}
function prep_btc {
btcvalues=`grep '^drift is' $base/data/btc.txt | awk '{print $NF}' | tail -100`
(( btclast = `echo "$btcvalues" | tail -1` ))
(( btchigh = `echo "$btcvalues" | sort -n | tail -1` ))
(( btclow = `echo "$btcvalues" | sort -n | head -1` ))
btcvalues_positive=`echo "$btcvalues" | sed -r 's/^-.*/0/'`
btcvalues_no_negative=`echo "$btcvalues" | sed -r 's/^[^-].*/0/' | sed 's/-//g'`
tmp=`echo "$btcvalues" | sed 's/$/ +/'`
tmp2=`echo $tmp | sed 's/ +$//'`
lines=`echo "$tmp" | wc -l`
(( btcavg = ( $tmp2 ) / lines ))
unset tmp tmp2 lines
(( btc_variability = btclast - btcavg ))
}
function prep_eur {
eurvalues=`grep '^drift is' $base/data/eur.txt | awk '{print $NF}' | tail -100`
(( eurlast = `echo "$eurvalues" | tail -1` ))
(( eurhigh = `echo "$eurvalues" | sort -n | tail -1` ))
(( eurlow = `echo "$eurvalues" | sort -n | head -1` ))
eurvalues_positive=`echo "$eurvalues" | sed -r 's/^-.*/0/'`
eurvalues_no_negative=`echo "$eurvalues" | sed -r 's/^[^-].*/0/' | sed 's/-//g'`
tmp=`echo "$eurvalues" | sed 's/$/ +/'`
tmp2=`echo $tmp | sed 's/ +$//'`
lines=`echo "$tmp" | wc -l`
(( euravg = ( $tmp2 ) / lines ))
unset tmp tmp2 lines
(( eur_variability = eurlast - euravg ))
}
function prep_paxg {
paxgvalues=`grep '^drift is' $base/data/paxg.txt | awk '{print $NF}' | tail -100`
[[ -z $paxgvalues ]] && bomb unable to define paxgvalues
(( `echo "$paxgvalues" | wc -l` <= 5 )) && echo -e not enough data just yet\\n && exit 0
(( paxglast = `echo "$paxgvalues" | tail -1` ))
(( paxghigh = `echo "$paxgvalues" | sort -n | tail -1` ))
(( paxglow = `echo "$paxgvalues" | sort -n | head -1` ))
paxgvalues_positive=`echo "$paxgvalues" | sed -r 's/^-.*/0/'`
paxgvalues_no_negative=`echo "$paxgvalues" | sed -r 's/^[^-].*/0/' | sed 's/-//g'`
tmp=`echo "$paxgvalues" | sed 's/$/ +/'`
tmp2=`echo $tmp | sed 's/ +$//'`
lines=`echo "$tmp" | wc -l`
(( paxgavg = ( $tmp2 ) / lines ))
unset tmp tmp2 lines
(( paxg_variability = paxglast - paxgavg ))
}