This commit is contained in:
2024-03-25 21:11:35 +01:00
parent 55c6303f0f
commit 7baed40c0f
2 changed files with 33 additions and 22 deletions

View File

@@ -7,17 +7,26 @@ function f_ccxt {
g_echo_error "No secrets found (/dabo/.${STOCK_EXCHANGE}-secrets) found"
return 1
fi
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
g_python "exchange = ccxt.${STOCK_EXCHANGE}({'apiKey': '${API_KEY}','secret': '${API_SECRET}','options': {'defaultType': 'swap',},})" || return 1
g_python_wantoutput=1
g_python 'print(exchange.fetch_balance ({"currency": "USDT"}))' || return 1
# Initialize ccxt in python
if [ -z "$g_python_running" ] || [ -z "$f_ccxt_initialized" ]
then
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
g_python "exchange = ccxt.${STOCK_EXCHANGE}({'apiKey': '${API_KEY}','secret': '${API_SECRET}','options': {'defaultType': 'swap',},})" || 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[*]}
}