array and vars

This commit is contained in:
olli 2024-08-30 17:32:54 +02:00
parent fa6dd07417
commit 051798ed00

View File

@ -43,23 +43,43 @@ function get_orders {
fi fi
[ -z "$f_symbols" ] && return 1 [ -z "$f_symbols" ] && return 1
for f_symbol in "${f_symbols[@]}" for f_symbol in ${f_symbols_array_trade[@]}
do do
f_symbol_file=${f_symbol//:*} f_symbol_file=${f_symbol//:*}
f_symbol_file=${f_symbol_file///} 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}'))" if f_ccxt "print($STOCK_EXCHANGE.fetchOpenOrders(symbol='${f_symbol}'))"
then 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\") | select(.status==\"open\") |
.symbol + \",\" + .type + \",\" + .side + \",\" + (.price|tostring) + \",\" + (.stopPrice|tostring) + \",\" + (.amount .symbol + \",\" + .type + \",\" + .side + \",\" + (.price|tostring) + \",\" + (.amount|tostring) + \",\" + .id + \",\" + (.stopLossPrice|tostring) + \",\" + (.takeProfitPrice|tostring)
|tostring) " >"CCXT_ORDERS_${f_symbol_file}"
" >"CCXT_OPEN_ORDERS_${f_symbol_file}"
else 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 continue
fi fi
done 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]}
}