Compare commits

...

3 Commits

Author SHA1 Message Date
0f62e2ffbd fix 2024-08-30 17:33:12 +02:00
051798ed00 array and vars 2024-08-30 17:32:54 +02:00
fa6dd07417 cancel orders 2024-08-30 17:32:27 +02:00
3 changed files with 70 additions and 7 deletions

View File

@ -114,6 +114,9 @@ do
# Get current positions
[ ${FULL_LOOP} = 1 ] && get_positions || continue
# Get current orders
[ ${FULL_LOOP} = 1 ] && get_orders || continue
## Run strategies
[ ${FULL_LOOP} = 1 ] && run_strategies

View File

@ -43,23 +43,43 @@ function get_orders {
fi
[ -z "$f_symbols" ] && return 1
for f_symbol in "${f_symbols[@]}"
for f_symbol in ${f_symbols_array_trade[@]}
do
f_symbol_file=${f_symbol//:*}
f_symbol_file=${f_symbol_file///}
g_echo_note "Getting orders from $f_symbol to \"CCXT_OPEN_ORDERS_$f_symbol_file\""
g_echo_note "Getting orders from $f_symbol to \"CCXT_ORDERS_$f_symbol_file\""
if f_ccxt "print($STOCK_EXCHANGE.fetchOpenOrders(symbol='${f_symbol}'))"
then
echo $f_ccxt_result | tee "CCXT_OPEN_ORDERS_${f_symbol_file}_RAW" | jq -r "
echo $f_ccxt_result | tee "CCXT_ORDERS_${f_symbol_file}_RAW" | jq -r "
.[] |
select(.status==\"open\") |
.symbol + \",\" + .type + \",\" + .side + \",\" + (.price|tostring) + \",\" + (.stopPrice|tostring) + \",\" + (.amount
|tostring)
" >"CCXT_OPEN_ORDERS_${f_symbol_file}"
.symbol + \",\" + .type + \",\" + .side + \",\" + (.price|tostring) + \",\" + (.amount|tostring) + \",\" + .id + \",\" + (.stopLossPrice|tostring) + \",\" + (.takeProfitPrice|tostring)
" >"CCXT_ORDERS_${f_symbol_file}"
else
rm -f "CCXT_OPEN_ORDERS_${f_symbol_file}_RAW" "CCXT_OPEN_ORDERS_${f_symbol_file}"
rm -f "CCXT_ORDERS_${f_symbol_file}_RAW" "CCXT_ORDERS_${f_symbol_file}"
continue
fi
done
cat CCXT_ORDERS_*${CURRENCY} >CCXT_ORDERS
}
function get_orders_array {
g_array CCXT_ORDERS f_get_ordes_rarray
}
function get_orders_line_vars {
local f_order_line=$1
g_array $f_order_line f_order_array ,
f_order_symbol=${f_order_array[0]}
f_order_type=${f_order_array[1]}
f_order_side=${f_order_array[2]}
f_order_entry_price=${f_order_array[3]}
f_order_amount=${f_order_array[4]}
f_order_id=${f_order_array[5]}
f_order_stoplossprice=${f_order_array[6]}
f_order_takeprofitprice=${f_order_array[7]}
}

View File

@ -0,0 +1,40 @@
#!/bin/bash
# Copyright (c) 2022-2024 olli
#
# This file is part of dabo (crypto bot).
#
# dabo is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# dabo is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with dabo. If not, see <http://www.gnu.org/licenses/>.
function order_close {
# Info for log
g_echo_note "RUNNING FUNCTION ${FUNCNAME} $@"
local f_symbol=$1
local f_order
get_symbols_ticker
get_orders
get_orders_array
for f_order in "${f_get_orders_array[@]}"
do
get_order_line_vars "$f_order"
if [ "$f_symbol" = "$f_order_symbol" ]
then
f_ccxt "print(${STOCK_EXCHANGE}.cancelAllOrders('$f_symbol'))"
fi
done
}