35 lines
1.2 KiB
Bash
Executable File
35 lines
1.2 KiB
Bash
Executable File
#!/bin/sh
|
|
|
|
IFS=";"
|
|
while read DATE CURRENCY COIN PRICE FEE BUYRATE;
|
|
do
|
|
weeklyMax=$(rrdtool fetch rrd/crypto-${CURRENCY}.rrd AVERAGE --start -7d | grep -v -- '-nan' | sort -n -k 2 | tail -1 | awk '{print $2}' | sed 's/e+/ * 10^/g; s/e-/ * 10^-/g;' | bc -l)
|
|
current=$(rrdtool fetch rrd/crypto-${CURRENCY}.rrd LAST --start -10m | grep -v -- '-nan' | tail -1 | awk '{print $2}' | sed 's/e+/ * 10^/g; s/e-/ * 10^-/g' | bc -l)
|
|
curValue=$(echo "$COIN * $current - $FEE" | bc)
|
|
curProfit=$(printf "%0.2f" $(echo "$curValue - $PRICE" | bc))
|
|
maxDiff=$(echo "(($weeklyMax) - ($current)) / ($weeklyMax) * 100" | bc)
|
|
|
|
if [ "$CURRENCY" == "BTC" ] && [ "${current%%.*}" -lt "5000" ];
|
|
then
|
|
echo "[$CURRENCY] low exchange rate: $current EUR/${CURRENCY}\n => Buy more?"
|
|
continue;
|
|
fi
|
|
|
|
if [ "${maxDiff%%.*}" -gt "10" ];
|
|
then
|
|
echo "[$CURRENCY] exchange rate dropps by more than 10% (max: $weeklyMax EUR/${CURRENCY}, cur: $current EUR/${CURRENCY})\n => Buy more?"
|
|
continue;
|
|
fi
|
|
|
|
if [ "0${maxDiff%%.*}" -gt "3" ];
|
|
then
|
|
echo "[$CURRENCY] prices dropping by more than 3% (max: $weeklyMax, cur: $current)"
|
|
if [ "0$curProfit" -gt "0" ];
|
|
then
|
|
echo "[$CURRENCY] profit: $curProfit EUR\n => sell?"
|
|
fi
|
|
fi
|
|
|
|
echo "[$CURRENCY] profit: $curProfit EUR"
|
|
done < $1
|