fixes and switch to ccxt

This commit is contained in:
olli 2024-06-14 19:56:43 +02:00
parent 73081d1309
commit c2ee85d7b6
7 changed files with 49 additions and 49 deletions

View File

@ -3,7 +3,7 @@
. /dabo/dabo-prep.sh . /dabo/dabo-prep.sh
### MAIN ### ### MAIN ###
g_echo_warn "STARTING DABO BOT $0" g_echo_note "STARTING DABO BOT $0"
touch firstloop touch firstloop
export FULL_LOOP=1 export FULL_LOOP=1
@ -51,9 +51,6 @@ do
. ../../dabo-bot.conf . ../../dabo-bot.conf
. ../../dabo-bot.override.conf . ../../dabo-bot.override.conf
# Headline
export csv_headline="Date and Time,Price,Change,EMA12,EMA26,MACD,EMA9 (Sig.),Histogram,MACD Sig.,RSI5,RSI14,RSI21,RSI720,RSI60,RSI120,RSI240,RSI420,Coingecko Change 24h,Coingecko Change 7d,Coingecko Change 14d,Coingecko Change 30d,Coingecko Change 1y,Coingecko MarketCap Change 24h,RANGE DATE,LOWEST IN RANGE,HIGHEST IN RANGE,PIVOT POINT,SUPPORT1,RESIST1,GOLDEN POCKET SUPPORT,GOLDEN POCKET RESIST,GOLDEN POCKET 65 SUPPORT,GOLDEN POCKET 65 RESIST,SUPPORT3,RESIST3,EMA50,EMA100,EMA200,EMA800,Coingecko Price"
# Timestamp # Timestamp
export f_timestamp=$(g_date_print) export f_timestamp=$(g_date_print)
@ -101,8 +98,8 @@ do
# Get current symbols # Get current symbols
[ ${FULL_LOOP} = 1 ] && get_symbols [ ${FULL_LOOP} = 1 ] && get_symbols
# Get current assets ## Get current assets
get_assets || continue #get_assets || continue
# Sell something? # Sell something?
#check_for_sell #check_for_sell
@ -117,12 +114,12 @@ do
[ ${FULL_LOOP} = 1 ] && check_for_buy [ ${FULL_LOOP} = 1 ] && check_for_buy
# Update webpage # Update webpage
if jobs | egrep -q "Running.+webpage" && [ ${FULL_LOOP} = 1 ] #if jobs | egrep -q "Running.+webpage" && [ ${FULL_LOOP} = 1 ]
then #then
g_echo_note "webpage already running" # g_echo_note "webpage already running"
else #else
webpage & # webpage &
fi #fi
done done

View File

