more pure bash to speed up things

This commit is contained in:
olli 2023-11-15 17:08:03 +01:00
parent 7eeabb270f
commit 839680820e
2 changed files with 41 additions and 36 deletions

View File

@ -46,7 +46,7 @@ function analyze {
>${g_tmp}/${tmpfile} >${g_tmp}/${tmpfile}
>${g_tmp}/result-${tmpfile} >${g_tmp}/result-${tmpfile}
rm -rf ${g_tmp}/open-${tmpfile} #rm -rf ${g_tmp}/open-${tmpfile}
rm -rf ${g_tmp}/interim-${tmpfile} rm -rf ${g_tmp}/interim-${tmpfile}
rm -rf ${g_tmp}/output-${tmpfile} rm -rf ${g_tmp}/output-${tmpfile}
@ -92,47 +92,50 @@ function analyze {
f_market_performance_before=${f_market_performance} f_market_performance_before=${f_market_performance}
echo "MARKET_PERF=$f_market_performance" echo "MARKET_PERF=$f_market_performance"
if [ -f "${g_tmp}/open-${tmpfile}" ] #if [ -f "${g_tmp}/open-${tmpfile}" ]
if [ -n "${f_open_trade}" ]
then then
if [ "${ANALYZE_VERBOSE}" -eq "0" ] # if [ "${ANALYZE_VERBOSE}" -eq "0" ]
then # then
check_sell_conditions ${g_tmp}/${tmpfile} >>${g_tmp}/output-${tmpfile} # check_sell_conditions ${g_tmp}/${tmpfile} >>${g_tmp}/output-${tmpfile}
else # else
check_sell_conditions ${g_tmp}/${tmpfile} check_sell_conditions ${g_tmp}/${tmpfile}
fi # fi
fi # fi
if ! [ -f "${g_tmp}/open-${tmpfile}" ] # if ! [ -f "${g_tmp}/open-${tmpfile}" ]
then
if [ "${ANALYZE_VERBOSE}" -eq "0" ]
then
check_buy_conditions ${g_tmp}/${tmpfile} >>${g_tmp}/output-${tmpfile}
else else
# then
# if [ "${ANALYZE_VERBOSE}" -eq "0" ]
# then
# check_buy_conditions ${g_tmp}/${tmpfile} >>${g_tmp}/output-${tmpfile}
# else
check_buy_conditions ${g_tmp}/${tmpfile} check_buy_conditions ${g_tmp}/${tmpfile}
fi # fi
fi fi
## Chart Part ## Chart Part
#local f_intrade=0 local f_intrade=0
#local f_score=${f_buy_score} local f_score=${f_buy_score}
#local f_interim="0" local f_interim="0"
#[ -z "${f_buy_score}" ] && f_buy_score=0 [ -z "${f_buy_score}" ] && f_buy_score=0
#if [ -z "${f_sell_score}" ] if [ -z "${f_sell_score}" ]
#then then
# f_sell_score=0 f_sell_score=0
#else else
# f_score=${f_sell_score} f_score=${f_sell_score}
# f_intrade=1 f_intrade=1
# if [ -s ${g_tmp}/interim-${tmpfile} ] if [ -s ${g_tmp}/interim-${tmpfile} ]
# then then
# f_interim=$(tail -n1 ${g_tmp}/interim-${tmpfile}) f_interim=$(tail -n1 ${g_tmp}/interim-${tmpfile})
# f_interim=$(g_calc "${f_interim}-${FEE}") f_interim=$(g_calc "${f_interim}-${FEE}")
# fi fi
#fi fi
#echo "$f_line,${f_market_performance},${f_score},${f_buy_score},${f_sell_score},${f_intrade},${f_interim}" >>analyze-${analyzedate}/chart-${tmpfile} echo "$f_line,${f_market_performance},${f_score},${f_buy_score},${f_sell_score},${f_intrade},${f_interim}" >>analyze-${analyzedate}/chart-${tmpfile}
# Chart Part End ## Chart Part End
done done
# sell at the end to have a final result. # sell at the end to have a final result.
if [ -f ${g_tmp}/open-${tmpfile} ] #if [ -f ${g_tmp}/open-${tmpfile} ]
if [ -n "${f_open_trade}" ]
then then
f_SELL="SELL ${f_ASSET}: End of file/data" 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 echo "SELL: $(tail -n1 ${g_tmp}/${tmpfile} | cut -d, -f1) === ${f_SELL}" >>${g_tmp}/output-${tmpfile} 2>&1
@ -140,7 +143,8 @@ function analyze {
result=$(g_calc "${result}-${FEE}") result=$(g_calc "${result}-${FEE}")
echo "$result" >>${g_tmp}/result-${tmpfile} echo "$result" >>${g_tmp}/result-${tmpfile}
echo "RESULT: ${result}% (${BUY_PRICE} -> ${f_price})" >>${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}/open-${tmpfile}
unset f_open_trade
rm -f ${g_tmp}/interim-${tmpfile} rm -f ${g_tmp}/interim-${tmpfile}
fi fi

View File

@ -97,7 +97,8 @@ function check_buy_conditions {
echo "BUY: ${f_BUY}" echo "BUY: ${f_BUY}"
#echo "${csv_headline},Marketperformance #echo "${csv_headline},Marketperformance
#${f_last_line}" | cut -d, -f 2-22 | perl -pe 's/([0-9].[0-9][0-9][0-9][0-9][0-9][0-9])[0-9]+/$1/g' | perl -pe 's/((?<=,)|(?<=^)),/ ,/g;' | column -t -s, #${f_last_line}" | cut -d, -f 2-22 | perl -pe 's/([0-9].[0-9][0-9][0-9][0-9][0-9][0-9])[0-9]+/$1/g' | perl -pe 's/((?<=,)|(?<=^)),/ ,/g;' | column -t -s,
echo "${f_echo_prefix}${f_BUY}" >${g_tmp}/open-${tmpfile} f_open_trade=1
#echo "${f_echo_prefix}${f_BUY}" >${g_tmp}/open-${tmpfile}
BUY_PRICE=$f_price BUY_PRICE=$f_price
f_BUY="" f_BUY=""
fi fi