fixes in market-performance calc

This commit is contained in:
olli 2023-10-06 11:20:17 +02:00
parent 7da8f09630
commit 313b6589f2

View File

@ -53,7 +53,6 @@ function market_performance {
g_echo_note "ETH forecast: $f_eth_forecast" g_echo_note "ETH forecast: $f_eth_forecast"
f_eth_forecast=$(echo "scale=2; ${f_eth_forecast}/3" | bc -l | sed -r 's/^(-?)\./\10./') f_eth_forecast=$(echo "scale=2; ${f_eth_forecast}/3" | bc -l | sed -r 's/^(-?)\./\10./')
# Calculate available market data week changes # Calculate available market data week changes
local f_index_performance_txt="" local f_index_performance_txt=""
local f_index_performance_added=0 local f_index_performance_added=0
@ -107,21 +106,6 @@ 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 msci world (last week and halved because of the long time)
#local f_msci_last_date=$(tail -n1 asset-histories/MSCI-WORLD-INDEX.history.csv | cut -d, -f1)
#local f_from=$(egrep "^$(date -d "${f_msci_last_date} last week" "+%Y-%m-%d %H:" | cut -d, -f1 | tail -n1)" asset-histories/MSCI-WORLD-INDEX.history.csv | head -n1 | cut -d, -f2)
#[ -z "${f_from}" ] && f_from=$(egrep "^$(date -d "${f_msci_last_date} last week" "+%Y-%m-%d " | cut -d, -f1 | tail -n1)" asset-histories/MSCI-WORLD-INDEX.history.csv | head -n1 | cut -d, -f2)
#local f_to=$(tail -n 1 asset-histories/MSCI-WORLD-INDEX.history.csv | cut -d, -f2)
#local f_exchange_rate_diff_percentage=$(g_percentage-diff ${f_from} ${f_to})
#if [ ${f_to} == "0" ] || [ ${f_from} == "0" ]
#then
# local f_msci_world_performance="-0.1"
#else
# local f_msci_world_performance=$(echo "scale=2; ${f_exchange_rate_diff_percentage}/2" | bc -l | sed -r 's/^(-?)\./\10./')
#fi
# price performance bitcoin (last 30 minutes) # price performance bitcoin (last 30 minutes)
local f_from=$(tail -n 30 asset-histories/BTC${CURRENCY}.history.csv | grep -v ^[A-Z] | head -n1 | cut -d, -f2) local f_from=$(tail -n 30 asset-histories/BTC${CURRENCY}.history.csv | grep -v ^[A-Z] | head -n1 | cut -d, -f2)
local f_to=$(tail -n 1 asset-histories/BTC${CURRENCY}.history.csv | cut -d, -f2) local f_to=$(tail -n 1 asset-histories/BTC${CURRENCY}.history.csv | cut -d, -f2)
@ -140,12 +124,11 @@ function market_performance {
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})/6" | 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./')
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
[ -s MARKET_PERFORMANCE.csv ] || echo "date,market performance,btc,eth,btc forecast,eth forecast,top250,DXY-INVERTED,SP500,NASDAQ,MSCI-WORLD,OIL-GAS-INVERTED,DAX,KRE-BANKING,US-UNEMPLOYMENT forecast,US-CONSUMER-PRICE forecast" >MARKET_PERFORMANCE.csv [ -s MARKET_PERFORMANCE.csv ] || echo "date,market performance,btc,eth,btc forecast,eth forecast,top250,DXY-INVERTED,SP500,NASDAQ,MSCI-WORLD,OIL-GAS-INVERTED,DAX,KRE-BANKING,US-UNEMPLOYMENT forecast,US-CONSUMER-PRICE forecast" >MARKET_PERFORMANCE.csv
echo "${f_date},${f_market_performance},${f_btc_performance},${f_eth_performance},${f_btc_forecast},${f_eth_forecast},${f_top250_marketcap_performance}${f_index_performance_csv}" >>MARKET_PERFORMANCE.csv echo "${f_date},${f_market_performance},${f_btc_performance},${f_eth_performance},${f_btc_forecast},${f_eth_forecast},${f_top250_marketcap_performance}${f_index_performance_csv}" >>MARKET_PERFORMANCE.csv
echo -n "${f_market_performance}" >MARKET_PERFORMANCE_LATEST echo -n "${f_market_performance}" >MARKET_PERFORMANCE_LATEST
} }