more pure bash to speed up things

This commit is contained in:
olli 2023-11-12 13:24:43 +01:00
parent 5f5c19eea9
commit 6d6eecf4b1

View File

@ -47,9 +47,9 @@ function analyze {
>${g_tmp}/${tmpfile}
>${g_tmp}/result-${tmpfile}
rm -f ${g_tmp}/open-${tmpfile}
rm -f ${g_tmp}/interim-${tmpfile}
rm -f ${g_tmp}/output-${tmpfile}
rm -rf ${g_tmp}/open-${tmpfile}
rm -rf ${g_tmp}/interim-${tmpfile}
rm -rf ${g_tmp}/output-${tmpfile}
#local f_ORIGIFS="$IFS"
#IFS=$'\n'
@ -63,16 +63,13 @@ function analyze {
mapfile -t f_lines <<<$(egrep "^${ANALYZE_TIME}" "$file" | grep -v ',,')
for line in "${f_lines[@]}"
do
# Chart Part
f_sell_score=""
f_buy_score=""
# Chart Part End
#IFS=$f_ORIGIFS
current=$(echo $line | cut -d, -f2)
time=$(echo $line | cut -d, -f1 | cut -d: -f1,2)
f_market_performance=$(grep "^$time" data/botdata/MARKET_PERFORMANCE | tail -n1 | cut -d: -f4 | cut -d"%" -f1 | sed 's/ *//')
echo "$line" >>${g_tmp}/${tmpfile}
echo " ${line},${f_market_performance}" | perl -pe 's/([0-9].[0-9][0-9][0-9][0-9][0-9][0-9])[0-9]+/$1/g' | column -t -s, >>${g_tmp}/output-${tmpfile}
#echo " ${line},${f_market_performance}" | perl -pe 's/([0-9].[0-9][0-9][0-9][0-9][0-9][0-9])[0-9]+/$1/g' | column -t -s, >>${g_tmp}/output-${tmpfile}
if [ -f "${g_tmp}/open-${tmpfile}" ]
then
if [ "${ANALYZE_VERBOSE}" -eq "0" ]
@ -117,10 +114,12 @@ function analyze {
then
f_SELL="SELL ${f_ASSET}: End of file/data"
echo "SELL: $(tail -n1 ${g_tmp}/${tmpfile} | cut -d, -f1) === ${f_SELL}" >>${g_tmp}/output-${tmpfile} 2>&1
result=$(g_percentage-diff ${BUY_PRICE} ${current})
#result=$(g_percentage-diff ${BUY_PRICE} ${current})
result=$(g_percentage-diff ${BUY_PRICE} ${f_price})
result=$(g_calc "${result}-${FEE}")
echo "$result" >>${g_tmp}/result-${tmpfile}
echo "RESULT: ${result}% (${BUY_PRICE} -> ${current})" >>${g_tmp}/output-${tmpfile}
#echo "RESULT: ${result}% (${BUY_PRICE} -> ${current})" >>${g_tmp}/output-${tmpfile}
echo "RESULT: ${result}% (${BUY_PRICE} -> ${f_price})" >>${g_tmp}/output-${tmpfile}
rm -f ${g_tmp}/open-${tmpfile}
rm -f ${g_tmp}/interim-${tmpfile}
fi