Compare commits

..

No commits in common. "bae56de644cb68b7ee9b4b9c2fb3423f1908ba56" and "655c3b403255a6172bc0e95c55342585317674d4" have entirely different histories.

10 changed files with 118 additions and 246 deletions

View File

@ -30,8 +30,8 @@ do
# Reload Config
. ../../dabo-bot.conf
. ../../dabo-bot.override.conf
# get all indicators
# get orders
get_indicators_all
rm -f asset-histories/*.history.*.csv.indicators-calculating
rm 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 120
sleep 12
while true
do
@ -33,7 +33,6 @@ do
# get levels
get_levels_all
rm -f asset-histories/*.history.*.csv.levels-calculating
# recalc every 6 hours
sleep 21600
sleep 900
done

View File

@ -32,21 +32,16 @@ do
. ../../dabo-bot.conf
. ../../dabo-bot.override.conf
# notify 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
[ "$interval" = "1d" ] && cat FAILED_*/* 2>/dev/null | notify.sh -s "Failed downloads"
# 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,6 +40,9 @@ 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"
@ -55,12 +58,6 @@ 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
@ -97,6 +94,7 @@ 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,13 +51,7 @@ function currency_converter {
f_currency_date_day=$(date -d "${f_currency_date}" "+%Y-%m-%d")
# month failback
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,8 +26,7 @@ function get_indicators_all {
local f_histfile f_symbol
# 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
find asset-histories -maxdepth 1 -name "ECONOMY-*.history.[0-5][5dhwm]*.csv" | sort | while read f_histfile
do
if [ -s "${f_histfile}.fetching" ] || [ -s "${f_histfile}.indicators-calculating" ]
then
@ -70,7 +69,7 @@ function get_indicators_all {
fi
done
done
shopt -u nullglob
shopt +s nullglob
}
@ -83,27 +82,17 @@ 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 f_last_year
local f_ema f_change f_changed f_line f_valid_data f_ath
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}]}" ] || [ -z "${v_csv_array_associative[open_${i}]}" ]
if [ -z "${v_csv_array_associative[date_${i}]}" ]
then
g_echo_note "No data $f_histfile:${v_csv_array_associative[date_${i}]}"
return 0
@ -116,42 +105,16 @@ 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
# 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
#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
fi
# ath (all-time-high) of present data
@ -172,20 +135,10 @@ function get_indicators {
# check for missing EMAs
for f_ema_column in $f_emas
do
# 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
# check for enough values/lines to calculate EMA
[ $i -ge $f_ema_column ] || continue
# calculate EMA
if [ -z "${v_csv_array_associative[ema${f_ema_column}_${i}]}" ]
then
calc_ema ${f_ema_column} close && f_change=1
fi
[ -z "${v_csv_array_associative[ema${f_ema_column}_${i}]}" ] && calc_ema ${f_ema_column} close && f_change=1
done
# check for missing RSI
@ -211,11 +164,6 @@ 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,142 +17,95 @@
# 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
# 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
echo "g_wget -O \"${f_histfile}.wget.tmp\" $f_wget 2>\"${f_histfile}.err\"" >"${f_histfile}.err"
fi
### CPI Data: curl hapi.bls.gov/publicAPI/v2/timeseries/data/cpi | jq -a
### release dates: https://www.bls.gov/schedule/news_release/bls.ics
# jd
if [ -z "$f_failed" ] && [ -n "$f_jq" ]
then
if ! jq -r "$f_jq" "${f_histfile}.wget.tmp" >"${f_histfile}.tmp" 2>"${f_histfile}.err.tmp"
then
echo jq -r "$f_jq" "${f_histfile}.wget.tmp" >"${f_histfile}.err"
f_failed=jq
else
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
mv "${f_histfile}.wget.tmp" "${f_histfile}.tmp"
fi
# 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
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
cat "${g_tmp}/${FUNCNAME}.tmp" >"${f_histfile}"
fi
fi
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
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
}
#https://production.dataviz.cnn.io/index/fearandgreed/graphdata
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"
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
fi
# check source platform for parsing parameters, prepare and run wget command
>MARKET_DATA_CMD
if echo "${f_url}" | grep -q "boerse.de"
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
then
g_echo_note "Ignoring ${f_name} $(tail -n 10 MARKET_DATA_CMD_OUT-${f_name}.tmp) - maybe out of business day"
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}
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)"
fi
if ! [ -e "MARKET_DATA_CMD_OUT-${f_name}" ]
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]+"
then
echo ${f_old_value} >MARKET_DATA_CMD_OUT-${f_name}
else
echo 0 >MARKET_DATA_CMD_OUT-${f_name}
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
}

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}" 51
[ -s "${f_histfile}" ] && get_indicators "${f_histfile}" 900
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}" 51
get_indicators "${f_histfile}" 900
rm -f "${f_histfile}.fetching"
@ -664,3 +664,5 @@ function f_add_missing_ohlcv_intervals {
cat "$g_tmp/f_add_missing_ohlcv_intervals_result" >"$f_histfile"
fi
}

View File

@ -22,19 +22,9 @@ 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
@ -50,33 +40,25 @@ function get_values {
# get current prices from exchange
get_symbols_ticker
# get values from csv files
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
#f_first=true
for f_asset in $f_assets BTC${CURRENCY} $f_eco_assets
do
# read latest ohlcv data and indicators per timeframe to vars
for f_time in 5m 15m 1h 4h 1d 1w
do
# special on ECONOMY data
#f_prefix="${f_asset}_${f_time}_"
#[ "$f_first" = "true" ] && f_prefix="${f_time}_"
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,6 +136,7 @@ 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', "