added fibonacci retracements; added coingecko 1y price change and 24h marketcap change
This commit is contained in:
parent
99b3bd160c
commit
45333c7261
@ -33,6 +33,6 @@ INVEST="5"
|
||||
EMERGENCY_STOP="1000"
|
||||
|
||||
# Headline - don't touch
|
||||
export csv_headline="Date and Time,Price,Change,EMA12,EMA26,MACD,EMA9 (Sig.),Histogram,MACD Sig.,RSI5,RSI14,RSI21,RSI720,RSI60,RSI120,RSI240,RSI420,Change 24h,Change 7d,Change 14d,Change 30d"
|
||||
export csv_headline="Date and Time,Price,Change,EMA12,EMA26,MACD,EMA9 (Sig.),Histogram,MACD Sig.,RSI5,RSI14,RSI21,RSI720,RSI60,RSI120,RSI240,RSI420,Change 24h,Change 7d,Change 14d,Change 30d,Change 1y,MarketCap Change 24h,FIB60,FIB168,FIB672,FIB8064"
|
||||
|
||||
|
||||
|
@ -42,8 +42,6 @@ function get_asset {
|
||||
fi
|
||||
|
||||
# headline
|
||||
|
||||
#[ -s "${f_ASSET_HIST_FILE}" ] || echo 'Date and Time,Price,Price Change,EMA12,EMA26,MACD,EMA9 MACD (Signal),MACD Histogram,MACD Signal,RSI5,RSI14,RSI21,RSI720,RSI60,RSI120,RSI240,RSI420,Price Change 24h,Price Change 7d,Price Change 14d,Price Change 30d' >"${f_ASSET_HIST_FILE}"
|
||||
[ -s "${f_ASSET_HIST_FILE}" ] || echo "${csv_headline}" >"${f_ASSET_HIST_FILE}"
|
||||
|
||||
|
||||
@ -78,6 +76,18 @@ function get_asset {
|
||||
echo -n ,$(jq -r ".[] |select(.symbol==\"${f_asset}\")|\"\\(.price_change_percentage_7d_in_currency)\"" COINGECKO_GET_ASSETS_CMD_OUT) >>${f_ASSET_HIST_FILE}
|
||||
echo -n ,$(jq -r ".[] |select(.symbol==\"${f_asset}\")|\"\\(.price_change_percentage_14d_in_currency)\"" COINGECKO_GET_ASSETS_CMD_OUT) >>${f_ASSET_HIST_FILE}
|
||||
echo -n ,$(jq -r ".[] |select(.symbol==\"${f_asset}\")|\"\\(.price_change_percentage_30d_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}
|
||||
|
||||
# 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
|
||||
|
||||
# end with newline
|
||||
echo "" >>${f_ASSET_HIST_FILE}
|
||||
|
@ -31,7 +31,7 @@ function get_assets {
|
||||
|
||||
## write assets list and filter by marketcap and sort by price
|
||||
# get krypto symbol list sorted by marketcap
|
||||
echo "curl -s -X 'GET' \"https://api.coingecko.com/api/v3/coins/markets?vs_currency=usd&order=market_cap_desc&per_page=250&page=1&sparkline=false&price_change_percentage=1h,24h,7d,14d,30d\" -H 'accept: application/json'" >COINGECKO_GET_ASSETS_CMD
|
||||
echo "curl -s -X 'GET' \"https://api.coingecko.com/api/v3/coins/markets?vs_currency=usd&order=market_cap_desc&per_page=250&page=1&sparkline=false&price_change_percentage=1h,24h,7d,14d,30d,1y\" -H 'accept: application/json'" >COINGECKO_GET_ASSETS_CMD
|
||||
g_runcmd g_retrycmd sh COINGECKO_GET_ASSETS_CMD >COINGECKO_GET_ASSETS_CMD_OUT || return 1
|
||||
#ASSET_MARKETCAP_OUT.tmp || return 1
|
||||
if [ -s COINGECKO_GET_ASSETS_CMD_OUT ] && grep -q "market_cap_rank" COINGECKO_GET_ASSETS_CMD_OUT
|
||||
|
48
dabo/functions/get_fibonacci_indicator.sh
Normal file
48
dabo/functions/get_fibonacci_indicator.sh
Normal file
@ -0,0 +1,48 @@
|
||||
function get_fibonacci_indicator {
|
||||
#g_echo_note "RUNNING FUNCTION ${FUNCNAME} $@"
|
||||
# get histfile
|
||||
local f_hist_file="$1"
|
||||
local f_period="$2"
|
||||
|
||||
f_fibonacci=""
|
||||
|
||||
# Check for enough time periods in data
|
||||
local f_period=$((f_period+1))
|
||||
local f_period_sum=$(tail -n${f_period} "${f_hist_file}" | cut -d, -f2 | grep "^[0-9]" | wc -l)
|
||||
if ! [ ${f_period_sum} -ge ${f_period} ]
|
||||
then
|
||||
g_echo_note "${FUNCNAME} $@: Not enough data - waiting for more values and defaulting to 0. (${f_period} needed; ${f_period_sum} given)"
|
||||
echo -n ",0" >>"${f_hist_file}"
|
||||
return 0
|
||||
fi
|
||||
|
||||
# get highest and lowest price in period and current price
|
||||
local f_highest=$(tail -n${f_period} "${f_hist_file}" | cut -d"," -f2 | grep "^[0-9]" | sort -n | tail -n1)
|
||||
local f_lowest=$(tail -n${f_period} "${f_hist_file}" | cut -d"," -f2 | grep "^[0-9]" | sort -n | head -n1)
|
||||
local f_price=$(tail -n1 "${f_hist_file}" | cut -d"," -f2 | grep "^[0-9]")
|
||||
# calculate range
|
||||
local f_range=$(echo "${f_highest}-${f_lowest}" | bc -l)
|
||||
|
||||
# calculate current difference to highest
|
||||
local f_diff_to_highest=$(echo "${f_highest}-${f_price}" | bc -l)
|
||||
local f_diff_to_highest_in_range=$(echo "${f_range}-${f_diff_to_highest}" | bc -l)
|
||||
|
||||
# calculate fibonacci retracement value from range to difference of highest price
|
||||
f_fibonacci=$(echo "scale=8; 1+(1/${f_range}*(${f_diff_to_highest_in_range}-${f_range}))" | bc | sed 's/^\./0./;' | xargs printf "%.3f")
|
||||
#f_fibonacci=$(g_percentage-diff ${f_range} ${f_diff_to_highest_in_range})
|
||||
|
||||
echo -n ",${f_fibonacci}" >>"${f_hist_file}"
|
||||
|
||||
# echo "
|
||||
#Highest=$f_highest
|
||||
#Lowest=$f_lowest
|
||||
#Price=$f_price
|
||||
#Range=$f_range
|
||||
#highest-diff=$f_diff_to_highest
|
||||
#highest-diff-range=$f_diff_to_highest_in_range
|
||||
#"
|
||||
|
||||
#g_echo_note "Fibonacci-Retracement: ${f_fibonacci}"
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user