fetch orders

This commit is contained in:
olli 2024-06-14 19:49:10 +02:00
parent 7ade733c8d
commit c7c8ea9b7f

View File

@ -0,0 +1,47 @@
function get_orders {
g_echo_note "RUNNING FUNCTION ${FUNCNAME} $@"
local f_symbol=$1
local f_symbol_file
# get orders of all symbols available if symbol argument is not given
local f_symbols=()
if [ -z "$f_symbol" ]
then
for f_symbol in "${f_symbols_array[@]}"
do
if [ -z "$LEVERAGE" ]
then
[[ $f_symbol =~ /${CURRENCY}$ ]] && f_symbols+=("$f_symbol")
else
[[ $f_symbol =~ /${CURRENCY}:${CURRENCY}$ ]] && f_symbols+=("$f_symbol")
fi
done
else
f_symbols+=("$f_symbol")
fi
[ -z "$f_symbols" ] && return 1
for f_symbol in "${f_symbols[@]}"
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\""
if f_ccxt "print($STOCK_EXCHANGE.fetchOpenOrders(symbol='${f_symbol}'))"
then
if [ -z "$f_ccxt_json_out" ]
then
rm -f CCXT_OPEN_ORDERS_${f_symbol_file}_RAW CCXT_OPEN_ORDERS_${f_symbol_file}
continue
fi
echo $f_ccxt_result | tee "CCXT_OPEN_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}"
fi
done
}