add crypto analyze

This commit is contained in:
Arne Baeumler 2020-05-01 22:37:53 +02:00
parent 257841947a
commit 93ddb34d1f
2 changed files with 39 additions and 0 deletions

5
scripts/crypto.csv Normal file
View File

@ -0,0 +1,5 @@
2020-04-21;BTC;0.00289369;20;1.49;6396.68
2020-04-28;BTC;0.12019584;900;13.21;7377.44
2020-04-28;LTC;1.11667004;50;1.99;42.99
2020-04-28;EOS;8.987;25;1.49;2.62
2020-04-28;XLM;361.076062;25;1.49;0.0651
1 2020-04-21 BTC 0.00289369 20 1.49 6396.68
2 2020-04-28 BTC 0.12019584 900 13.21 7377.44
3 2020-04-28 LTC 1.11667004 50 1.99 42.99
4 2020-04-28 EOS 8.987 25 1.49 2.62
5 2020-04-28 XLM 361.076062 25 1.49 0.0651

34
scripts/cryptoAnalyze.sh Executable file
View File

@ -0,0 +1,34 @@
#!/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