new chart data and global timestamp
This commit is contained in:
parent
dbca1683fb
commit
1e8a95bac7
@ -5,6 +5,15 @@ function get_asset {
|
||||
|
||||
# write asset hist file with macd and rsi
|
||||
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}"
|
||||
if ! grep -q "^$(echo "${f_timestamp}" | cut -d: -f1,2)" "${f_ASSET_HIST_FILE}"
|
||||
then
|
||||
@ -32,18 +41,23 @@ function get_asset {
|
||||
fi
|
||||
|
||||
f_ASSET_HIST_FILE="asset-histories/${f_ASSET}.history.csv"
|
||||
if [ ${f_linecount} -lt 30 ] && [ ${f_lines} -ge 50 ] && [ ${INTERVAL} -lt 300 ]
|
||||
then
|
||||
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:"
|
||||
then
|
||||
return 0
|
||||
fi
|
||||
fi
|
||||
#if [ ${f_linecount} -lt 30 ] && [ ${f_lines} -ge 50 ] && [ ${INTERVAL} -lt 300 ]
|
||||
#then
|
||||
# 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:"
|
||||
# then
|
||||
# return 0
|
||||
# fi
|
||||
#fi
|
||||
|
||||
# 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
|
||||
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}\")|\"\\(.market_cap_change_percentage_24h)\"" COINGECKO_GET_ASSETS_CMD_OUT) >>${f_ASSET_HIST_FILE}
|
||||
|
||||
# Calculate Fibonacci-Retracement
|
||||
# last 60 timeframes (a day on hourly)
|
||||
get_fibonacci_indicator ${f_ASSET_HIST_FILE} 60
|
||||
# last 168 timeframes (a week on hourly)
|
||||
get_fibonacci_indicator ${f_ASSET_HIST_FILE} 168
|
||||
# last 672 timeframes (a month on hourly)
|
||||
get_fibonacci_indicator ${f_ASSET_HIST_FILE} 672
|
||||
# last 8064 timeframes (a year on hourly)
|
||||
get_fibonacci_indicator ${f_ASSET_HIST_FILE} 8064
|
||||
# range and fibonacci
|
||||
get_range ${f_ASSET_HIST_FILE}
|
||||
|
||||
# Calculate EMA 50:36 100:37 200:38 800:39
|
||||
local f_calcemanumcolumn
|
||||
for f_calcemanumcolumn in 50:36 100:37 200:38 800:39
|
||||
do
|
||||
local f_calcema=$(echo ${f_calcemanumcolumn} | cut -d: -f1)
|
||||
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
|
||||
echo "" >>${f_ASSET_HIST_FILE}
|
||||
|
Loading…
Reference in New Issue
Block a user