diff --git a/dabo/functions/get_ohlcv-candle.sh b/dabo/functions/get_ohlcv-candle.sh index 22157ed..8157c11 100644 --- a/dabo/functions/get_ohlcv-candle.sh +++ b/dabo/functions/get_ohlcv-candle.sh @@ -391,7 +391,16 @@ function convert_ohlcv_1h_to_1d { local f_today=$(TZ="$f_target_timezone" date "+%Y-%m-%d") - grep -A9999 -B24 "^$f_latestdate" "$f_input_file" | grep ':00:00,' | cut -d, -f1,2,3,4,5,6 | while read f_line + # check if there is a $f_latestdate + grep -A9999 -B24 "^$f_latestdate" "$f_input_file" >"$g_tmp/convert_ohlcv_1h_to_1d_nextlines" + if ! [ -s "$g_tmp/convert_ohlcv_1h_to_1d_nextlines" ] + then + cat "$f_input_file" >"$g_tmp/convert_ohlcv_1h_to_1d_nextlines" + f_nextdate=$(date -d "$(head -n1 "$g_tmp/convert_ohlcv_1h_to_1d_nextlines" | cut -d, -f1)" +%Y-%m-%d) + fi + + # go through lines + cat "$g_tmp/convert_ohlcv_1h_to_1d_nextlines" | grep ':00:00,' | cut -d, -f1,2,3,4,5,6 | while read f_line do g_array "$f_line" g_line_array , # calculate day in target timezone @@ -456,6 +465,9 @@ function convert_ohlcv_1h_to_1d { } function convert_ohlcv_1d_to_1w { + + g_echo_note "RUNNING FUNCTION ${FUNCNAME} $@" + local f_input_file=$1 local f_output_file=$2 @@ -472,8 +484,15 @@ function convert_ohlcv_1d_to_1w { # if not exists use first date as latest date [ -z "$f_latestdate" ] && f_latestdate=$(date -d "$(head -n1 "$f_input_file" | cut -d, -f1)" +%Y-%m-%d) + # check if there is a $f_latestdate + grep -A9999 -B9 "^$f_latestdate" "$f_input_file" >"$g_tmp/convert_ohlcv_1d_to_1w_nextlines" + if ! [ -s "$g_tmp/convert_ohlcv_1d_to_1w_nextlines" ] + then + cat "$f_input_file" >"$g_tmp/convert_ohlcv_1d_to_1w_nextlines" + fi + # go through lines - for f_line in $(grep -A9999 -B9 "^$f_latestdate" "$f_input_file") + for f_line in $(cat "$g_tmp/convert_ohlcv_1d_to_1w_nextlines") do 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" diff --git a/dabo/functions/get_orders.sh b/dabo/functions/get_orders.sh index 2f356aa..b2a3230 100644 --- a/dabo/functions/get_orders.sh +++ b/dabo/functions/get_orders.sh @@ -120,7 +120,7 @@ function get_order_line_vars { then o[${f_asset}_present]=${f_type} else - o[${f_asset}_present]=${o[${f_asset}_present]},${f_type} + o[${f_asset}_present]="${o[${f_asset}_present]} ${f_type}" fi o[${f_asset}_${f_type}_type]=${f_order_array[1]} o[${f_asset}_${f_type}_side]=${f_order_array[2]} diff --git a/dabo/functions/order.sh b/dabo/functions/order.sh index bf54bbf..da4f19f 100644 --- a/dabo/functions/order.sh +++ b/dabo/functions/order.sh @@ -89,11 +89,18 @@ function order { fi # Add stoploos and take profit if available - if [ -n "$f_stoploss" ] + if [ -n "$f_stoploss" ] then - if g_num_is_higher_equal $f_stoploss $f_price + # check for long + if [[ $f_side = buy ]] && g_num_is_higher_equal $f_stoploss $f_price then - g_echo_warn "Order not possible: Stoploss ($f_stoploss) higher then buy price ($f_price)" + g_echo_warn "Long Order not possible: Stoploss ($f_stoploss) higher then buy price ($f_price)" + return 1 + fi + # check for short + if [[ $f_side = sell ]] && g_num_is_lower_equal $f_stoploss $f_price + then + g_echo_warn "Short Order not possible: Stoploss ($f_stoploss) lower then buy price ($f_price)" return 1 fi f_ccxt "print($STOCK_EXCHANGE.priceToPrecision('${f_symbol}', ${f_stoploss}))" @@ -102,11 +109,19 @@ function order { fi if [ -n "$f_takeprofit" ] then - if g_num_is_lower_equal $f_takeprofit $f_price + # check for long + if [[ $f_side = buy ]] && g_num_is_lower_equal $f_takeprofit $f_price then - g_echo_warn "Order not possible:TakeProfit ($f_takeprofit) lower then buy price ($f_price)" + g_echo_warn "Long Order not possible:TakeProfit ($f_takeprofit) lower then buy price ($f_price)" return 1 fi + # check for short + if [[ $f_side = sell ]] && g_num_is_higher_equal $f_takeprofit $f_price + then + 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', " diff --git a/dabo/functions/webpage.sh b/dabo/functions/webpage.sh index 47df784..0b9ce23 100644 --- a/dabo/functions/webpage.sh +++ b/dabo/functions/webpage.sh @@ -105,20 +105,24 @@ function webpage { echo '

Open Orders

' >>../index.html.tmp echo "" >>../index.html.tmp get_orders_array + local f_type for f_symbol in ${f_symbols_array_trade[@]} do f_asset=${f_symbol//:$CURRENCY/} f_asset=${f_asset//\//} - [ -z "${o[${f_asset}_entry_price]}" ] && continue - [ "${o[${f_asset}_entry_price]}" = "null" ] && continue - echo " + for f_type in ${o[${f_asset}_present]} + do + [ -z "${o[${f_asset}_${f_type}_entry_price]}" ] && continue + [ "${o[${f_asset}_${f_type}_entry_price]}" = "null" ] && continue + echo " - - - - - + + + + +" >>../index.html.tmp + done done echo "
SymbolAmountEntry PriceStopLossTakeProfitNotes
$f_symbol${o[${f_asset}_amount]}${o[${f_asset}_entry_price]}${o[${f_asset}_stoplossprice]}${o[${f_asset}_takeprofitprice]}${o[${f_asset}_type]} ${p[${f_asset}_side]}${o[${f_asset}_${f_type}_amount]}${o[${f_asset}_${f_type}_entry_price]}${o[${f_asset}_${f_type}_stoplossprice]}${o[${f_asset}_${f_type}_takeprofitprice]}${o[${f_asset}_${f_type}_type]} ${p[${f_asset}_${f_type}_side]}
" >>../index.html.tmp diff --git a/dabo/functions/webpage_transactions.sh b/dabo/functions/webpage_transactions.sh index 89de507..346d34f 100644 --- a/dabo/functions/webpage_transactions.sh +++ b/dabo/functions/webpage_transactions.sh @@ -47,7 +47,7 @@ function webpage_transactions { local f_tax=$(cat ALL_TRANSACTIONS_OVERVIEW.csv | grep "^$f_tax_year-" | cut -d, -f 2,13,14 | egrep -v ',,0$' | grep "$f_exchange_tax_type" | cut -d, -f3 | awk "{ SUM += \$1} END { printf(\"%.2f\", SUM) }") #echo "$f_exchange_tax_type: $f_tax" - #echo "$f_tax_type: $f_tax EUR
" >>${g_tmp}/tax_summary_$f_exchange-$f_tax_year + echo "$f_tax_type: $f_tax EUR
" >>${g_tmp}/tax_summary_$f_exchange-$f_tax_year echo "