diff --git a/dabo/functions/run_strategies.sh b/dabo/functions/run_strategies.sh index 84ec85f..bef140b 100644 --- a/dabo/functions/run_strategies.sh +++ b/dabo/functions/run_strategies.sh @@ -37,7 +37,7 @@ function run_strategies { g_echo_error "Error in ${f_strategy} $(cat $g_tmp/strat_bash_error)" continue fi - g_echo_note "Runnign strategy ${f_strategy}" + g_echo_note "Running strategy ${f_strategy}" . "${f_strategy}" || g_echo_warn "Failed ${f_strategy}" done diff --git a/strategies/example_manage_positions.strategy.sh b/strategies/example_manage_positions.strategy.sh index 279ade4..6d89bdd 100644 --- a/strategies/example_manage_positions.strategy.sh +++ b/strategies/example_manage_positions.strategy.sh @@ -42,8 +42,17 @@ do # check for already existing stoploss if [ -n "${o[${asset}_sl_close_${side}_id]}" ] then + # do nothing if current stoploss price is already larger/equal then half of current pnl - g_num_is_higher_equal ${o[${asset}_sl_close_${side}_stopprice]} $stoploss_price && continue + if [[ $side = long ]] + then + g_num_is_higher_equal ${o[${asset}_sl_close_${side}_stopprice]} $stoploss_price && continue + fi + if [[ $side = short ]] + then + g_num_is_lower_equal ${o[${asset}_sl_close_${side}_stopprice]} $stoploss_price && continue + fi + # cancel existing stoploss order order_cancel_id "$symbol" "${o[${asset}_sl_close_${side}_id]}" || continue fi