more pure bash to speed up things

This commit is contained in:
olli 2023-11-12 14:36:33 +01:00
parent d7e4231f76
commit af22be8875

View File

@ -23,7 +23,6 @@ function analyze {
local file=$1
tmpfile=$(basename "${file}")
. /etc/bash/gaboshlib.include
g_tmp="$2"
#for bashfunc in $(find /etc/bash/gaboshlib -type f -name "g_*.bashfunc" -o -name "g_*.sh")
@ -58,7 +57,15 @@ function analyze {
echo "$(head -n1 ${file}),Market Perrormance,Score,Buy Score,Sell Score,InTrade,Inetrim Result" >analyze-${analyzedate}/chart-${tmpfile}
# Chart Part End
#for line in $(egrep "^${ANALYZE_TIME}" "$file" | grep -v ',,')
# create market performance array of timeframe
for f_market_perf_line in $(cat data/botdata/MARKET_PERFORMANCE.csv | cut -d, -f1,2 | sed 's/:[0-9][0-9],/,/; s/ /-/g; s/:/-/g')
do
f_market_perf_date=${f_market_perf_line%,*}
f_market_perf_date=${f_market_perf_date//[^0-9]/}
f_market_perf=${f_market_perf_line#*,}
f_market_performace_array[${f_market_perf_date}]=${f_market_perf}
done
local f_lines
mapfile -t f_lines <<<$(egrep "^${ANALYZE_TIME}" "$file" | grep -v ',,')
for line in "${f_lines[@]}"
@ -67,7 +74,10 @@ function analyze {
f_buy_score=""
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/ *//')
#f_market_performance=$(grep "^$time" data/botdata/MARKET_PERFORMANCE | tail -n1 | cut -d: -f4 | cut -d"%" -f1 | sed 's/ *//')
time=${time//[^0-9]/}
f_market_performance=${f_market_performace_array[${time}]}
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}
if [ -f "${g_tmp}/open-${tmpfile}" ]
@ -114,11 +124,9 @@ 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} ${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} -> ${f_price})" >>${g_tmp}/output-${tmpfile}
rm -f ${g_tmp}/open-${tmpfile}
rm -f ${g_tmp}/interim-${tmpfile}