Compare commits

...

12 Commits

10 changed files with 235 additions and 107 deletions

View File

@ -30,8 +30,8 @@ do
# Reload Config
. ../../dabo-bot.conf
. ../../dabo-bot.override.conf
# get orders
# get all indicators
get_indicators_all
rm asset-histories/*.history.*.csv.indicators-calculating
rm -f asset-histories/*.history.*.csv.indicators-calculating
done

View File

@ -22,7 +22,7 @@
. /dabo/dabo-prep.sh
rm -f asset-histories/*.history.*.csv.levels-calculating
sleep 12
sleep 120
while true
do
@ -33,6 +33,7 @@ do
# get levels
get_levels_all
rm -f asset-histories/*.history.*.csv.levels-calculating
sleep 900
# recalc every 6 hours
sleep 21600
done

View File

@ -32,16 +32,21 @@ do
. ../../dabo-bot.conf
. ../../dabo-bot.override.conf
# notify failed downloads
[ "$interval" = "1d" ] && cat FAILED_*/* 2>/dev/null | notify.sh -s "Failed downloads"
if [ "$interval" = "1h" ]
then
cat FAILED_*/* 2>/dev/null | notify.sh -s "Failed downloads"
mkdir -p REPORTED_FAILED
mv FAILED_*/* REPORTED_FAILED/ 2>/dev/null
fi
# Timestamp
export f_timestamp=$(g_date_print)
# get candles and indicators
get_ohlcv-candles $interval
[[ $interval != 1w ]] && get_marketdata_all $interval
[ -n "$seconds" ] && sleeptime=$(( ( ($seconds - $(TZ=UTC printf "%(%s)T") % $seconds) % $seconds + 2 )))
#[[ $interval = 4h ]] && sleeptime=??
if [ "$interval" = "1d" ]
then
get_marketdata_fear_and_greed_alternativeme
sleeptime=$(($(TZ=UTC date +%s -d "tomorrow 0:01") - $(date +%s) +2 ))
fi
[ "$interval" = "1w" ] && sleeptime=$(($(TZ=UTC date +%s -d "next monday 0:01") - $(date +%s) +2 ))

View File

