-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathCompare_rate.sh
65 lines (31 loc) · 1.54 KB
/
Compare_rate.sh
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
#!/bin/ksh
#Need to dynamically read value of price difference from Form
#Below is just of testing
Output_File=/home/user/Output.out
Date_Time=`date +"%Y-%m-%d %H:%M:%S"`
Diff_value="0.1"
wget -o COIN_BASE_DOWNLOAD.log https://coinbase.com/api/v1/prices/spot_rate
COIN_BASE="spot_rate"
COIN_BASE_VALUE=`cat spot_rate | cut -d":" -f2 | cut -d"," -f1 | tr -d "\""`
echo "*******Comparison of COIN BASE and BIT STAMP Prices @ $Date_Time ******" >> $Output_File
echo "COIN BASE VALUE = $COIN_BASE_VALUE" >> $Output_File
wget -o bitstamp_download.log https://www.bitstamp.net/api/ticker/
BITSTAMP_VALUE=`cat index.html | cut -d":" -f3 | cut -d"," -f1 | tr -d "\"" | tr -d " "`
echo "BITSTAMP VALUE= $BITSTAMP_VALUE" >>$Output_File
#CoinminBit=`expr $COIN_BASE_VALUE - $BITSTAMP_VALUE`
#BitminCoin=`expr $BITSTAMP_VALUE - $COIN_BASE_VALUE`
CoinminBit=`echo "$COIN_BASE_VALUE-$BITSTAMP_VALUE" | bc`
BitminCoin=`echo "$BITSTAMP_VALUE-$COIN_BASE_VALUE" | bc`
#echo "$CoinminBit $BitminCoin"
if [ $CoinminBit -gt $Diff_value ];
then
echo "COIN BASE is greater than BITSTAMP. Difference= $CoinminBit" >>$Output_File
echo "Coin Base is greater than Bitstamp = $CoinminBit" | mailx -s "COIN_BASE_VALUE-BITSTAMP_VALUE is $CoinminBit" [email protected]
fi
if [ $BitminCoin -gt $Diff_value ];
then
echo "BITSTAMP is grater than COINBASE. Difference= $BitminCoin" >>$Output_File
echo "Bitstamp is grater than coin base $BitminCoin" | mailx -s "BITSTAMP_VALUE-COIN_BASE_VALUE is $BitminCoin" [email protected]
fi
/bin/cat $Output_File
rm spot_rate index.html *log