@ -14,10 +14,8 @@ function f_ccxt {
return 1 return 1
fi fi
#unset g_ccxt_jobs
#local g_ccxt_jobs
mapfile -t g_ccxt_jobs < <(jobs -r)
# Initialize ccxt in python if not initialized # Initialize ccxt in python if not initialized
mapfile -t g_ccxt_jobs < <(jobs -r)
[[ ${g_ccxt_jobs[*]} =~ *python-pipeexec.py* ]] || unset f_ccxt_initialized [[ ${g_ccxt_jobs[*]} =~ *python-pipeexec.py* ]] || unset f_ccxt_initialized
if [ -z "$f_ccxt_initialized" ] if [ -z "$f_ccxt_initialized" ]
then then
@ -44,14 +42,18 @@ function f_ccxt {
# reference result to python-result # reference result to python-result
declare -ng f_ccxt_result=g_python_result declare -ng f_ccxt_result=g_python_result
# Check for json output # Check for json output or empty json output
f_ccxt_json_out="" f_ccxt_json_out=""
[[ $f_ccxt_result =~ ^\[ ]] && [[ $f_ccxt_result =~ \]$ ]] && f_ccxt_json_out=1 if ! [ "$f_ccxt_result" = '[]' ]
[[ $f_ccxt_result =~ ^\{ ]] && [[ $f_ccxt_result =~ \}$ ]] && f_ccxt_json_out=1 then
[[ $f_ccxt_result =~ ^\[ ]] && [[ $f_ccxt_result =~ \]$ ]] && f_ccxt_json_out=1
[[ $f_ccxt_result =~ ^\{ ]] && [[ $f_ccxt_result =~ \}$ ]] && f_ccxt_json_out=1
fi
# make the output jq-conform if json poutput
# avoids errors like: "parse error: Invalid numeric literal at"
if [ -n "$f_ccxt_json_out" ] if [ -n "$f_ccxt_json_out" ]
then then
# make the output jq-conform
# avoids errors like: "parse error: Invalid numeric literal at"
f_ccxt_result=${f_ccxt_result//\'/\"} f_ccxt_result=${f_ccxt_result//\'/\"}
f_ccxt_result=${f_ccxt_result// None/ null} f_ccxt_result=${f_ccxt_result// None/ null}
f_ccxt_result=${f_ccxt_result// True/ true} f_ccxt_result=${f_ccxt_result// True/ true}
@ -62,6 +64,3 @@ function f_ccxt {
return 0 return 0
} }

View File

@ -87,6 +87,9 @@ function currency_converter {
if [ -n "$f_rate" ] if [ -n "$f_rate" ]
then then
[[ $f_histfile =~ ${f_currency}${f_currency_target} ]] && f_reverse=true [[ $f_histfile =~ ${f_currency}${f_currency_target} ]] && f_reverse=true
[ $f_currency_target = "USD" ] && f_reverse=true
[ $f_currency = "USD" ] && f_reverse=false
[ $f_currency_target = "EUR" ] && [ $f_currency = "USD" ] && f_reverse=true
[[ $f_line =~ ^$f_currency_date_hour ]] && break [[ $f_line =~ ^$f_currency_date_hour ]] && break
fi fi
fi fi

View File

@ -27,17 +27,23 @@ function get_assets {
mv ASSETS.tmp ASSETS mv ASSETS.tmp ASSETS
## write histfiles parallel ## write histfiles parallel
local f_ASSET #local f_ASSET
local f_parallel_arg #local f_parallel_arg
echo -n "parallel -j3 bash -c --" >/tmp/parallel #echo -n "parallel -j3 bash -c --" >/tmp/parallel
#for f_ASSET in $(cat ASSETS | egrep -v "${BLACKLIST}")
#do
# #get_asset "${f_ASSET}"
# echo -n " \"get_asset ${f_ASSET}\"" >>/tmp/parallel
#done
#export f_timestamp
#export csv_headline
#. /tmp/parallel
## alternatively single jobs (for debugging!?)
for f_ASSET in $(cat ASSETS | egrep -v "${BLACKLIST}") for f_ASSET in $(cat ASSETS | egrep -v "${BLACKLIST}")
do do
#get_asset "${f_ASSET}" get_asset "${f_ASSET}"
echo -n " \"get_asset ${f_ASSET}\"" >>/tmp/parallel
done done
export f_timestamp
export csv_headline
. /tmp/parallel
} }

View File

@ -19,12 +19,13 @@ function get_marketdata_yahoo_historic {
[[ $f_item = "BLAZE-USD" ]] && f_item="BLAZE30179-USD" [[ $f_item = "BLAZE-USD" ]] && f_item="BLAZE30179-USD"
[[ $f_item = "BEER-USD" ]] && f_item="BEER31337-USD" [[ $f_item = "BEER-USD" ]] && f_item="BEER31337-USD"
[[ $f_item = "TAI-USD" ]] && f_item="TAI20605-USD" [[ $f_item = "TAI-USD" ]] && f_item="TAI20605-USD"
[[ $f_item = "DEFI-USD" ]] && f_item="DEFI29200-USD"
# end if already failed the last hour # end if already failed the last hour
if [ -f FAILED_YAHOO_${f_name}_HISTORIC_DOWNLOAD ] if [ -f FAILED_YAHOO/${f_name}_HISTORIC_DOWNLOAD ]
then then
find "FAILED_YAHOO_${f_name}_HISTORIC_DOWNLOAD" -mmin +60 -delete find "FAILED_YAHOO/${f_name}_HISTORIC_DOWNLOAD" -mmin +60 -delete
if [ -f FAILED_YAHOO_${f_name}_HISTORIC_DOWNLOAD ] if [ -f FAILED_YAHOO/${f_name}_HISTORIC_DOWNLOAD ]
then then
#g_echo_note "${f_targetcsv} already failed to downloaded within last hour" #g_echo_note "${f_targetcsv} already failed to downloaded within last hour"
return 1 return 1
@ -65,7 +66,8 @@ function get_marketdata_yahoo_historic {
#ERR: #ERR:
#$(cat "${f_targetcsvtmp}".err) #$(cat "${f_targetcsvtmp}".err)
#" #"
mv ${f_targetcsvtmp}.err FAILED_YAHOO_${f_name}_HISTORIC_DOWNLOAD mkdir -p FAILED_YAHOO
mv ${f_targetcsvtmp}.err FAILED_YAHOO/${f_name}_HISTORIC_DOWNLOAD
return 1 return 1
fi fi
} }

View File

@ -23,7 +23,9 @@ function get_positions {
select(.entryPrice != 0) | select(.entryPrice != 0) |
.symbol + \",\" + (.notional|tostring) + \",\" + (.entryPrice|tostring) + \",\" + (.markPrice|tostring) + \",\" + .side + \",\" + (.leverage|tostring) .symbol + \",\" + (.notional|tostring) + \",\" + (.entryPrice|tostring) + \",\" + (.markPrice|tostring) + \",\" + .side + \",\" + (.leverage|tostring)
" CCXT_POSITIONS_RAW >POSITIONS " CCXT_POSITIONS_RAW >POSITIONS
get_position_array get_position_array
} }
function get_position_array { function get_position_array {

View File

@ -2,17 +2,9 @@ function get_symbols {
g_echo_note "RUNNING FUNCTION ${FUNCNAME} $@" g_echo_note "RUNNING FUNCTION ${FUNCNAME} $@"
f_ccxt "print($STOCK_EXCHANGE.symbols)" local f_symbols=""
if [ -z "$f_ccxt_json_out" ] [ -s CCXT_TICKERS_RAW ] && f_symbols=$(jq -r '.[] | .symbol' CCXT_TICKERS_RAW)
then f_symbols=${f_symbols//$'\n'/'+'}
g_echo_warn "Could not get symbols list - no json output"
return 1
fi
local f_symbols=${f_ccxt_result}
f_symbols=${f_symbols//\"}
f_symbols=${f_symbols//, /+}
f_symbols=${f_symbols//\[}
f_symbols=${f_symbols//\]}
if [ -z "$f_symbols" ] if [ -z "$f_symbols" ]
then then
@ -20,9 +12,8 @@ function get_symbols {
return 1 return 1
fi fi
g_array "$f_symbols" f_symbols_array + g_array "$f_symbols" f_symbols_array_ref +
f_symbols_array=("${g_array[@]}")
printf '%s\n' "${f_symbols_array[@]}" >SYMBOLS-$STOCK_EXCHANGE printf '%s\n' "${f_symbols_array[@]}" >SYMBOLS-$STOCK_EXCHANGE
} }