@ -40,9 +40,6 @@ function calc_ema {
# check if there is a column (i from loop through array)
[ -z "$f_column" ] && return 3
# check for enough positions/values to calculate (enough values)
[ $f_position -ge $f_period ] || return 0
# get ema column
[ -z "$f_target_column" ] && local f_target_column="ema$f_period"
@ -58,6 +55,12 @@ function calc_ema {
local f_last_ema_position=$((f_position-1))
local f_last_ema=${v_csv_array_associative[${f_target_column}_${f_last_ema_position}]}
# check for enough positions/values to calculate (enough values) if SMA needed
if [ -z "$f_last_ema" ]
then
[ $f_position -ge $f_period ] || return 5
fi
# check if last EMA is given
if [ -n "$f_last_ema" ]
then
@ -94,7 +97,6 @@ function calc_ema {
fi
v_csv_array_associative[${f_target_column}_${f_position}]=$g_calc_result
f_ema=$g_calc_result
return 0
}

View File

@ -51,7 +51,13 @@ function currency_converter {
f_currency_date_day=$(date -d "${f_currency_date}" "+%Y-%m-%d")
# month failback
f_currency_date_month=$(date -d "${f_currency_date}" "+%Y-%m")
if [ $(date -d "${f_currency_date}" "+%d") = "01" ]
then
# on first day in month use month before because no date from current month
f_currency_date_month=$(date -d "${f_currency_date} yesterday" "+%Y-%m")
else
f_currency_date_month=$(date -d "${f_currency_date}" "+%Y-%m")
fi
# path to history files for the converting rate
[ -d asset-histories ] || mkdir asset-histories

View File

@ -26,7 +26,8 @@ function get_indicators_all {
local f_histfile f_symbol
find asset-histories -maxdepth 1 -name "ECONOMY-*.history.[0-5][5dhwm]*.csv" | sort | while read f_histfile
# ECONOMY and MARKETDATA
find asset-histories -maxdepth 1 -name "ECONOMY-*.history.[0-5][5dhwm]*.csv" -o -name "MARKETDATA_*.history.[0-5][5dhwm]*.csv" | sort | while read f_histfile
do
if [ -s "${f_histfile}.fetching" ] || [ -s "${f_histfile}.indicators-calculating" ]
then
@ -69,7 +70,7 @@ function get_indicators_all {
fi
done
done
shopt +s nullglob
shopt -u nullglob
}
@ -82,17 +83,27 @@ function get_indicators {
local f_fill_missing_ohlcv_intervals=$3
local f_line
# check if the job is already done
if [ $(wc -l <"${f_histfile}") -gt 801 ]
then
if ! tail +801 "${f_histfile}" | egrep -vq "^....-..-..*,[0-9\.]+,[0-9\.]+,[0-9\.]+,[0-9\.]+,[0-9\.]+,[0-9\.\-]+,[0-9\.]+,[0-9\.]+,[0-9\.]+,[0-9\.]+,[0-9\.]+,[0-9\.]+,[0-9\.]+,[0-9\.]+,[0-9\.]+,[0-9\.]+,[0-9\.]+,[0-9\.\-]+,[0-9\.\-]+,[0-9\.\-]+,[a-z]*,[0-9\.\-]+,[0-9\.\-]+"
then
g_echo_note "${f_histfile} seems to be indicator-complete"
return 0
fi
fi
# history
local f_columns="date,open,high,low,close,volume,change,ath,ema12,ema26,ema50,ema100,ema200,ema400,ema800,rsi5,rsi14,rsi21,macd,macd_ema9_signal,macd_histogram,macd_histogram_signal,macd_histogram_max,macd_histogram_strength"
local f_emas="12 26 50 100 200 400 800"
local f_rsis="5 14 21"
local f_ema f_change f_changed f_line f_valid_data f_ath
local f_ema f_change f_changed f_line f_valid_data f_ath f_last_year
local f_columns_space="${f_columns//,/ }"
g_read_csv "${f_histfile}" "${f_last_intervals}" "$f_columns"
for ((i=0; i<=${#g_csv_array[@]}-1; i++))
do
if [ -z "${v_csv_array_associative[date_${i}]}" ]
if [ -z "${v_csv_array_associative[date_${i}]}" ] || [ -z "${v_csv_array_associative[open_${i}]}" ]
then
g_echo_note "No data $f_histfile:${v_csv_array_associative[date_${i}]}"
return 0
@ -105,16 +116,42 @@ function get_indicators {
### check for unfilled fields
f_change=""
# check olhc data
if [ -z "${v_csv_array_associative[high_${i}]}" ] && [ -z "${v_csv_array_associative[low_${i}]}" ] && [ -z "${v_csv_array_associative[close_${i}]}" ]
then
g_echo_note "fixing OHLC Data"
# open is close
v_csv_array_associative[close_${i}]=${v_csv_array_associative[open_${i}]}
# open is previous close
[ -n "${v_csv_array_associative[close_${p}]}" ] && v_csv_array_associative[open_${i}]="${v_csv_array_associative[close_${p}]}"
# calc high/low from open/close
if g_num_is_higher_equal ${v_csv_array_associative[open_${i}]} ${v_csv_array_associative[close_${i}]}
then
v_csv_array_associative[high_${i}]=${v_csv_array_associative[open_${i}]}
v_csv_array_associative[low_${i}]=${v_csv_array_associative[close_${i}]}
else
v_csv_array_associative[high_${i}]=${v_csv_array_associative[close_${i}]}
v_csv_array_associative[low_${i}]=${v_csv_array_associative[open_${i}]}
fi
f_change=1
fi
# check for missing percentage change
if [ -z "${v_csv_array_associative[change_${i}]}" ]
then
#if ! [ $p -lt 0 ]
#then
#echo "g_percentage-diff ${v_csv_array_associative[close_${p}]} ${v_csv_array_associative[close_${i}]}"
#g_percentage-diff ${v_csv_array_associative[close_${p}]} ${v_csv_array_associative[close_${i}]} && f_change=1
g_percentage-diff ${v_csv_array_associative[open_${i}]} ${v_csv_array_associative[close_${i}]} && f_change=1
v_csv_array_associative[change_${i}]=${g_percentage_diff_result}
#fi
# special for changes watched per year like CPI,...
if [[ $f_histfile = "asset-histories/MARKETDATA_US_CONSUMER_PRICE_INDEX_CPI.history.1d.csv" ]] || \
[[ $f_histfile = "asset-histories/MARKETDATA_US_UNEMPLOYMENT_RATE.history.1d.csv" ]]
then
if [ $i -ge 12 ]
then
f_last_year=$((i-12))
g_percentage-diff ${v_csv_array_associative[open_${f_last_year}]} ${v_csv_array_associative[close_${i}]}
v_csv_array_associative[year_change_${i}]=${g_percentage_diff_result}
fi
fi
g_percentage-diff ${v_csv_array_associative[open_${i}]} ${v_csv_array_associative[close_${i}]} && f_change=1
v_csv_array_associative[change_${i}]=${g_percentage_diff_result}
fi
# ath (all-time-high) of present data
@ -135,10 +172,20 @@ function get_indicators {
# check for missing EMAs
for f_ema_column in $f_emas
do
# check for enough values/lines to calculate EMA
[ $i -ge $f_ema_column ] || continue
# check for enough values/lines to calculate EMA if no previous EMA given
if [ -z "${v_csv_array_associative[ema${f_ema_column}_${p}]}" ]
then
if ! [ $i -ge $f_ema_column ]
then
#echo "not enough lines $i -ge $f_ema_column"
continue
fi
fi
# calculate EMA
[ -z "${v_csv_array_associative[ema${f_ema_column}_${i}]}" ] && calc_ema ${f_ema_column} close && f_change=1
if [ -z "${v_csv_array_associative[ema${f_ema_column}_${i}]}" ]
then
calc_ema ${f_ema_column} close && f_change=1
fi
done
# check for missing RSI
@ -164,6 +211,11 @@ function get_indicators {
# build line
for f_column in $f_columns
do
# special for changes watched per year like CPI,...
if [[ $f_column = change ]]
then
[ -n "${v_csv_array_associative[year_change_${i}]}" ] && v_csv_array_associative[change_${i}]=${v_csv_array_associative[year_change_${i}]}
fi
if [ -z "$f_line" ]
then
f_line="${v_csv_array_associative[${f_column}_${i}]}"

View File

@ -17,95 +17,142 @@
# You should have received a copy of the GNU General Public License
# along with dabo. If not, see <http://www.gnu.org/licenses/>.
function get_marketdata_all {
local f_interval=$1
# daily garketdata jobs
if [[ $f_interval = 1d ]]
then
# FEAR_AND_GREED_ALTERNATIVEME
get_marketdata FEAR_AND_GREED_ALTERNATIVEME 'https://api.alternative.me/fng/?limit=0&format=json' '.data[] | (.timestamp | tonumber | strftime("%Y-%m-%d")) + "," + .value + ",,,,0"' "" 1d
# FEAR_AND_GREED_CNN
get_marketdata FEAR_AND_GREED_CNN 'https://production.dataviz.cnn.io/index/fearandgreed/graphdata' '.fear_and_greed_historical.data[] | (.x/1000 | strftime("%Y-%m-%d")) + "," + (.y|tostring) + ",,,,0"' "" 1d
# monthly US consumer price index CPI data
get_marketdata US_CONSUMER_PRICE_INDEX_CPI "https://api.bls.gov/publicAPI/v2/timeseries/data/CUUR0000SA0?startyear=$(date -d 'now -8 years' '+%Y')&endyear=$(date '+%Y')" '.Results.series[0].data[] | .year + "-" + (.period | gsub("M"; "")) + "-01," + .value + ",,,,0"' "" 1d
# monthly US unemployment rate
get_marketdata US_UNEMPLOYMENT_RATE "https://api.bls.gov/publicAPI/v2/timeseries/data/LNU03000000?startyear=$(date -d 'now -8 years' '+%Y')&endyear=$(date '+%Y')" '.Results.series[0].data[] | .year + "-" + (.period | gsub("M"; "")) + "-01," + .value + ",,,,0"' "" 1d
# US FED funds rate
get_marketdata US_FED_FUNDS_RATE 'https://fred.stlouisfed.org/graph/fredgraph.csv?id=DFF' "" "" 1d
fi
# Binance Long Short Ration Account / Taker and Open Interest per symbol
get_symbols_ticker
local f_symbol f_asset f_time
for f_symbol in BTC/$CURRENCY "${f_symbols_array_trade[@]}"
do
f_asset=${f_symbol//:$CURRENCY/}
f_asset=${f_asset//\//}
# week not available
[[ $f_interval = 1w ]] && continue
f_time='%Y-%m-%d %H:%M:00'
[[ $f_interval = 1d ]] && f_time='%Y-%m-%d'
# BINANCE_LONG_SHORT_RATIO_ACCOUNT per symbol
get_marketdata BINANCE_LONG_SHORT_RATIO_ACCOUNT_$f_asset "https://fapi.binance.com/futures/data/globalLongShortAccountRatio?symbol=${f_asset}&limit=500&period=${f_interval}" ".[] | (.timestamp/1000 | strftime(\"${f_time}\")) + \",\" + .longShortRatio + \",,,,0\"" "" ${f_interval}
# BINANCE_LONG_SHORT_RATIO_Taker per symbol
get_marketdata BINANCE_LONG_SHORT_RATIO_TAKER_$f_asset "https://fapi.binance.com/futures/data/takerlongshortRatio?symbol=${f_asset}&limit=500&period=${f_interval}" ".[] | (.timestamp/1000 | strftime(\"${f_time}\")) + \",\" + .buySellRatio + \",,,,0\"" "" ${f_interval}
# BINANCE_OPEN_INTEREST per symbol
get_marketdata BINANCE_OPEN_INTEREST_$f_asset "https://fapi.binance.com/futures/data/openInterestHist?symbol=${f_asset}&limit=500&period=${f_interval}" ".[] | (.timestamp/1000 | strftime(\"${f_time}\")) + \",\" + .sumOpenInterest + \",,,,0\"" "" ${f_interval}
done
}
function get_marketdata {
g_echo_note "RUNNING FUNCTION ${FUNCNAME} $@"
local f_name=$1
local f_wget=$2
local f_jq=$3
local f_other=$4
local f_timeframe=$5
[ -z "$f_timeframe" ] && f_timeframe=1d
local f_histfile="asset-histories/MARKETDATA_${f_name}.history.1d.csv"
local f_dataline f_failed
### CPI Data: curl hapi.bls.gov/publicAPI/v2/timeseries/data/cpi | jq -a
### release dates: https://www.bls.gov/schedule/news_release/bls.ics
get_marketdata_from_url https://www.investing.com/economic-calendar/unemployment-rate-300/ US-UNEMPLOYMENT-INDEX
get_marketdata_from_url https://www.investing.com/economic-calendar/cpi-733 US-CONSUMER-PRICE-INDEX
get_marketdata_from_url https://www.investing.com/indices/fed-funds-composite-interest-rate-opinion US-FED-FEDERAL-FUNDS-RATE-INVERTED-INDEX
get_marketdata_from_url '"https://fapi.binance.com/futures/data/globalLongShortAccountRatio?symbol=BTCUSDT&period=5m" | jq -r .[].longShortRatio | tail -n1' BINANCE-BTC-GlobalLongShortAccountRatio
get_marketdata_from_url '"https://fapi.binance.com/futures/data/takerlongshortRatio?symbol=BTCUSDT&period=5m" | jq -r .[].buySellRatio | tail -n1' BINANCE-BTC-TakerLongShortRatio
get_marketdata_from_url '"https://fapi.binance.com/futures/data/openInterestHist?symbol=BTCUSDT&period=5m" | jq -r .[].sumOpenInterest | tail -n1' BINANCE-BTC-OpenInterest
get_marketdata_from_url '"https://api.alternative.me/fng/?limit=1&format=json" | jq -r .data[].value' CRYPTO_FEAR_AND_GREED-INDEX
# clear old stuff
find asset-histories/*INDEX* -type f -mtime +6 -delete
}
function get_marketdata_from_url {
g_echo_note "RUNNING FUNCTION ${FUNCNAME} $@"
local f_url="$1"
local f_name="$2"
## get data for analysis
if find asset-histories/${f_name}.history.csv -mmin -${INTERVAL_MIN} 2>/dev/null | grep -q "asset-histories/${f_name}.history.csv"
# download
g_wget -O "${f_histfile}.wget.tmp" $f_wget 2>"${f_histfile}.err.tmp" || f_failed=wget
[ -s "${f_histfile}.wget.tmp" ] || f_failed=wget
if [ -n "$f_failed" ]
then
g_echo_note "asset-histories/${f_name}.history.csv already downloaded in the last ${INTERVAL_MIN} minutes"
f_get_marketdata_price=$(cat MARKET_DATA_CMD_OUT-${f_name})
return 0
echo "g_wget -O \"${f_histfile}.wget.tmp\" $f_wget 2>\"${f_histfile}.err\"" >"${f_histfile}.err"
fi
# check source platform for parsing parameters, prepare and run wget command
>MARKET_DATA_CMD
if echo "${f_url}" | grep -q "boerse.de"
# jd
if [ -z "$f_failed" ] && [ -n "$f_jq" ]
then
echo "wget ${g_wget_opts} -q -O - ${f_url} | egrep 'itemprop=\"price\" content=\"[0-9]+\.[0-9]+\"' | sed s'#\"#\n#g' | egrep '^[0-9]+\.[0-9]+'" >MARKET_DATA_CMD
elif echo "${f_url}" | egrep -q "investing.com.+economic-calendar"
then
echo "wget ${g_wget_opts} -q -O - ${f_url} | egrep 'Actual.+Forecast.+Previous' | cut -d'>' -f7,11 | cut -d'<' -f1,2 | sed 's#,##g' | sed 's/\%//g' | sed 's#</div>#,#' | grep '[0-9]' | cut -d, -f1" >MARKET_DATA_CMD
elif echo "${f_url}" | egrep -q "investing.com.+indices"
then
echo "wget ${g_wget_opts} -q -O - ${f_url} | sed 's#</div>#\n#g' | grep 'text-5xl.*font-bold.*md:text-' | sed 's#^.*>##; s#,##g' | grep '[0-9]'" >MARKET_DATA_CMD
elif echo "${f_url}" | egrep -q '^"https://'
then
echo "wget -q -O - ${g_wget_opts} ${f_url}" >MARKET_DATA_CMD
else
# default to Yahoo Finace Symbols via API
echo "wget ${g_wget_opts} -q -O - https://query1.finance.yahoo.com/v8/finance/chart/${f_url} | jq -r '.[].result[].meta.regularMarketPrice'" >MARKET_DATA_CMD
fi
g_runcmd g_retrycmd sh MARKET_DATA_CMD >MARKET_DATA_CMD_OUT-${f_name}.tmp 2>MARKET_DATA_CMD_OUT-${f_name}.tmp.err
# check output
local f_get_marketdata_price_tmp=$(cat MARKET_DATA_CMD_OUT-${f_name}.tmp)
if g_num_valid_number ${f_get_marketdata_price_tmp}
then
if egrep -q "^0\.00" MARKET_DATA_CMD_OUT-${f_name}.tmp
if ! jq -r "$f_jq" "${f_histfile}.wget.tmp" >"${f_histfile}.tmp" 2>"${f_histfile}.err.tmp"
then
g_echo_note "Ignoring ${f_name} $(tail -n 10 MARKET_DATA_CMD_OUT-${f_name}.tmp) - maybe out of business day"
echo jq -r "$f_jq" "${f_histfile}.wget.tmp" >"${f_histfile}.err"
f_failed=jq
else
g_echo_note "${f_name}: ${f_get_marketdata_price_tmp}"
mv MARKET_DATA_CMD_OUT-${f_name}.tmp MARKET_DATA_CMD_OUT-${f_name}
mv "${f_histfile}.tmp" "${f_histfile}.wget.tmp"
fi
fi
# other/additional processing
if [ -z "$f_failed" ] && [ -n "$f_other" ]
then
if ! cat "${f_histfile}.wget.tmp" | eval $f_other
then
echo "cat \"${f_histfile}.wget.tmp\" | $f_other" >"${f_histfile}.err"
f_failed=other
fi
else
g_echo_warn "MARKET_DATA_CMD_OUT-${f_name}.tmp has wrong Syntax. - Not updating ${f_name} Index.
CMD:
$(tail -n 10 MARKET_DATA_CMD)
Output:
$(tail -n 10 MARKET_DATA_CMD_OUT-${f_name}.tmp | cat -t)
Error:
$(tail -n 10 MARKET_DATA_CMD_OUT-${f_name}.tmp.err | cat -t)"
mv "${f_histfile}.wget.tmp" "${f_histfile}.tmp"
fi
if ! [ -e "MARKET_DATA_CMD_OUT-${f_name}" ]
# cleanup
rm -f "${f_histfile}.wget.tmp" "${f_histfile}.err.tmp"
# error if no csvfile available
if [ -n "$f_failed" ] || ! [ -s "${f_histfile}.tmp" ]
then
local f_old_value=$(tail -n 1 asset-histories/${f_name}.history.csv | cut -d, -f2)
if echo ${f_old_value} | egrep -q "^[0-9]*\.[0-9]+"
cat "${f_histfile}.err.tmp" >>"${f_histfile}.err"
cat "${f_histfile}.wget.tmp" >>"${f_histfile}.err"
cat "${f_histfile}.err" 1>&2
mkdir -p FAILED_MARKETDATA
mv "${f_histfile}.err" "FAILED_MARKETDATA/MARKETDATA-${f_name}" 2>/dev/null
return 1
fi
# on first download
if ! [ -s "${f_histfile}" ]
then
grep ^[2-9] "${f_histfile}.tmp" | sort -k1,1 -t, -u >"${f_histfile}"
else
# merge data
egrep -h ^[0-9][0-9][0-9][0-9]-[0-9][0-9] "${f_histfile}" "${f_histfile}.tmp" | sort -k1,1 -t, -u >"${g_tmp}/${FUNCNAME}.tmp"
# if there is new dataline add it
if ! cmp -s "${g_tmp}/${FUNCNAME}.tmp" "${f_histfile}"
then
echo ${f_old_value} >MARKET_DATA_CMD_OUT-${f_name}
else
echo 0 >MARKET_DATA_CMD_OUT-${f_name}
cat "${g_tmp}/${FUNCNAME}.tmp" >"${f_histfile}"
fi
fi
f_get_marketdata_price=$(cat MARKET_DATA_CMD_OUT-${f_name})
echo "${f_timestamp},${f_get_marketdata_price}" >>asset-histories/${f_name}.history.csv
rm "${f_histfile}.tmp"
# calc indicators ans if 1d then generate 1w histfile
if [[ $f_interval = 1d ]]
then
get_indicators "${f_histfile}"
convert_ohlcv_1d_to_1w "${f_histfile}" "${f_histfile/.1d./.1w.}"
get_indicators "${f_histfile/.1d./.1w.}"
else
get_indicators "${f_histfile}" 999
fi
}
#https://production.dataviz.cnn.io/index/fearandgreed/graphdata

View File

@ -54,7 +54,7 @@ function get_ohlcv-candles {
get_ohlcv-candle "${f_eco_asset}" ${f_timeframe} "${f_histfile}" "ECONOMY-${f_eco_asset}"
fi
# refresh latest indicators
[ -s "${f_histfile}" ] && get_indicators "${f_histfile}" 900
[ -s "${f_histfile}" ] && get_indicators "${f_histfile}" 51
done
done
@ -83,7 +83,7 @@ function get_ohlcv-candles {
get_ohlcv-candle "$f_symbol" $f_timeframe "${f_histfile}" && printf '%(%Y-%m-%d %H:%M:%S)T' >>"$f_histfile.fetched"
# refresh latest indicators
get_indicators "${f_histfile}" 900
get_indicators "${f_histfile}" 51
rm -f "${f_histfile}.fetching"
@ -664,5 +664,3 @@ function f_add_missing_ohlcv_intervals {
cat "$g_tmp/f_add_missing_ohlcv_intervals_result" >"$f_histfile"
fi
}

View File

@ -22,9 +22,19 @@ function get_values {
g_echo_note "RUNNING FUNCTION ${FUNCNAME} $@"
local f_assets="$@"
local f_asset_histories
f_assets=${f_assets//:$CURRENCY/}
f_assets=${f_assets//\//}
for f_asset in $f_assets
do
f_asset_histories+="$f_asset "
f_asset_histories+="MARKETDATA_BINANCE_OPEN_INTEREST_$f_asset "
f_asset_histories+="MARKETDATA_BINANCE_LONG_SHORT_RATIO_TAKER_$f_asset "
f_asset_histories+="MARKETDATA_BINANCE_LONG_SHORT_RATIO_ACCOUNT_$f_asset "
done
local f_eco_asset f_eco_assets f_asset f_time f_prefix f_histfile f_columns f_return f_levelsfile f_tmp_levels f_first
for f_eco_asset in $ECO_ASSETS
@ -40,25 +50,33 @@ function get_values {
# get current prices from exchange
get_symbols_ticker
# get values from csv files
#f_first=true
for f_asset in $f_assets BTC${CURRENCY} $f_eco_assets
for f_asset in $f_asset_histories\
BTC${CURRENCY}\
$f_eco_assets\
MARKETDATA_BINANCE_OPEN_INTEREST_BTC${CURRENCY}\
MARKETDATA_BINANCE_LONG_SHORT_RATIO_TAKER_BTC${CURRENCY}\
MARKETDATA_BINANCE_LONG_SHORT_RATIO_ACCOUNT_BTC${CURRENCY}\
MARKETDATA_FEAR_AND_GREED_ALTERNATIVEME\
MARKETDATA_FEAR_AND_GREED_CNN\
MARKETDATA_US_CONSUMER_PRICE_INDEX_CPI\
MARKETDATA_US_FED_FUNDS_RATE MARKETDATA_US_UNEMPLOYMENT_RATE
do
# read latest ohlcv data and indicators per timeframe to vars
for f_time in 5m 15m 1h 4h 1d 1w
do
#f_prefix="${f_asset}_${f_time}_"
#[ "$f_first" = "true" ] && f_prefix="${f_time}_"
# special on ECONOMY data
f_prefix="${f_time}_"
if [[ "$f_asset" =~ ^ECONOMY- ]]
then
f_prefix="${f_asset}_${f_time}_"
f_prefix=${f_prefix//-/_}
fi
# histfile
f_histfile="asset-histories/${f_asset}.history.${f_time}.csv"
if ! [ -s "$f_histfile" ]
then
[ "$f_time" = "1w" ] || g_echo_warn "file $f_histfile empty or does not exist"
f_return=1
continue
fi

View File

@ -136,7 +136,6 @@ function order {
g_echo_warn "Short Order not possible:TakeProfit ($f_takeprofit) higher then buy price ($f_price)"
return 1
fi
f_ccxt "print($STOCK_EXCHANGE.priceToPrecision('${f_symbol}', ${f_takeprofit}))"
f_takeprofit=$f_ccxt_result
f_params="${f_params}'takeProfitPrice': '$f_takeprofit', "