updated/added a lot of indexes,...
This commit is contained in:
parent
c6a4fcfe66
commit
a5a8134b02
@ -1,6 +1,11 @@
|
|||||||
function market_performance {
|
function market_performance {
|
||||||
g_echo_note "RUNNING FUNCTION ${FUNCNAME} $@"
|
g_echo_note "RUNNING FUNCTION ${FUNCNAME} $@"
|
||||||
|
|
||||||
|
if find MARKET_PERFORMANCE.csv -mmin -${INTERVAL_MIN} | grep -q "MARKET_PERFORMANCE.csv"
|
||||||
|
then
|
||||||
|
g_echo_note "MARKET_PERFORMANCE.csv already downloaded in the last ${INTERVAL_MIN} minutes"
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
|
||||||
## function for scoring limits set in config up or down by specific (market) facts
|
## function for scoring limits set in config up or down by specific (market) facts
|
||||||
# generates variable f_market_performance
|
# generates variable f_market_performance
|
||||||
@ -64,12 +69,12 @@ function market_performance {
|
|||||||
# day average 1 week ago
|
# day average 1 week ago
|
||||||
local f_from=$(grep "^$(date "+%Y-%m-%d" -d "last week") " asset-histories/${f_INDEX}-INDEX.history.csv | cut -d, -f2 | awk '{ sum += $1; n++ } END { if (n > 0) print sum / n; }')
|
local f_from=$(grep "^$(date "+%Y-%m-%d" -d "last week") " asset-histories/${f_INDEX}-INDEX.history.csv | cut -d, -f2 | awk '{ sum += $1; n++ } END { if (n > 0) print sum / n; }')
|
||||||
# fallback this or last month
|
# fallback this or last month
|
||||||
[ -z "${f_from}" ] && f_from=$(grep "^$(date "+%Y-%m-")" asset-histories/${f_INDEX}-INDEX.history.csv | cut -d, -f2 | awk '{ sum += $1; n++ } END { if (n > 0) print sum / n; }')
|
#[ -z "${f_from}" ] && f_from=$(grep "^$(date "+%Y-%m-")" asset-histories/${f_INDEX}-INDEX.history.csv | cut -d, -f2 | awk '{ sum += $1; n++ } END { if (n > 0) print sum / n; }')
|
||||||
[ -z "${f_from}" ] && f_from=$(grep "^$(date "+%Y-%m-" -d "last month")" asset-histories/${f_INDEX}-INDEX.history.csv | cut -d, -f2 | awk '{ sum += $1; n++ } END { if (n > 0) print sum / n; }')
|
#[ -z "${f_from}" ] && f_from=$(grep "^$(date "+%Y-%m-" -d "last month")" asset-histories/${f_INDEX}-INDEX.history.csv | cut -d, -f2 | awk '{ sum += $1; n++ } END { if (n > 0) print sum / n; }')
|
||||||
# if no data
|
# if no data
|
||||||
[ -z "${f_from}" ] && f_from=0
|
[ -z "${f_from}" ] && f_from=0
|
||||||
# latest value
|
# middle of latest 10 values
|
||||||
local f_to=$(tail -n 1 asset-histories/${f_INDEX}-INDEX.history.csv | cut -d, -f2)
|
local f_to=$(tail -n 10 asset-histories/${f_INDEX}-INDEX.history.csv | cut -d, -f2 | awk '{ sum += $1; n++ } END { if (n > 0) print sum / n; }')
|
||||||
[ -z "${f_to}" ] && f_to=0
|
[ -z "${f_to}" ] && f_to=0
|
||||||
if [ ${f_to} == "0" ] || [ ${f_from} == "0" ]
|
if [ ${f_to} == "0" ] || [ ${f_from} == "0" ]
|
||||||
then
|
then
|
||||||
@ -127,29 +132,25 @@ function market_performance {
|
|||||||
f_index_performance_csv="${f_index_performance_csv},${f_index_performance}"
|
f_index_performance_csv="${f_index_performance_csv},${f_index_performance}"
|
||||||
done
|
done
|
||||||
|
|
||||||
# price performance bitcoin (last 48 intervals)
|
# price performance bitcoin
|
||||||
#local f_from=$(tail -n 48 asset-histories/BTC${CURRENCY}.history.csv | grep -v ^[A-Z] | head -n1 | cut -d, -f2)
|
#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 1 asset-histories/BTC${CURRENCY}.history.csv | cut -d, -f2)
|
#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_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_exchange_rate_diff_percentage=$(g_percentage-diff ${f_from} ${f_to})
|
||||||
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_btc_performance=${f_exchange_rate_diff_percentage}
|
||||||
local f_exchange_rate_diff_percentage=$(g_percentage-diff ${f_from} ${f_to})
|
local f_btc_performance=$(jq -r '.[] |select(.symbol=="btc")|(.price_change_percentage_7d_in_currency)' COINGECKO_GET_ASSETS_CMD_OUT)
|
||||||
#get_rate_percentage_min_before_and_now BTC ${CURRENCY} 360 || return 1
|
|
||||||
local f_btc_performance=${f_exchange_rate_diff_percentage}
|
|
||||||
|
|
||||||
# price performance ethereum (last 48 intervals)
|
# price performance ethereum
|
||||||
#get_rate_percentage_min_before_and_now ETH ${CURRENCY} 360 || return 1
|
#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_from=$(tail -n 48 asset-histories/ETH${CURRENCY}.history.csv | grep -v ^[A-Z] | head -n1 | cut -d, -f2)
|
#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_to=$(tail -n 1 asset-histories/ETH${CURRENCY}.history.csv | cut -d, -f2)
|
#local f_exchange_rate_diff_percentage=$(g_percentage-diff ${f_from} ${f_to})
|
||||||
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_eth_performance=${f_exchange_rate_diff_percentage}
|
||||||
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_eth_performance=$(jq -r '.[] |select(.symbol=="eth")|(.price_change_percentage_7d_in_currency)' COINGECKO_GET_ASSETS_CMD_OUT)
|
||||||
local f_exchange_rate_diff_percentage=$(g_percentage-diff ${f_from} ${f_to})
|
|
||||||
local f_eth_performance=${f_exchange_rate_diff_percentage}
|
|
||||||
|
|
||||||
# hourly price performance over TOP 250 marketcap by coingecko
|
# hourly price performance over TOP 250 marketcap by coingecko
|
||||||
local f_top250_marketcap_performance=$(jq -r ".[].price_change_percentage_1h_in_currency" COINGECKO_GET_ASSETS_CMD_OUT | awk '{ SUM += $1} END { printf("%.2f", SUM/250) }')
|
local f_top250_marketcap_performance=$(jq -r ".[].price_change_percentage_1h_in_currency" COINGECKO_GET_ASSETS_CMD_OUT | awk '{ SUM += $1} END { printf("%.2f", SUM/250) }')
|
||||||
|
|
||||||
## calculate market performance
|
## calculate market performance
|
||||||
f_market_performance=$(echo "scale=2; (${f_btc_forecast} + ${f_eth_forecast} + ${f_index_performance_added} + ${f_btc_performance} + ${f_eth_performance} + ${f_top250_marketcap_performance})" | bc -l | sed -r 's/^(-?)\./\10./')
|
f_market_performance=$(echo "scale=2; (${f_btc_forecast} + ${f_eth_forecast} + ${f_index_performance_added} + ${f_btc_performance} + ${f_eth_performance} + ${f_top250_marketcap_performance})" | bc -l | sed -r 's/^(-?)\./\10./' | xargs printf "%.2f")
|
||||||
local f_date=$(g_date_print)
|
local f_date=$(g_date_print)
|
||||||
echo "${f_date} Market Performance: ${f_market_performance}%; BTC forecast: ${f_btc_forecast}%; ETH forecast: ${f_eth_forecast}%; ${f_index_performance_txt}BTC: ${f_btc_performance}%; ETH: ${f_eth_performance}%; TOP250 Marketcap: ${f_top250_marketcap_performance}%" >>MARKET_PERFORMANCE
|
echo "${f_date} Market Performance: ${f_market_performance}%; BTC forecast: ${f_btc_forecast}%; ETH forecast: ${f_eth_forecast}%; ${f_index_performance_txt}BTC: ${f_btc_performance}%; ETH: ${f_eth_performance}%; TOP250 Marketcap: ${f_top250_marketcap_performance}%" >>MARKET_PERFORMANCE
|
||||||
local f_indexlistcsv=$(echo "$f_indexlist" | perl -pe 's/\n/,/g; s/ +/,/g; s/,+/,/g')
|
local f_indexlistcsv=$(echo "$f_indexlist" | perl -pe 's/\n/,/g; s/ +/,/g; s/,+/,/g')
|
||||||
|
Loading…
Reference in New Issue
Block a user