33 lines
1021 B
Bash
33 lines
1021 B
Bash
function f_ccxt {
|
|
if [ -s /dabo/.${STOCK_EXCHANGE,,}-secrets ]
|
|
then
|
|
. /dabo/.${STOCK_EXCHANGE,,}-secrets
|
|
else
|
|
g_echo_error "No secrets found (/dabo/.${STOCK_EXCHANGE,,}-secrets) found"
|
|
return 1
|
|
fi
|
|
|
|
local g_ccxt_jobs
|
|
mapfile -t g_ccxt_jobs < <(jobs -r)
|
|
# Initialize ccxt in python
|
|
if [[ ${g_python_jobs[*]} != python-pipeexec.py ]] || [ -z "$f_ccxt_initialized" ]
|
|
then
|
|
unset f_ccxt_initialized
|
|
g_python 'import os' || return 1
|
|
g_python 'import sys' || return 1
|
|
g_python 'sys.path.append("/ccxt/python")' || return 1
|
|
g_python 'import ccxt' || return 1
|
|
sleep 0.5
|
|
local f_exchange_type="swap"
|
|
[ -z "$LEVERAGE" ] && f_exchange_type="spot"
|
|
g_python "exchange = ccxt.${STOCK_EXCHANGE,,}({'apiKey': '${API_KEY}','secret': '${API_SECRET}','options': {'defaultType': '${f_exchange_type}',},})" || return 1
|
|
f_ccxt_initialized=true
|
|
fi
|
|
|
|
|
|
g_python_waitforoutput=1
|
|
g_python "$@" || return 1
|
|
unset f_ccxt_result
|
|
f_ccxt_result=${g_python_result[*]}
|
|
}
|