From ccd3b510ecfb9534cb7920332fcb6f5ee8803d43 Mon Sep 17 00:00:00 2001 From: mrtg Date: Wed, 21 Feb 2024 08:30:12 +0100 Subject: [PATCH] cleanup --- scripts/cryptoAlert.pl | 56 ---------------------------------------- scripts/cryptoAnalyze.sh | 53 ------------------------------------- 2 files changed, 109 deletions(-) delete mode 100755 scripts/cryptoAlert.pl delete mode 100755 scripts/cryptoAnalyze.sh diff --git a/scripts/cryptoAlert.pl b/scripts/cryptoAlert.pl deleted file mode 100755 index 6de67a7..0000000 --- a/scripts/cryptoAlert.pl +++ /dev/null @@ -1,56 +0,0 @@ -#!/usr/bin/perl -# -use strict; -use warnings; -use RRDs; -use Data::Dumper; -use Template; - -my $file = $ARGV[0] or die("Usage: $0 csv\n"); - -my $rrdpath = "/var/www/localhost/rrd"; -my $cryptoMap = { - "AAVE" => "AAVE", - "ALGO" => "Algorand", - "BTC" => "Bitcoin", - "CVC" => "Civic", - "DNT" => "district0x", - "EGLD" => "Elrond eGold", - "ETH" => "Etherium", - "LRC" => "Loopring", - "REN" => "REN", - "SNX" => "Synthetix", - "XLM" => "Stellar Lumen", - "XTZ" => "Tezos" -}; -my $v; -my $alarmThresh = 15; - -sub getCurrentPrice { - my ($symbol) = @_; - my ($start,$step,$name,$data) = RRDs::fetch("${rrdpath}/crypto-${symbol}.rrd","LAST","--start","-10m"); - return($data->[0]->[0]); -} - -sub getLast4hAverage { - my ($symbol) = @_; - my ($start,$step,$name,$data) = RRDs::fetch("${rrdpath}/crypto-${symbol}.rrd","AVERAGE","--start","-4h","-r",'4h'); - return($data->[0]->[0]); -} - -open(CSV,"<$file") or die("open($file): $!\n"); - -while () { - chomp($_); - my ($date,$currency,$coin,$price,$fee,$buyrate,$sellthres) = split /;/; - my $curPrice = sprintf("%.4f",&getCurrentPrice($currency)); - my $avg4hPrice = sprintf("%.4f",&getLast4hAverage($currency)); - if($avg4hPrice > ((1 + int($alarmThresh)/100) * $curPrice)) { - $v->{$currency} = "current price dropped by more than ${alarmThresh}% from $avg4hPrice Euro/$currency to $curPrice Euro/$currency within 4h"; - } -} -close(CSV); - -foreach my $c (sort keys %{$v}) { - print "$cryptoMap->{$c}: $v->{$c}
\n"; -} diff --git a/scripts/cryptoAnalyze.sh b/scripts/cryptoAnalyze.sh deleted file mode 100755 index 98e5c2e..0000000 --- a/scripts/cryptoAnalyze.sh +++ /dev/null @@ -1,53 +0,0 @@ -#!/bin/sh - -HOUR=$(date +%H) -IFS=";" -while read DATE CURRENCY COIN PRICE FEE BUYRATE SELLTHRESH; -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 -l) - curProfit=$(printf "%0.2f" $(echo "$curValue - $PRICE" | bc)) - profitPerc=$(printf "%0.2f" $(echo "$curProfit / $PRICE * 100" | bc -l)) - maxDiff=$(printf "%0.2f" $(echo "(($weeklyMax) - ($current)) / ($weeklyMax) * 100" | bc -l)) - - if [ "$CURRENCY" == "BTC" ] && [ "${current%%.*}" -lt "7000" ]; - then - echo "[$CURRENCY] low exchange rate: $current EUR/${CURRENCY} => Buy more?" - continue; - fi - - if [ "${profitPerc%%.*}" -ge "$SELLTHRESH" ]; - then - echo "[$CURRENCY] bought: ${DATE}" - echo "[$CURRENCY] profit: ${profitPerc}% >= ${SELLTHRESH}% !!!!" - echo "[$CURRENCY] profit: $curProfit EUR (${profitPerc}%)" - echo "[$CURRENCY] maxDiff: ${maxDiff}%" - echo - continue - fi - -# if [ "0${maxDiff%%.*}" -ge "10" ]; -# then -# echo "[$CURRENCY] exchange rate dropped ${maxDiff}% (max: $weeklyMax EUR/${CURRENCY}, cur: $current EUR/${CURRENCY}) => Buy more?" -# continue; -# fi -# -# if [ "0${maxDiff%%.*}" -gt "3" ]; -# then -# echo "[$CURRENCY] prices dropped ${maxDiff}% (max: $weeklyMax EUR/${CURRENCY}, cur: $current EUR/${CURRENCY})" -# if [ "0${profitPerc%%.*}" -ge "10" ]; -# then -# echo "[$CURRENCY] profit: $curProfit EUR (${profitPerc}%) => sell?" -# continue; -# fi -# fi - - if [ "0$HOUR" -eq "6" ]; - then - echo "[$CURRENCY] bought: ${DATE}" - echo "[$CURRENCY] profit: $curProfit EUR (${profitPerc}%)" - echo "[$CURRENCY] maxDiff: ${maxDiff}%" - echo - fi -done < $1