new chart data and global timestamp

This commit is contained in:
olli 2023-10-20 17:39:19 +02:00
parent dbca1683fb
commit 1e8a95bac7

View File

@ -5,6 +5,15 @@ function get_asset {
# write asset hist file with macd and rsi # write asset hist file with macd and rsi
local f_ASSET_HIST_FILE="asset-histories/${f_ASSET}.history-raw.csv" local f_ASSET_HIST_FILE="asset-histories/${f_ASSET}.history-raw.csv"
if find "${f_ASSET_HIST_FILE}" -mmin -${INTERVAL_MIN} | grep -q "${f_ASSET_HIST_FILE}"
then
g_echo_note "${f_ASSET_HIST_FILE} already downloaded in the last ${INTERVAL_MIN} minutes"
return 0
fi
[ -f "${f_ASSET_HIST_FILE}" ] || echo "Date and Time,Price" >"${f_ASSET_HIST_FILE}" [ -f "${f_ASSET_HIST_FILE}" ] || echo "Date and Time,Price" >"${f_ASSET_HIST_FILE}"
if ! grep -q "^$(echo "${f_timestamp}" | cut -d: -f1,2)" "${f_ASSET_HIST_FILE}" if ! grep -q "^$(echo "${f_timestamp}" | cut -d: -f1,2)" "${f_ASSET_HIST_FILE}"
then then
@ -32,18 +41,23 @@ function get_asset {
fi fi
f_ASSET_HIST_FILE="asset-histories/${f_ASSET}.history.csv" f_ASSET_HIST_FILE="asset-histories/${f_ASSET}.history.csv"
if [ ${f_linecount} -lt 30 ] && [ ${f_lines} -ge 50 ] && [ ${INTERVAL} -lt 300 ] #if [ ${f_linecount} -lt 30 ] && [ ${f_lines} -ge 50 ] && [ ${INTERVAL} -lt 300 ]
then #then
g_echo_note "${f_ASSET_HIST_FILE}: set price to 5 minute period" # g_echo_note "${f_ASSET_HIST_FILE}: set price to 5 minute period"
if ! echo "${f_timestamp}" | egrep -q ":[0-5]0:|:[0-5]5:" # if ! echo "${f_timestamp}" | egrep -q ":[0-5]0:|:[0-5]5:"
then # then
return 0 # return 0
fi # fi
fi #fi
# headline # headline
[ -s "${f_ASSET_HIST_FILE}" ] || echo "${csv_headline}" >"${f_ASSET_HIST_FILE}" #[ -s "${f_ASSET_HIST_FILE}" ] || echo "${csv_headline}" >"${f_ASSET_HIST_FILE}"
if [ -s "${f_ASSET_HIST_FILE}" ]
then
sed -i -e 1c"$csv_headline" "${f_ASSET_HIST_FILE}"
else
echo "$csv_headline" >"${f_ASSET_HIST_FILE}"
fi
# date and price # date and price
echo -n "${f_line}" >>${f_ASSET_HIST_FILE} echo -n "${f_line}" >>${f_ASSET_HIST_FILE}
@ -79,15 +93,24 @@ function get_asset {
echo -n ,$(jq -r ".[] |select(.symbol==\"${f_asset}\")|\"\\(.price_change_percentage_1y_in_currency)\"" COINGECKO_GET_ASSETS_CMD_OUT) >>${f_ASSET_HIST_FILE} echo -n ,$(jq -r ".[] |select(.symbol==\"${f_asset}\")|\"\\(.price_change_percentage_1y_in_currency)\"" COINGECKO_GET_ASSETS_CMD_OUT) >>${f_ASSET_HIST_FILE}
echo -n ,$(jq -r ".[] |select(.symbol==\"${f_asset}\")|\"\\(.market_cap_change_percentage_24h)\"" COINGECKO_GET_ASSETS_CMD_OUT) >>${f_ASSET_HIST_FILE} echo -n ,$(jq -r ".[] |select(.symbol==\"${f_asset}\")|\"\\(.market_cap_change_percentage_24h)\"" COINGECKO_GET_ASSETS_CMD_OUT) >>${f_ASSET_HIST_FILE}
# Calculate Fibonacci-Retracement # range and fibonacci
# last 60 timeframes (a day on hourly) get_range ${f_ASSET_HIST_FILE}
get_fibonacci_indicator ${f_ASSET_HIST_FILE} 60
# last 168 timeframes (a week on hourly) # Calculate EMA 50:36 100:37 200:38 800:39
get_fibonacci_indicator ${f_ASSET_HIST_FILE} 168 local f_calcemanumcolumn
# last 672 timeframes (a month on hourly) for f_calcemanumcolumn in 50:36 100:37 200:38 800:39
get_fibonacci_indicator ${f_ASSET_HIST_FILE} 672 do
# last 8064 timeframes (a year on hourly) local f_calcema=$(echo ${f_calcemanumcolumn} | cut -d: -f1)
get_fibonacci_indicator ${f_ASSET_HIST_FILE} 8064 local f_caclemacolumn=$(echo ${f_calcemanumcolumn} | cut -d: -f2)
get_ema "${f_ASSET_HIST_FILE}" 2 ${f_calcema} "$(tail -n2 "${f_ASSET_HIST_FILE}" | head -n1 | grep ^2 | cut -d, -f${f_caclemacolumn})" "${f_price}"
if [ -z "${f_ema}" ]
then
g_echo_note "${FUNCNAME} $@: Not enough data for calculating EMA - waiting for more values"
echo -n "," >>"${f_ASSET_HIST_FILE}"
else
echo -n ",${f_ema}" >>"${f_ASSET_HIST_FILE}"
fi
done
# end with newline # end with newline
echo "" >>${f_ASSET_HIST_FILE} echo "" >>${f_ASSET_HIST_FILE}