From 393eaf1ddbc625a231cb1fb8ac66e06ba050c44b Mon Sep 17 00:00:00 2001 From: olli Date: Tue, 30 May 2023 11:57:05 +0200 Subject: [PATCH] small fixes --- dabo/recalc-times-before-example.sh | 85 +++++++++++++++++++++++++++++ strategies/sell.example.conf | 1 - 2 files changed, 85 insertions(+), 1 deletion(-) create mode 100644 dabo/recalc-times-before-example.sh diff --git a/dabo/recalc-times-before-example.sh b/dabo/recalc-times-before-example.sh new file mode 100644 index 0000000..153afe5 --- /dev/null +++ b/dabo/recalc-times-before-example.sh @@ -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 + diff --git a/strategies/sell.example.conf b/strategies/sell.example.conf index 0099bcd..4a4b975 100755 --- a/strategies/sell.example.conf +++ b/strategies/sell.example.conf @@ -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