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
### MAIN ###
g_echo_warn "STARTING DABO BOT $0"
g_echo_note "STARTING DABO BOT $0"
touch firstloop
export FULL_LOOP=1
@ -51,9 +51,6 @@ do
. ../../dabo-bot.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
export f_timestamp=$(g_date_print)
@ -101,8 +98,8 @@ do
# Get current symbols
[ ${FULL_LOOP} = 1 ] && get_symbols
# Get current assets
get_assets || continue
## Get current assets
#get_assets || continue
# Sell something?
#check_for_sell
@ -117,12 +114,12 @@ do
[ ${FULL_LOOP} = 1 ] && check_for_buy
# Update webpage
if jobs | egrep -q "Running.+webpage" && [ ${FULL_LOOP} = 1 ]
then
g_echo_note "webpage already running"
else
webpage &
fi
#if jobs | egrep -q "Running.+webpage" && [ ${FULL_LOOP} = 1 ]
#then
# g_echo_note "webpage already running"
#else
# webpage &
#fi
done

View File

@ -14,10 +14,8 @@ function f_ccxt {
return 1
fi
#unset g_ccxt_jobs
#local g_ccxt_jobs
mapfile -t g_ccxt_jobs < <(jobs -r)
# Initialize ccxt in python if not initialized
mapfile -t g_ccxt_jobs < <(jobs -r)
[[ ${g_ccxt_jobs[*]} =~ *python-pipeexec.py* ]] || unset f_ccxt_initialized
if [ -z "$f_ccxt_initialized" ]
then
@ -44,14 +42,18 @@ function f_ccxt {
# reference result to 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=""
if ! [ "$f_ccxt_result" = '[]' ]
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" ]
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// None/ null}
f_ccxt_result=${f_ccxt_result// True/ true}
@ -62,6 +64,3 @@ function f_ccxt {
return 0
}

View File

@ -87,6 +87,9 @@ function currency_converter {
if [ -n "$f_rate" ]
then
[[ $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
fi
fi

View File

@ -27,17 +27,23 @@ function get_assets {
mv ASSETS.tmp ASSETS
## write histfiles parallel
local f_ASSET
local f_parallel_arg
echo -n "parallel -j3 bash -c --" >/tmp/parallel
#local f_ASSET
#local f_parallel_arg
#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}")
do
#get_asset "${f_ASSET}"
echo -n " \"get_asset ${f_ASSET}\"" >>/tmp/parallel
get_asset "${f_ASSET}"
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 = "BEER-USD" ]] && f_item="BEER31337-USD"
[[ $f_item = "TAI-USD" ]] && f_item="TAI20605-USD"
[[ $f_item = "DEFI-USD" ]] && f_item="DEFI29200-USD"
# end if already failed the last hour
if [ -f FAILED_YAHOO_${f_name}_HISTORIC_DOWNLOAD ]
if [ -f FAILED_YAHOO/${f_name}_HISTORIC_DOWNLOAD ]
then
find "FAILED_YAHOO_${f_name}_HISTORIC_DOWNLOAD" -mmin +60 -delete
if [ -f FAILED_YAHOO_${f_name}_HISTORIC_DOWNLOAD ]
find "FAILED_YAHOO/${f_name}_HISTORIC_DOWNLOAD" -mmin +60 -delete
if [ -f FAILED_YAHOO/${f_name}_HISTORIC_DOWNLOAD ]
then
#g_echo_note "${f_targetcsv} already failed to downloaded within last hour"
return 1
@ -65,7 +66,8 @@ function get_marketdata_yahoo_historic {
#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
fi
}

View File

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

View File

@ -2,17 +2,9 @@ function get_symbols {
g_echo_note "RUNNING FUNCTION ${FUNCNAME} $@"
f_ccxt "print($STOCK_EXCHANGE.symbols)"
if [ -z "$f_ccxt_json_out" ]
then
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//\]}
local f_symbols=""
[ -s CCXT_TICKERS_RAW ] && f_symbols=$(jq -r '.[] | .symbol' CCXT_TICKERS_RAW)
f_symbols=${f_symbols//$'\n'/'+'}
if [ -z "$f_symbols" ]
then
@ -20,9 +12,8 @@ function get_symbols {
return 1
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
}