no subshells for calculation

This commit is contained in:
olli 2023-11-26 17:18:01 +01:00
parent eb520626cb
commit db7ba20416
13 changed files with 63 additions and 61 deletions

View File

@ -22,8 +22,6 @@ function g_echo_note {
function analyze { function analyze {
set -x
local file=$1 local file=$1
tmpfile=$(basename "${file}") tmpfile=$(basename "${file}")
@ -131,7 +129,8 @@ function analyze {
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}") g_calc "${f_interim}-${FEE}"
f_interim=${g_calc_result}
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}
@ -144,8 +143,10 @@ function analyze {
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
result=$(g_percentage-diff ${BUY_PRICE} ${f_price}) g_percentage-diff ${BUY_PRICE} ${f_price}
result=$(g_calc "${result}-${FEE}") #result=$(g_percentage-diff ${BUY_PRICE} ${f_price})
g_calc "${g_percentage_diff_result}-${FEE}"
result=${g_calc_result}
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}
@ -156,10 +157,12 @@ function analyze {
complete_result=0 complete_result=0
for result in $(cat ${g_tmp}/result-${tmpfile}) for result in $(cat ${g_tmp}/result-${tmpfile})
do do
complete_result=$(g_calc "$complete_result+$result" | xargs printf "%.2f") g_calc "$complete_result+$result"
complete_result=$(echo ${g_calc_result} | xargs printf "%.2f")
done done
hodlresult=$(g_percentage-diff $(egrep "^${ANALYZE_TIME}" "$file" | grep -v ',,' | head -n1 | cut -d, -f2) $(egrep "^${ANALYZE_TIME}" "$file" | grep -v ',,' | tail -n1 | cut -d, -f2)) g_percentage-diff $(egrep "^${ANALYZE_TIME}" "$file" | grep -v ',,' | head -n1 | cut -d, -f2) $(egrep "^${ANALYZE_TIME}" "$file" | grep -v ',,' | tail -n1 | cut -d, -f2)
hodlresult=${g_percentage_diff_result}
echo "COMPLETE:RESULT:$(basename "$file" | cut -d. -f1):: ${complete_result}% HODL:${hodlresult}% analyze-${analyzedate}/${tmpfile}.log $file" | perl -pe 's/ /\t/g; s/:/ /g' | tee -a ${g_tmp}/output-${tmpfile} echo "COMPLETE:RESULT:$(basename "$file" | cut -d. -f1):: ${complete_result}% HODL:${hodlresult}% analyze-${analyzedate}/${tmpfile}.log $file" | perl -pe 's/ /\t/g; s/:/ /g' | tee -a ${g_tmp}/output-${tmpfile}
echo "=====================================" >>${g_tmp}/output-${tmpfile} echo "=====================================" >>${g_tmp}/output-${tmpfile}

View File

@ -49,7 +49,8 @@ ${FUNCNAME} $@"
cat ${g_tmp}/API_CMD_OUT >${f_CMDFILE}_QUOTE_OUT cat ${g_tmp}/API_CMD_OUT >${f_CMDFILE}_QUOTE_OUT
# get convert price # get convert price
local f_convert_price=$(cat ${f_CMDFILE}_QUOTE_OUT | grep '^{' | jq -r .inverseRatio | head -n1) local f_convert_price=$(cat ${f_CMDFILE}_QUOTE_OUT | grep '^{' | jq -r .inverseRatio | head -n1)
local f_price_diff=$(g_percentage-diff ${f_market_price} ${f_convert_price}) g_percentage-diff ${f_market_price} ${f_convert_price}
local f_price_diff=${g_percentage_diff_result}
fi fi
if [ "${f_ACTION}" = "sell" ] if [ "${f_ACTION}" = "sell" ]
@ -59,7 +60,8 @@ ${FUNCNAME} $@"
cat ${g_tmp}/API_CMD_OUT >${f_CMDFILE}_QUOTE_OUT cat ${g_tmp}/API_CMD_OUT >${f_CMDFILE}_QUOTE_OUT
# get convert price # get convert price
local f_convert_price=$(cat ${f_CMDFILE}_QUOTE_OUT | grep '^{' | jq -r .ratio | head -n1) local f_convert_price=$(cat ${f_CMDFILE}_QUOTE_OUT | grep '^{' | jq -r .ratio | head -n1)
local f_price_diff=$(g_percentage-diff ${f_convert_price} ${f_market_price}) g_percentage-diff ${f_convert_price} ${f_market_price}
local f_price_diff=${g_percentage_diff_result}
fi fi
if [ $(echo "${f_price_diff} > ${FEE}" | bc -l) -eq 1 ] if [ $(echo "${f_price_diff} > ${FEE}" | bc -l) -eq 1 ]

View File

@ -59,7 +59,8 @@ function check_buy_conditions {
g_echo_note "${f_BUY}" g_echo_note "${f_BUY}"
# calculate quantity from balance for potentially invest # calculate quantity from balance for potentially invest
local f_INVEST_QUANTITY=$(g_calc "scale=2; ${CURRENCY_BALANCE}/100*${INVEST}" | cut -d\. -f1) g_calc "scale=2; ${CURRENCY_BALANCE}/100*${INVEST}"
local f_INVEST_QUANTITY=$(echo "${g_calc_result}" | cut -d\. -f1)
g_echo_note "BUY current investment quantity is ${f_INVEST_QUANTITY} ${CURRENCY}" g_echo_note "BUY current investment quantity is ${f_INVEST_QUANTITY} ${CURRENCY}"
# remove CURRENCY from asset # remove CURRENCY from asset
@ -72,17 +73,25 @@ function check_buy_conditions {
# use MIN_NOTIONAL+5% as INVEST_QUANTITY if INVEST_QUANTITY is under MIN_NOTIONAL # use MIN_NOTIONAL+5% as INVEST_QUANTITY if INVEST_QUANTITY is under MIN_NOTIONAL
# +5% in spite of MIN_NOTIONAL to be able to sell when the price falls a little bit # +5% in spite of MIN_NOTIONAL to be able to sell when the price falls a little bit
[ $(g_calc "${f_INVEST_QUANTITY} < ${f_MIN_NOTIONAL}") -eq 0 ] || f_INVEST_QUANTITY=$(g_calc "scale=2; $f_MIN_NOTIONAL/100*105") #[ $(g_calc "${f_INVEST_QUANTITY} < ${f_MIN_NOTIONAL}") -eq 0 ] || f_INVEST_QUANTITY=$(g_calc "scale=2; $f_MIN_NOTIONAL/100*105")
if ! g_num_is_lower.sh ${f_INVEST_QUANTITY} ${f_MIN_NOTIONAL}
then
g_calc "scale=2; ${f_MIN_NOTIONAL}/100*105"
f_INVEST_QUANTITY=${g_calc_result}
fi
# if there is not enough balance for buying because ${f_MIN_NOTIONAL} needed for buying to sell (workaround) # if there is not enough balance for buying because ${f_MIN_NOTIONAL} needed for buying to sell (workaround)
if [ $(g_calc "${CURRENCY_BALANCE} < ${f_MIN_NOTIONAL}*2") -ne 0 ] g_calc "${CURRENCY_BALANCE} < ${f_MIN_NOTIONAL}*2"
if [ ${g_calc_result} -ne 0 ]
then then
g_echo_note "BUY ${f_ASSET} not enough balance ${CURRENCY_BALANCE} for buying because of MIN_NOTIONAL (${f_MIN_NOTIONAL}*2) needed for buying-to-sell (workaround)" g_echo_note "BUY ${f_ASSET} not enough balance ${CURRENCY_BALANCE} for buying because of MIN_NOTIONAL (${f_MIN_NOTIONAL}*2) needed for buying-to-sell (workaround)"
return 1 return 1
fi fi
# continue if not balance enough for lowest quantity (MIN_NOTIONAL) # continue if not balance enough for lowest quantity (MIN_NOTIONAL)
if [ $(g_calc "${CURRENCY_BALANCE} > ${f_INVEST_QUANTITY}") -eq 0 ] g_calc "${CURRENCY_BALANCE} > ${f_INVEST_QUANTITY}"
if [ ${g_calc_result} -eq 0 ]
then then
g_echo_note "BUY ${f_ASSET} not enough balance (${CURRENCY_BALANCE}) for lowest quantity (MIN_NOTIONAL - ${f_INVEST_QUANTITY})" g_echo_note "BUY ${f_ASSET} not enough balance (${CURRENCY_BALANCE}) for lowest quantity (MIN_NOTIONAL - ${f_INVEST_QUANTITY})"
return 1 return 1

View File

@ -35,10 +35,12 @@ function check_sell_conditions {
fi fi
# result values (sould be reduced to one - f_result!?) # result values (sould be reduced to one - f_result!?)
f_result=$(g_percentage-diff ${f_BUY_PRICE} ${f_price}) g_percentage-diff ${f_BUY_PRICE} ${f_price}
f_result=${g_percentage_diff_result}
f_BUY_PRICE_LAST_RATE_DIFF=${f_result} f_BUY_PRICE_LAST_RATE_DIFF=${f_result}
result=${f_BUY_PRICE_LAST_RATE_DIFF} result=${f_BUY_PRICE_LAST_RATE_DIFF}
f_real_result=$(g_calc "${f_result}-${FEE}") g_calc "${f_result}-${FEE}"
f_real_result=${g_calc_result}
# analyze # analyze
[ -z "${BOT}" ] && echo "INTERIM RESULT: ${f_real_result}%" [ -z "${BOT}" ] && echo "INTERIM RESULT: ${f_real_result}%"
@ -104,9 +106,10 @@ function check_sell_conditions {
# echo "${csv_headline},Marketperformace # echo "${csv_headline},Marketperformace
#${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_SELL}" # echo "${f_SELL}"
#result=$(g_percentage-diff ${BUY_PRICE} ${current}) g_percentage-diff ${BUY_PRICE} ${f_price}
result=$(g_percentage-diff ${BUY_PRICE} ${f_price}) #result=${g_percentage_diff_result}
result=$(g_calc "${result}-${FEE}") g_calc "${g_percentage_diff_result}-${FEE}"
result=${g_calc_result}
echo "${result}" >>${g_tmp}/result-${tmpfile} echo "${result}" >>${g_tmp}/result-${tmpfile}
rm -f "${f_TRADE_HIST_FILE}" rm -f "${f_TRADE_HIST_FILE}"
rm -f "${f_TRADE_HIST_FILE_INTERIM}" rm -f "${f_TRADE_HIST_FILE_INTERIM}"

View File

@ -67,7 +67,8 @@ function get_asset {
if echo $f_last_price | grep -q "^[0-9]" if echo $f_last_price | grep -q "^[0-9]"
then then
f_price=$(tail -n1 ${f_ASSET_HIST_FILE} | cut -d, -f2) f_price=$(tail -n1 ${f_ASSET_HIST_FILE} | cut -d, -f2)
local f_price_change=$(g_percentage-diff ${f_last_price} ${f_price}) g_percentage-diff ${f_last_price} ${f_price}
local f_price_change=${g_percentage_diff_result}
else else
local f_price_change="" local f_price_change=""
fi fi

View File

@ -109,7 +109,10 @@ function get_macd_indicator {
if [ $(tail -n36 "${f_hist_file}" | wc -l) -ge 35 ] if [ $(tail -n36 "${f_hist_file}" | wc -l) -ge 35 ]
then then
local f_macd_histogram_max=$(tail -n350 "${f_hist_file}" | cut -d"," -f8 | egrep "^[0-9]|^-[0-9]" | sed 's/^-//' | sort -n | tail -n1) local f_macd_histogram_max=$(tail -n350 "${f_hist_file}" | cut -d"," -f8 | egrep "^[0-9]|^-[0-9]" | sed 's/^-//' | sort -n | tail -n1)
local f_macd_histogram_relation=$(echo "100+$(g_percentage-diff ${f_macd_histogram_max} ${f_macd_histogram})" | bc | sed 's/^\./0./; s/^-\./-0./' | cut -d\. -f1) g_percentage-diff ${f_macd_histogram_max} ${f_macd_histogram}
#local f_macd_histogram_relation=$(echo "100+$(g_percentage-diff ${f_macd_histogram_max} ${f_macd_histogram})" | bc | sed 's/^\./0./; s/^-\./-0./' | cut -d\. -f1)
g_calc "100+${g_percentage_diff_result}"
local f_macd_histogram_relation=${g_calc_result}
fi fi
echo -n ",${f_macd_histogram_relation}|${f_macd_signal}" >>"${f_hist_file}" echo -n ",${f_macd_histogram_relation}|${f_macd_signal}" >>"${f_hist_file}"

View File

@ -20,28 +20,6 @@ function get_rsi_indicator {
return 0 return 0
fi fi
# for f_price in $(tail -n${f_period} "${f_hist_file}" | cut -d"," -f2)
# do
# # not for the first line because a comparative value is missing
# if [ -z "${f_last_price}" ]
# then
# f_last_price=${f_price}
# continue
# fi
#
# # calculate each change
# local f_price_change=$(g_percentage-diff ${f_last_price} ${f_price})
# f_last_price=${f_price}
#
# # add positive/negative changes
# if echo "${f_price_change}" | grep -q '^-'
# then
# f_negative_sum=$(echo "${f_negative_sum}+${f_price_change}" | bc -l)
# else
# f_positive_sum=$(echo "${f_positive_sum}+${f_price_change}" | bc -l)
# fi
# done
f_positive_sum=$(tail -n${f_period} "${f_hist_file}" | cut -d"," -f3 | grep "^[0-9]" | awk "{ SUM += \$1} END { printf(\"%10.10f\", SUM/${f_period}) }") f_positive_sum=$(tail -n${f_period} "${f_hist_file}" | cut -d"," -f3 | grep "^[0-9]" | awk "{ SUM += \$1} END { printf(\"%10.10f\", SUM/${f_period}) }")
f_negative_sum=$(tail -n${f_period} "${f_hist_file}" | cut -d"," -f3 | grep "^-[0-9]" | awk "{ SUM += \$1} END { printf(\"%10.10f\", SUM/${f_period}) }") f_negative_sum=$(tail -n${f_period} "${f_hist_file}" | cut -d"," -f3 | grep "^-[0-9]" | awk "{ SUM += \$1} END { printf(\"%10.10f\", SUM/${f_period}) }")

View File

@ -45,7 +45,8 @@ function get_vars_from_csv {
get_var_from_line price_change 3 get_var_from_line price_change 3
# Check for price trend last 4 iterations # Check for price trend last 4 iterations
f_last_4_prices_change=$(g_percentage-diff ${f_4_last_line_array[2]} ${f_price}) g_percentage-diff ${f_4_last_line_array[2]} ${f_price}
f_last_4_prices_change=${g_percentage_diff_result}
if g_num_is_higher ${f_last_4_prices_change} 0 if g_num_is_higher ${f_last_4_prices_change} 0
then then

View File

@ -28,7 +28,8 @@ function market_performance {
g_echo_warn "Didn't get correct forecast from $f_url" g_echo_warn "Didn't get correct forecast from $f_url"
return 1 return 1
fi fi
local f_btc_forecast=$(g_percentage-diff ${f_today} ${f_forecast}) g_percentage-diff ${f_today} ${f_forecast}
local f_btc_forecast=${g_percentage_diff_result}
echo $f_btc_forecast | egrep -q '[0-9]\.[0-9]' || return 1 echo $f_btc_forecast | egrep -q '[0-9]\.[0-9]' || return 1
g_echo_note "BTC forecast: $f_btc_forecast" g_echo_note "BTC forecast: $f_btc_forecast"
f_btc_forecast=$(echo "scale=2; ${f_btc_forecast}/3" | bc -l | sed -r 's/^(-?)\./\10./') f_btc_forecast=$(echo "scale=2; ${f_btc_forecast}/3" | bc -l | sed -r 's/^(-?)\./\10./')
@ -53,7 +54,8 @@ function market_performance {
g_echo_warn "Didn't get correct forecast from $f_url" g_echo_warn "Didn't get correct forecast from $f_url"
return 1 return 1
fi fi
local f_eth_forecast=$(g_percentage-diff ${f_today} ${f_forecast}) g_percentage-diff ${f_today} ${f_forecast}
local f_eth_forecast=${g_percentage_diff_result}
echo $f_eth_forecast | egrep -q '[0-9]\.[0-9]' || return 1 echo $f_eth_forecast | egrep -q '[0-9]\.[0-9]' || return 1
g_echo_note "ETH forecast: $f_eth_forecast" g_echo_note "ETH forecast: $f_eth_forecast"
f_eth_forecast=$(echo "scale=2; ${f_eth_forecast}/3" | bc -l | sed -r 's/^(-?)\./\10./') f_eth_forecast=$(echo "scale=2; ${f_eth_forecast}/3" | bc -l | sed -r 's/^(-?)\./\10./')
@ -82,7 +84,8 @@ function market_performance {
local f_index_performance="-0.1" local f_index_performance="-0.1"
else else
# calculate performance # calculate performance
local f_index_performance=$(g_percentage-diff ${f_from} ${f_to}) g_percentage-diff ${f_from} ${f_to}
local f_index_performance=${g_percentage_diff_result}
fi fi
# if growing is bad for krypto - invert # if growing is bad for krypto - invert
if echo ${f_INDEX} | grep -q INVERTED if echo ${f_INDEX} | grep -q INVERTED
@ -133,17 +136,9 @@ function market_performance {
done done
# price performance bitcoin # price performance bitcoin
#local f_from=$(tail -n 48 asset-histories/BTC${CURRENCY}.history.csv | head -n 24 | cut -d, -f2 | awk '{ sum += $1; n++ } END { if (n > 0) print sum / n; }')
#local f_to=$(tail -n 24 asset-histories/BTC${CURRENCY}.history.csv | cut -d, -f2 | awk '{ sum += $1; n++ } END { if (n > 0) print sum / n; }')
#local f_exchange_rate_diff_percentage=$(g_percentage-diff ${f_from} ${f_to})
#local f_btc_performance=${f_exchange_rate_diff_percentage}
local f_btc_performance=$(jq -r '.[] |select(.symbol=="btc")|(.price_change_percentage_7d_in_currency)' COINGECKO_GET_ASSETS_CMD_OUT) local f_btc_performance=$(jq -r '.[] |select(.symbol=="btc")|(.price_change_percentage_7d_in_currency)' COINGECKO_GET_ASSETS_CMD_OUT)
# price performance ethereum # price performance ethereum
#local f_from=$(tail -n 48 asset-histories/ETH${CURRENCY}.history.csv | head -n 24 | cut -d, -f2 | awk '{ sum += $1; n++ } END { if (n > 0) print sum / n; }')
#local f_to=$(tail -n 24 asset-histories/ETH${CURRENCY}.history.csv | cut -d, -f2 | awk '{ sum += $1; n++ } END { if (n > 0) print sum / n; }')
#local f_exchange_rate_diff_percentage=$(g_percentage-diff ${f_from} ${f_to})
#local f_eth_performance=${f_exchange_rate_diff_percentage}
local f_eth_performance=$(jq -r '.[] |select(.symbol=="eth")|(.price_change_percentage_7d_in_currency)' COINGECKO_GET_ASSETS_CMD_OUT) local f_eth_performance=$(jq -r '.[] |select(.symbol=="eth")|(.price_change_percentage_7d_in_currency)' COINGECKO_GET_ASSETS_CMD_OUT)
# hourly price performance over TOP 250 marketcap by coingecko # hourly price performance over TOP 250 marketcap by coingecko

View File

@ -1,6 +1,7 @@
function score { function score {
#s_score=$((s_score${1})) #s_score=$((s_score${1}))
s_score=$(g_calc "${s_score} + ${1}") g_calc "${s_score} + ${1}"
s_score=${g_calc_result}
#echo " SCORE: s_score=${s_score} ($1) $2" #echo " SCORE: s_score=${s_score} ($1) $2"
s_score_hist="${s_score_hist} s_score_hist="${s_score_hist}
s_score=${s_score} (${1}) ${2}" s_score=${s_score} (${1}) ${2}"

View File

@ -203,7 +203,8 @@ function webpage {
local f_profit=$(cat "${f_trade_file}.result") local f_profit=$(cat "${f_trade_file}.result")
f_price="${f_price} ( ${f_profit}%)" f_price="${f_price} ( ${f_profit}%)"
else else
local f_profit=$(g_percentage-diff $(cat ${g_tmp}/buyprice) ${f_price}) g_percentage-diff $(cat ${g_tmp}/buyprice) ${f_price}
local f_profit=${g_percentage_diff_result}
f_price="${f_price} ( ${f_profit}%)" f_price="${f_price} ( ${f_profit}%)"
echo "${f_profit}" >"${f_trade_file}.result" echo "${f_profit}" >"${f_trade_file}.result"
fi fi

View File

@ -32,7 +32,8 @@ function get_asset {
if echo $f_last_price | grep -q "^[0-9]" if echo $f_last_price | grep -q "^[0-9]"
then then
local f_price=$(tail -n1 ${f_ASSET_HIST_FILE} | cut -d, -f2) local f_price=$(tail -n1 ${f_ASSET_HIST_FILE} | cut -d, -f2)
local f_price_change=$(g_percentage-diff ${f_last_price} ${f_price}) g_percentage-diff ${f_last_price} ${f_price}
local f_price_change=${g_percentage_diff_result}
else else
local f_price_change="" local f_price_change=""
fi fi

View File

@ -47,24 +47,28 @@ function get_asset {
price30before=$(grep "^$timebefore" "$rawhistfile" | cut -d, -f2) price30before=$(grep "^$timebefore" "$rawhistfile" | cut -d, -f2)
[ -z "$price30before" ] && continue [ -z "$price30before" ] && continue
local price=$(echo ${f_line} | cut -d, -f2) local price=$(echo ${f_line} | cut -d, -f2)
change30before=$(g_percentage-diff $price30before $price) g_percentage-diff $price30before $price
change30before=${g_percentage_diff_result}
#echo "XXXXXXX g_percentage-diff $price30before $price -> $change30before " #echo "XXXXXXX g_percentage-diff $price30before $price -> $change30before "
timebefore=$(date "+%Y-%m-%d %H:%M" -d "$time 14 day ago") timebefore=$(date "+%Y-%m-%d %H:%M" -d "$time 14 day ago")
price14before=$(grep "^$timebefore" "$rawhistfile" | cut -d, -f2) price14before=$(grep "^$timebefore" "$rawhistfile" | cut -d, -f2)
[ -z "$price14before" ] && continue [ -z "$price14before" ] && continue
change14before=$(g_percentage-diff $price14before $price) g_percentage-diff $price14before $price
change14before=${g_percentage_diff_result}
timebefore=$(date "+%Y-%m-%d %H:%M" -d "$time 7 day ago") timebefore=$(date "+%Y-%m-%d %H:%M" -d "$time 7 day ago")
price7before=$(grep "^$timebefore" "$rawhistfile" | cut -d, -f2) price7before=$(grep "^$timebefore" "$rawhistfile" | cut -d, -f2)
[ -z "$price7before" ] && continue [ -z "$price7before" ] && continue
change7before=$(g_percentage-diff $price7before $price) g_percentage-diff $price7before $price
change7before=${g_percentage_diff_result}
timebefore=$(date "+%Y-%m-%d %H:%M" -d "$time 1 day ago") timebefore=$(date "+%Y-%m-%d %H:%M" -d "$time 1 day ago")
price1before=$(grep "^$timebefore" "$rawhistfile" | cut -d, -f2) price1before=$(grep "^$timebefore" "$rawhistfile" | cut -d, -f2)
[ -z "$price1before" ] && continue [ -z "$price1before" ] && continue
change1before=$(g_percentage-diff $price1before $price) g_percentage-diff $price1before $price
change1before=${g_percentage_diff_result}
#echo "$f_line -- $change1before,$change7before,$change14before,$change30before" #echo "$f_line -- $change1before,$change7before,$change14before,$change30before"