BITPANDA(-PRO) now ONETRADING

This commit is contained in:
olli 2024-04-09 09:23:58 +02:00
parent 2236ac65f7
commit 2f41d7cd19
2 changed files with 11 additions and 13 deletions

View File

@ -1,14 +1,14 @@
#!/bin/bash
function bitpanda-api-call {
function onetrading-api-call {
g_echo_note "RUNNING FUNCTION ${FUNCNAME} $@"
local method=$1
local call=$2
local params=$3
if [ -s /dabo/.bitpanda-secrets ]
if [ -s /dabo/.onetrading-secrets ]
then
. /dabo/.bitpanda-secrets
. /dabo/.onetrading-secrets
else
g_echo_error "No secrets file found"
return 1
@ -17,8 +17,6 @@ function bitpanda-api-call {
echo "${call}" | egrep -q "/account/" && local f_token="-H 'Authorization: Bearer ${API_TOKEN}'"
echo "curl -s -X ${method} --url https://api.onetrading.com/${call} $f_token -H 'Accept: application/json' ${params}" >${g_tmp}/API_CMD
echo "curl -s -X ${method} --url https://api.onetrading.com/${call} -H 'Accept: application/json'" >${g_tmp}/API_CMD_WO_KEY
#echo "curl -s -X ${method} --url https://api.exchange.bitpanda.com/${call} $f_token -H 'Accept: application/json' ${params}" >${g_tmp}/API_CMD
#echo "curl -s -X ${method} --url https://api.exchange.bitpanda.com/${call} -H 'Accept: application/json'" >${g_tmp}/API_CMD_WO_KEY
g_runcmd g_retrycmd sh ${g_tmp}/API_CMD >${g_tmp}/API_CMD_OUT 2>&1
if egrep -q -i '^{"code":|error' ${g_tmp}/API_CMD_OUT

View File

@ -1,4 +1,4 @@
function bitpanda_get_token_info {
function onetrading_get_token_info {
g_echo_note "RUNNING FUNCTION ${FUNCNAME} $@"
@ -7,16 +7,16 @@ function bitpanda_get_token_info {
f_QUANTITY=$3
# cleanup cache
[ -s BITPANDA_TOKEN_INFO_CMD_OUT ] && find BITPANDA_TOKEN_INFO_CMD_OUT -mmin +60 -or -empty -delete
if ! [ -s BITPANDA_TOKEN_INFO_CMD_OUT ]
[ -s ONETRADING_TOKEN_INFO_CMD_OUT ] && find ONETRADING_TOKEN_INFO_CMD_OUT -mmin +60 -or -empty -delete
if ! [ -s ONETRADING_TOKEN_INFO_CMD_OUT ]
then
bitpanda-api-call GET public/v1/instruments >BITPANDA_TOKEN_INFO_CMD_OUT
cat ${g_tmp}/API_CMD_OUT >BITPANDA_TOKEN_INFO_CMD_OUT
onetrading-api-call GET public/v1/instruments >ONETRADING_TOKEN_INFO_CMD_OUT
cat ${g_tmp}/API_CMD_OUT >ONETRADING_TOKEN_INFO_CMD_OUT
fi
local f_ASSET_PRECISION=$(cat BITPANDA_TOKEN_INFO_CMD_OUT | jq -r ".[] | select(.state==\"ACTIVE\") | select(.quote.code==\"${f_CURRENCY}\") | select(.base.code==\"${f_ASSET}\") | .amount_precision")
local f_CURRENCY_PRECISION=$(cat BITPANDA_TOKEN_INFO_CMD_OUT | jq -r ".[] | select(.state==\"ACTIVE\") | select(.quote.code==\"${f_CURRENCY}\") | select(.base.code==\"${f_ASSET}\") | .quote.precision")
local f_ASSET_MINSIZE=$(cat BITPANDA_TOKEN_INFO_CMD_OUT | jq -r ".[] | select(.state==\"ACTIVE\") | select(.quote.code==\"${f_CURRENCY}\") | select(.base.code==\"${f_ASSET}\") | .min_size")
local f_ASSET_PRECISION=$(cat ONETRADING_TOKEN_INFO_CMD_OUT | jq -r ".[] | select(.state==\"ACTIVE\") | select(.quote.code==\"${f_CURRENCY}\") | select(.base.code==\"${f_ASSET}\") | .amount_precision")
local f_CURRENCY_PRECISION=$(cat ONETRADING_TOKEN_INFO_CMD_OUT | jq -r ".[] | select(.state==\"ACTIVE\") | select(.quote.code==\"${f_CURRENCY}\") | select(.base.code==\"${f_ASSET}\") | .quote.precision")
local f_ASSET_MINSIZE=$(cat ONETRADING_TOKEN_INFO_CMD_OUT | jq -r ".[] | select(.state==\"ACTIVE\") | select(.quote.code==\"${f_CURRENCY}\") | select(.base.code==\"${f_ASSET}\") | .min_size")
local f_ASSET_PRICE=$(tail -n1 "asset-histories/${f_ASSET}${f_CURRENCY}.history.csv" | cut -d"," -f2)
if [ -n "$f_QUANTITY" ] && [ -n "$f_ASSET_PRICE" ]