range fix

This commit is contained in:
olli 2023-10-30 16:33:53 +01:00
parent b166582fd3
commit 4d392cac27
3 changed files with 23 additions and 8 deletions

View File

@ -94,7 +94,12 @@ function get_asset {
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}
# range and fibonacci # range and fibonacci
get_range ${f_ASSET_HIST_FILE} if ! get_range ${f_ASSET_HIST_FILE}
then
local f_oldrange=$(tail -n2 ${f_ASSET_HIST_FILE} | head -n1 | cut -d, -f24,25,26,27,28,29,30,31,32,33,34,35)
g_echo_note "Taking old range ${f_oldrange}"
echo -n ",${f_oldrange}" >>$f_ASSET_HIST_FILE
fi
# Calculate EMA 50:36 100:37 200:38 800:39 # Calculate EMA 50:36 100:37 200:38 800:39
local f_calcemanumcolumn local f_calcemanumcolumn

View File

@ -7,11 +7,19 @@ function get_range {
# get histfile # get histfile
local f_hist_file="$1" local f_hist_file="$1"
# Get range from a day 12h before (past day ist the usual range for calculationg Levels / Pivot Point) # Get last days (past day is the usual range for calculationg Levels / Pivot Point) - Should be Tiomezone where most traders on exchange are in
# TODO:Add support for timezone
local f_latest_date=$(tail -n1 ${f_hist_file} | cut -d, -f1) local f_latest_date=$(tail -n1 ${f_hist_file} | cut -d, -f1)
local f_range_to_date=$(date "+%F %H:" --date="${f_latest_date} 12 hours ago") local f_range_day=$(date "+%F " --date="${f_latest_date} yesterday")
local f_range_from_date=$(date "+%F %H:" --date="${f_latest_date} 36 hours ago") local f_range_data=$(grep "^${f_range_day}" ${f_hist_file} | cut -d , -f2 | grep "^[0-9]")
local f_range_data=$(sed -n "/${f_range_from_date}/,/${f_range_to_date}/p" ${f_hist_file} | cut -d , -f2 | grep "^[0-9]")
# Check for new range
local f_last_range_day=$(tail -n1 ${f_hist_file} | cut -d, -f24)
if echo "${f_latest_date}" | grep -q ${f_last_range_day}
then
g_echo_note "${FUNCNAME} $@: No new range"
return 1
fi
if [ -n "${f_range_data}" ] if [ -n "${f_range_data}" ]
then then
@ -36,11 +44,13 @@ function get_range {
local f_support3=$(echo "scale=8; ${f_pivot_point}-((${f_highest_in_range}-${f_lowest_in_range})*1)" | bc | sed 's/^\./0./;' ) local f_support3=$(echo "scale=8; ${f_pivot_point}-((${f_highest_in_range}-${f_lowest_in_range})*1)" | bc | sed 's/^\./0./;' )
local f_resist3=$(echo "scale=8; ${f_pivot_point}+((${f_highest_in_range}-${f_lowest_in_range})*1)" | bc | sed 's/^\./0./;' ) local f_resist3=$(echo "scale=8; ${f_pivot_point}+((${f_highest_in_range}-${f_lowest_in_range})*1)" | bc | sed 's/^\./0./;' )
else else
g_echo_note "Not enough data for calculating range" g_echo_note "${FUNCNAME} $@: Not enough data for calculating range"
return 1
fi fi
# write down in history # write down in history
echo -n ",${f_range_periods},${f_lowest_in_range},${f_highest_in_range},${f_pivot_point},${f_support1},${f_resist1},${f_golden_pocket_support},${f_golden_pocket_resist},${f_golden_pocket65_support},${f_golden_pocket65_resist},${f_support3},${f_resist3}" >>"${f_hist_file}" echo -n ",${f_range_day},${f_lowest_in_range},${f_highest_in_range},${f_pivot_point},${f_support1},${f_resist1},${f_golden_pocket_support},${f_golden_pocket_resist},${f_golden_pocket65_support},${f_golden_pocket65_resist},${f_support3},${f_resist3}" >>"${f_hist_file}"
return 0
} }

View File

@ -266,7 +266,7 @@ function webpage {
</tr><tr><td colspan='4'>" >>../index.html.tmp </tr><tr><td colspan='4'>" >>../index.html.tmp
echo "<details><summary>${asset} Charts</summary>" >>../index.html.tmp echo "<details><summary>${asset} Charts</summary>" >>../index.html.tmp
echo "Price, EMA, Levels" >>../index.html.tmp echo "Price, EMA, Levels" >>../index.html.tmp
genchart asset-histories/${asset}.history.csv 50 2,25,26,27,28,29,30,31,32,33,34,35,4,36,37,38,39 green,DarkSlateGrey,DarkSlateGrey,Gold,DarkOrange,DarkOrange,GoldenRod,GoldenRod,GoldenRod,GoldenRod,DarkOrange,DarkOrange,MidnightBlue,Indigo,DarkSlateBlue,DodgerBlue,DeepSkyBlue >>../index.html.tmp genchart asset-histories/${asset}.history.csv 50 2,25,26,27,28,29,30,31,32,33,34,35,5,36,37,38 green,DarkSlateGrey,DarkSlateGrey,Gold,DarkOrange,DarkOrange,GoldenRod,GoldenRod,GoldenRod,GoldenRod,DarkOrange,DarkOrange,MidnightBlue,Indigo,DarkSlateBlue,DodgerBlue,DeepSkyBlue >>../index.html.tmp
echo "MACD" >>../index.html.tmp echo "MACD" >>../index.html.tmp
genchart asset-histories/${asset}.history.csv 50 8,6,7 >>../index.html.tmp genchart asset-histories/${asset}.history.csv 50 8,6,7 >>../index.html.tmp
echo "RSIs" >>../index.html.tmp echo "RSIs" >>../index.html.tmp