-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbtcScript
More file actions
executable file
·76 lines (59 loc) · 2.78 KB
/
btcScript
File metadata and controls
executable file
·76 lines (59 loc) · 2.78 KB
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
68
69
70
71
72
73
74
75
76
#!/bin/sh
#Go to /home/gorkem/btcProject
cd ~/btcProject/
#Arbitrage treshold in CAD
TRS=250
#USD/TRY on www.altinkaynak.com
#Get the source code from Altinkaynak and output to wholeSite file.
##wget -q http://www.altinkaynak.com/ -O altinkaynak
#Set a variable for USDTRY Buy Price and echo it.
##USDBUY=$(cat altinkaynak | grep -A4 "\"cphMain_iarrUSD\" class=" | tail -n 4 | tail -n 2 | grep ".\..." | sed 's/ //g' | head -c 4)
##echo "Buying price for \$1 is: $USDBUY TRY (altinkaynak)"
#Set a variable for USDTRY Sell Price and echo it.
##USDSELL=$(cat altinkaynak | grep -A4 "\"cphMain_iarrUSD\" class=" | tail -n 6 | grep ".\..." | sed 's/ //g' | head -c 4)
##echo "Selling price for \$1 is: $USDSELL TRY (altinkaynak)"
#BTC/TRY on www.btcturk.com
#Get the source code from btcTurk and output to btcTurk file.
wget -q https://www.btcturk.com -O btcTurk
#Filter out the price and set it to $BTCTRY.
BTCTRY=`(cat btcTurk | grep -E "BTCTRY.*pair|pair.*BTCTRY" | cut -d "\"" -f 6)`
#Print $BTCTRY
echo "BTC is $BTCTRY TRY (btcturk)"
#BTC/CAD on mybtc.ca
#Get the source code from mybtc.ca and output to mybtc.ca file.
wget https://mybtc.ca/buy-bitcoin-with-bank-wire-canada -O mybtc.ca -q
#Filter out the price and set it to $BTCCAD.
BTCCAD=`(cat mybtc.ca | grep "rate =" | cut -d "=" -f 2 | sed 's/ //g' | cut -d "." -f 1)`
#Print $BTCCAD
echo "BTC is $BTCCAD CAD (mybtc.ca)"
#CAD/TRY on investing.ca
#Get the source code from mybtc.ca and output to investing.ca file.
wget "https://ca.investing.com/currencies/cad-try" -O investing.ca -q
#Filter out the price and set it to $CADTRY.
CADTRY=`(cat investing.ca | grep "alertValue\" placeholder" | cut -d = -f 4 | cut -d \" -f 2)`
#Print $CADTRY
echo "CAD is $CADTRY TRY (investing.ca)"
#Set BTCTURKCAD variable by using the BTCTRY and CADTRY variables. Echo out the conversion
RATE=`(calc $BTCTRY/$CADTRY | head -c 8 | cut -d "~" -f 2 | cut -d "." -f 1)`
echo "BTC is $RATE CAD on btcturk"
#Takes the difference between RATE and BTCCAD and stores it
if [ $RATE -gt $BTCCAD ]
then
DFR=`(calc $RATE-$BTCCAD | sed 's/ //g')`
echo "btcturk.com-mybtc.ca =$DFR CAD ------ `date +%H:%M\ -\ %d/%m/%y`" | tee -a historicalDifference | tee diff.txt
else
DFR=`(calc $BTCCAD-$RATE | sed 's/ //g')`
echo "mybtc.ca-btcturk.ca =$DFR CAD ------ `date +%H:%M\ -\ %d/%m/%y`" | tee -a historicalDifference | tee diff.txt
fi
#ssmtp job
#Compares the ABSOLUTE Value of DFR to Treshold
if [ $DFR -gt $TRS ]
then
printf "From: Arbitrage Alert! \nSubject:BUYSELLNOW\n\n" > message
echo "BTC is $BTCTRY TRY (btcturk)" >> message
echo "BTC is $BTCCAD CAD (mybtc.ca)" >> message
echo "CAD is $CADTRY TRY (investing.ca)" >> message
echo "BTC is $RATE CAD on btcturk" >> message
cat diff.txt >> message
ssmtp gorkememir@gmail.com < message -v
fi