small fixes

This commit is contained in:
olli 2023-05-30 11:57:05 +02:00
parent a44425fdba
commit 393eaf1ddb
2 changed files with 85 additions and 1 deletions

View File

@ -0,0 +1,85 @@
#!/bin/bash -e
. /etc/bash/gaboshlib.include
g_lockfile
for bashfunc in $(find dabo/functions -type f -name "*.sh")
do
. "$bashfunc"
done
function get_asset {
local rawhistfile=$1
echo "$rawhistfile"
cat "$rawhistfile" | while read f_line
do
local time=""
local timebefore=""
local price30before=""
local price14before=""
local price7before=""
local price1before=""
local change30before=""
local change14before=""
local change7before=""
local change1before=""
local time=$(echo ${f_line} | cut -d, -f1)
if echo $f_line | egrep -q "100,100,100,100$"
then
local time=$(echo ${f_line} | cut -d, -f1)
else
continue
fi
timebefore=$(date "+%Y-%m-%d %H:%M" -d "$time 30 day ago")
#grep "^$timebefore" "$rawhistfile"
#echo "$f_line"
price30before=$(grep "^$timebefore" "$rawhistfile" | cut -d, -f2)
[ -z "$price30before" ] && continue
local price=$(echo ${f_line} | cut -d, -f2)
change30before=$(g_percentage-diff $price30before $price)
#echo "XXXXXXX g_percentage-diff $price30before $price -> $change30before "
timebefore=$(date "+%Y-%m-%d %H:%M" -d "$time 14 day ago")
price14before=$(grep "^$timebefore" "$rawhistfile" | cut -d, -f2)
[ -z "$price14before" ] && continue
change14before=$(g_percentage-diff $price14before $price)
timebefore=$(date "+%Y-%m-%d %H:%M" -d "$time 7 day ago")
price7before=$(grep "^$timebefore" "$rawhistfile" | cut -d, -f2)
[ -z "$price7before" ] && continue
change7before=$(g_percentage-diff $price7before $price)
timebefore=$(date "+%Y-%m-%d %H:%M" -d "$time 1 day ago")
price1before=$(grep "^$timebefore" "$rawhistfile" | cut -d, -f2)
[ -z "$price1before" ] && continue
change1before=$(g_percentage-diff $price1before $price)
#echo "$f_line -- $change1before,$change7before,$change14before,$change30before"
echo "$f_line" | sed "s/^\(${time}.*\)100,100,100,100/\1$change1before,$change7before,$change14before,$change30before/"
sed -i "s/^\(${time}.*\)100,100,100,100/\11.51,4.86,1.40,9.16/" $rawhistfile
done
}
find data/botdata/asset-histories -name "*.history.csv" | while read rawhistfile
do
get_asset "${rawhistfile}" || exit 1
done

View File

@ -1,4 +1,3 @@
# remove this line if you are fine with this settings and want to use them on your own risk!!!
# It is strongly recommended to test this strategy first via analyze.sh!!!
return 1