fix US-CONSUMER-PRICE-INDEX, US-UNEMPLOYMENT-INDEX

This commit is contained in:
olli 2024-04-09 09:22:43 +02:00
parent 9e918401e7
commit 6807c6c78c

View File

@ -61,7 +61,6 @@ function market_performance {
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_added=0 local f_index_performance_added=0
local f_index_performance_csv="" local f_index_performance_csv=""
local f_INDEX local f_INDEX
@ -98,13 +97,11 @@ function market_performance {
fi fi
fi fi
# finishing vars # finishing vars
f_index_performance_txt="${f_index_performance_txt}${f_INDEX}: ${f_index_performance}%; "
f_index_performance_added="$(echo "scale=2; ${f_index_performance_added}+${f_index_performance}" | bc -l | sed -r 's/^(-?)\./\10./')" f_index_performance_added="$(echo "scale=2; ${f_index_performance_added}+${f_index_performance}" | bc -l | sed -r 's/^(-?)\./\10./')"
f_index_performance_csv="${f_index_performance_csv},${f_index_performance}" f_index_performance_csv="${f_index_performance_csv},${f_index_performance}"
done done
# calculate US-FED-FEDERAL-FUNDS-RATE-INVERTED # calculate US-FED-FEDERAL-FUNDS-RATE-INVERTED
local f_economic
for f_eco_data in US-FED-FEDERAL-FUNDS-RATE-INVERTED-INDEX for f_eco_data in US-FED-FEDERAL-FUNDS-RATE-INVERTED-INDEX
do do
local f_index_performance=$(tail -n 1 asset-histories/${f_eco_data}.history.csv | cut -d, -f2) local f_index_performance=$(tail -n 1 asset-histories/${f_eco_data}.history.csv | cut -d, -f2)
@ -117,22 +114,19 @@ function market_performance {
f_index_performance="-${f_index_performance}" f_index_performance="-${f_index_performance}"
fi fi
fi fi
f_index_performance_txt="${f_index_performance_txt}${f_eco_data}: ${f_index_performance}%; "
f_index_performance_added="$(echo "scale=2; ${f_index_performance_added}+${f_index_performance}" | bc -l | sed -r 's/^(-?)\./\10./')" f_index_performance_added="$(echo "scale=2; ${f_index_performance_added}+${f_index_performance}" | bc -l | sed -r 's/^(-?)\./\10./')"
f_index_performance_csv="${f_index_performance_csv},${f_index_performance}" f_index_performance_csv="${f_index_performance_csv},${f_index_performance}"
done done
# calculate forecast US Unemployment Rate and US Consumer Price Index (CPI) # calculate forecast US Unemployment Rate and US Consumer Price Index (CPI)
local f_economic
for f_eco_data in US-UNEMPLOYMENT-INDEX US-CONSUMER-PRICE-INDEX for f_eco_data in US-UNEMPLOYMENT-INDEX US-CONSUMER-PRICE-INDEX
do do
local f_current=$(tail -n 1 asset-histories/${f_eco_data}.history.csv | cut -d, -f2) local f_current=$(tail -n 1 asset-histories/${f_eco_data}.history.csv | cut -d, -f2)
local f_forecast=$(tail -n 1 asset-histories/${f_eco_data}.history.csv | cut -d, -f3) #local f_forecast=$(tail -n 1 asset-histories/${f_eco_data}.history.csv | cut -d, -f3)
f_index_performance="$(echo "scale=2; ${f_current}-${f_forecast}" | bc -l | sed -r 's/^(-?)\./\10./')" #f_index_performance="$(echo "scale=2; ${f_current}-${f_forecast}" | bc -l | sed -r 's/^(-?)\./\10./')"
f_index_performance_txt="${f_index_performance_txt}${f_eco_data}: ${f_index_performance}%; " f_index_performance_added="$(echo "scale=2; ${f_index_performance_added}+${f_current}" | bc -l | sed -r 's/^(-?)\./\10./')"
f_index_performance_added="$(echo "scale=2; ${f_index_performance_added}+${f_index_performance}" | bc -l | sed -r 's/^(-?)\./\10./')" f_index_performance_csv="${f_index_performance_csv},${f_current}"
f_index_performance_csv="${f_index_performance_csv},${f_index_performance}"
done done
# price performance bitcoin # price performance bitcoin
@ -147,9 +141,8 @@ function market_performance {
## 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./' | xargs printf "%.2f") 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
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')
local f_market_csv_headline="date,market performance,btc,eth,btc forecast,eth forecast,top250,${f_indexlistcsv}US-FED-FEDERAL-FUNDS-RATE-INVERTED,US-UNEMPLOYMENT forecast,US-CONSUMER-PRICE forecast" local f_market_csv_headline="date,market performance,btc,eth,btc forecast,eth forecast,top250,${f_indexlistcsv}US-FED-FEDERAL-FUNDS-RATE-INVERTED,US-UNEMPLOYMENT,US-CONSUMER-PRICE"
if [ -s MARKET_PERFORMANCE.csv ] if [ -s MARKET_PERFORMANCE.csv ]
then then
sed -i -e 1c"$f_market_csv_headline" MARKET_PERFORMANCE.csv sed -i -e 1c"$f_market_csv_headline" MARKET_PERFORMANCE.csv