This commit is contained in:
olli 2024-12-19 17:03:48 +01:00
parent 29e04d9533
commit 78f9b15413
3 changed files with 16 additions and 14 deletions

View File

@ -36,8 +36,8 @@ function get_indicators_all {
fi fi
# do the job # do the job
printf '%(%Y-%m-%d %H:%M:%S)T' >"${f_histfile}.indicators-calculating" printf "$0 %(%Y-%m-%d %H:%M:%S)T" >"${f_histfile}.indicators-calculating"
get_indicators "${f_histfile}" ${f_last_intervals} && printf '%(%Y-%m-%d %H:%M:%S)T' >>"$f_histfile.indicators-calculated" get_indicators "${f_histfile}" ${f_last_intervals} && printf "$0 %(%Y-%m-%d %H:%M:%S)T\n" >>"$f_histfile.indicators-calculated"
# add missing intervals for example from weekends from non-24h-assets like economic data - interval from filename # add missing intervals for example from weekends from non-24h-assets like economic data - interval from filename
#f_add_missing_ohlcv_intervals "${f_histfile}" #f_add_missing_ohlcv_intervals "${f_histfile}"
rm -f "${f_histfile}.indicators-calculating" rm -f "${f_histfile}.indicators-calculating"
@ -63,8 +63,8 @@ function get_indicators_all {
fi fi
# do the job # do the job
printf '%(%Y-%m-%d %H:%M:%S)T' >"${f_histfile}.indicators-calculating" printf "$0 %(%Y-%m-%d %H:%M:%S)T" >"${f_histfile}.indicators-calculating"
get_indicators "${f_histfile}" ${f_last_intervals} && printf '%(%Y-%m-%d %H:%M:%S)T' >>"$f_histfile.indicators-calculated" get_indicators "${f_histfile}" ${f_last_intervals} && printf "$0 %(%Y-%m-%d %H:%M:%S)T\n" >>"$f_histfile.indicators-calculated"
rm -f "${f_histfile}.indicators-calculating" rm -f "${f_histfile}.indicators-calculating"
fi fi

View File

@ -77,7 +77,7 @@ function get_marketdata {
local f_other=$4 local f_other=$4
local f_timeframe=$5 local f_timeframe=$5
[ -z "$f_timeframe" ] && f_timeframe=1d [ -z "$f_timeframe" ] && f_timeframe=1d
local f_histfile="asset-histories/MARKETDATA_${f_name}.history.1d.csv" local f_histfile="asset-histories/MARKETDATA_${f_name}.history.${f_timeframe}.csv"
local f_dataline f_failed local f_dataline f_failed
# download # download
@ -146,11 +146,11 @@ function get_marketdata {
# calc indicators and if 1d then generate 1w histfile # calc indicators and if 1d then generate 1w histfile
if [[ $f_interval = 1d ]] if [[ $f_interval = 1d ]]
then then
get_indicators "${f_histfile}" get_indicators "${f_histfile}" 51
convert_ohlcv_1d_to_1w "${f_histfile}" "${f_histfile/.1d./.1w.}" convert_ohlcv_1d_to_1w "${f_histfile}" "${f_histfile/.1d./.1w.}"
get_indicators "${f_histfile/.1d./.1w.}" get_indicators "${f_histfile/.1d./.1w.}" 51
else else
get_indicators "${f_histfile}" 999 get_indicators "${f_histfile}" 51
fi fi
} }

View File

@ -118,14 +118,11 @@ function get_ohlcv-candle {
if [[ $f_asset =~ ^ECONOMY- ]] if [[ $f_asset =~ ^ECONOMY- ]]
then then
# economy from yahoo finance # economy from yahoo finance
if [ "$f_timeframe" = "1h" ] || [ "$f_timeframe" = "15m" ] || [ "$f_timeframe" = "5m" ]
then
if ! get_marketdata_yahoo "$f_symbol" "$f_asset" $f_timeframe if ! get_marketdata_yahoo "$f_symbol" "$f_asset" $f_timeframe
then then
g_echo_error "$f_get_marketdata_coinmarketcap_error" g_echo_error "$f_get_marketdata_coinmarketcap_error"
return 1 return 1
fi fi
fi
f_histfile_extdata=$f_histfile_yahoo f_histfile_extdata=$f_histfile_yahoo
else else
# crypto from coinmarketcap # crypto from coinmarketcap
@ -512,6 +509,11 @@ function convert_ohlcv_1d_to_1w {
IFS=',' read -r f_date f_open f_high f_low f_close f_volume f_other <<< "$f_line" IFS=',' read -r f_date f_open f_high f_low f_close f_volume f_other <<< "$f_line"
IFS='-' read -r f_year f_month f_day <<< "$f_date" IFS='-' read -r f_year f_month f_day <<< "$f_date"
[ -z "$f_high" ] && f_high=$f_open
[ -z "$f_low" ] && f_low=$f_open
[ -z "$f_close" ] && f_close=$f_open
[ -z "$f_volume" ] && f_volume=0
# use week-number to sort day data in weeks # use week-number to sort day data in weeks
f_week_number=$(date -d "$f_year-$f_month-$f_day" +%U) f_week_number=$(date -d "$f_year-$f_month-$f_day" +%U)
f_week_number=${f_week_number##0} f_week_number=${f_week_number##0}