BITPANDA(-PRO) now ONETRADING

This commit is contained in:
olli 2024-04-09 09:24:03 +02:00
parent 2f41d7cd19
commit 4355c14a66

View File

@ -56,7 +56,7 @@ ${FUNCNAME} $@"
# prepare trading command # prepare trading command
local f_CMDFILE="trade-histories/${f_DATE}-${f_CURRENCY}-TRADE_CMD" local f_CMDFILE="trade-histories/${f_DATE}-${f_CURRENCY}-TRADE_CMD"
[ ${STOCK_EXCHANGE} = "BINANCE" ] && echo "${TRADE_CMD}" | perl -pe "s/ACTION/${f_ACTION}/; s/TOKEN/${f_ASSET}${f_CURRENCY}/; s/QUANTITY/${f_QUANTITY}/" >${f_CMDFILE} [ ${STOCK_EXCHANGE} = "BINANCE" ] && echo "${TRADE_CMD}" | perl -pe "s/ACTION/${f_ACTION}/; s/TOKEN/${f_ASSET}${f_CURRENCY}/; s/QUANTITY/${f_QUANTITY}/" >${f_CMDFILE}
[ ${STOCK_EXCHANGE} = "BITPANDA" ] && echo "${TRADE_CMD}" | perl -pe "s/ACTION/${f_ACTION}/; s/TOKEN/${f_ASSET}_${f_CURRENCY}/; s/QUANTITY/${f_ASSET_QUANTITY}/" >${f_CMDFILE} [ ${STOCK_EXCHANGE} = "ONETRADING" ] && echo "${TRADE_CMD}" | perl -pe "s/ACTION/${f_ACTION}/; s/TOKEN/${f_ASSET}_${f_CURRENCY}/; s/QUANTITY/${f_ASSET_QUANTITY}/" >${f_CMDFILE}
# trade # trade
g_echo_note "Command: $(cat ${f_CMDFILE})" g_echo_note "Command: $(cat ${f_CMDFILE})"
cat ${f_CMDFILE} cat ${f_CMDFILE}
@ -91,7 +91,7 @@ ${FUNCNAME} $@"
# Check return and log trade # Check return and log trade
[ ${STOCK_EXCHANGE} = "BINANCE" ] && f_STATUS=$(cat ${f_CMDFILE}_OUT | grep '^{' | jq -r .status) [ ${STOCK_EXCHANGE} = "BINANCE" ] && f_STATUS=$(cat ${f_CMDFILE}_OUT | grep '^{' | jq -r .status)
[ ${STOCK_EXCHANGE} = "BITPANDA" ] && f_STATUS=$(cat ${f_CMDFILE}_OUT | grep '^{' | jq -r .order_id) [ ${STOCK_EXCHANGE} = "ONETRADING" ] && f_STATUS=$(cat ${f_CMDFILE}_OUT | grep '^{' | jq -r .order_id)
local f_trade_info_msg="TRADE - ${f_ACTION} ${f_ASSET}${f_CURRENCY} local f_trade_info_msg="TRADE - ${f_ACTION} ${f_ASSET}${f_CURRENCY}
${f_link} ${f_link}
@ -107,14 +107,14 @@ Comment: ${f_COMMENT}"
[ ${STOCK_EXCHANGE} = "BINANCE" ] && local f_COMMISSION=$(cat ${f_CMDFILE}_OUT | grep '^{' | jq -r .fills[].commission) | head -n1 [ ${STOCK_EXCHANGE} = "BINANCE" ] && local f_COMMISSION=$(cat ${f_CMDFILE}_OUT | grep '^{' | jq -r .fills[].commission) | head -n1
[ ${STOCK_EXCHANGE} = "BINANCE" ] && local f_COMMISSIONASSET=$(cat ${f_CMDFILE}_OUT | grep '^{' | jq -r .fills[].commissionAsset | head -n1) [ ${STOCK_EXCHANGE} = "BINANCE" ] && local f_COMMISSIONASSET=$(cat ${f_CMDFILE}_OUT | grep '^{' | jq -r .fills[].commissionAsset | head -n1)
if [ ${STOCK_EXCHANGE} = "BITPANDA" ] if [ ${STOCK_EXCHANGE} = "ONETRADING" ]
then then
sleep 10 sleep 10
bitpanda-api-call GET public/v1/account/trades onetrading-api-call GET public/v1/account/trades
cat ${g_tmp}/API_CMD_OUT >${f_CMDFILE}_OUT_BITPANDA_TRADE cat ${g_tmp}/API_CMD_OUT >${f_CMDFILE}_OUT_ONETRADING_TRADE
local f_PRICE=$(cat ${f_CMDFILE}_OUT_BITPANDA_TRADE | jq -r ".trade_history | .[] | select(.trade.order_id==\"${f_STATUS}\") | .trade.price") local f_PRICE=$(cat ${f_CMDFILE}_OUT_ONETRADING_TRADE | jq -r ".trade_history | .[] | select(.trade.order_id==\"${f_STATUS}\") | .trade.price")
local f_COMMISSION=$(cat ${f_CMDFILE}_OUT_BITPANDA_TRADE | jq -r ".trade_history | .[] | select(.trade.order_id==\"${f_STATUS}\") | .fee.fee_amount") local f_COMMISSION=$(cat ${f_CMDFILE}_OUT_ONETRADING_TRADE | jq -r ".trade_history | .[] | select(.trade.order_id==\"${f_STATUS}\") | .fee.fee_amount")
local f_COMMISSIONASSET=$(cat ${f_CMDFILE}_OUT_BITPANDA_TRADE | jq -r ".trade_history | .[] | select(.trade.order_id==\"${f_STATUS}\") | .fee.fee_currency") local f_COMMISSIONASSET=$(cat ${f_CMDFILE}_OUT_ONETRADING_TRADE | jq -r ".trade_history | .[] | select(.trade.order_id==\"${f_STATUS}\") | .fee.fee_currency")
fi fi
echo "${f_DATE},${f_ACTION},${f_CMDFILE}_OUT,${f_QUANTITY} ${f_CURRENCY},${f_PRICE},${f_COMMISSION} ${f_COMMISSIONASSET},${f_COMMENT}" | head -n1 >>trade-histories/${f_ASSET}${f_CURRENCY}.history.csv echo "${f_DATE},${f_ACTION},${f_CMDFILE}_OUT,${f_QUANTITY} ${f_CURRENCY},${f_PRICE},${f_COMMISSION} ${f_COMMISSIONASSET},${f_COMMENT}" | head -n1 >>trade-histories/${f_ASSET}${f_CURRENCY}.history.csv