small fixes
This commit is contained in:
parent
a44425fdba
commit
393eaf1ddb
85
dabo/recalc-times-before-example.sh
Normal file
85
dabo/recalc-times-before-example.sh
Normal 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
|
||||||
|
|
@ -1,4 +1,3 @@
|
|||||||
|
|
||||||
# remove this line if you are fine with this settings and want to use them on your own risk!!!
|
# 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!!!
|
# It is strongly recommended to test this strategy first via analyze.sh!!!
|
||||||
return 1
|
return 1
|
||||||
|
Loading…
Reference in New Issue
Block a user