#!/bin/bash function binance-api-call { g_echo_note "RUNNING FUNCTION ${FUNCNAME} $@" local method=$1 local call=$2 local params=$3 if [ -s /home/docker/binance-cli/.binance-secrets ] then . /home/docker/binance-cli/.binance-secrets else g_echo_error "No secrets file found" return 1 fi call=$(echo "$call" | sed "s/^\///") if echo "${call}" | egrep -q "^sapi/|^api/v3/order" then params="recvWindow=60000${params}" local timestamp=$(date +%s000) params="${params}×tamp=${timestamp}" local signature=$(echo -n "${params}" | openssl dgst -sha256 -hmac "${API_SECRET}" | cut -d" " -f2) params="?${params}&signature=$signature" fi echo "curl -s -H \"X-MBX-APIKEY: $API_KEY\" -X \"$method\" \"https://api.binance.com/${call}${params}\"" >${g_tmp}/API_CMD echo "curl -s -H \"X-MBX-APIKEY: API_KEY\" -X \"$method\" \"https://api.binance.com/${call}${params}\"" >${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 then g_echo_error "$(cat ${g_tmp}/API_CMD_WO_KEY): $(cat ${g_tmp}/API_CMD_OUT)" return 1 fi }