83 lines
1.7 KiB
Bash
Executable File
83 lines
1.7 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
. /etc/bash/gaboshlib.include
|
|
|
|
g_lockfile
|
|
|
|
|
|
### CONFIG ###
|
|
|
|
BASEPATH=/dabo/htdocs
|
|
g_tries=3
|
|
g_tries_delay=5
|
|
|
|
|
|
### FUNCTIONS ###
|
|
for bashfunc in $(find ${BASEPATH}/../functions -type f -name "*.sh")
|
|
do
|
|
. "$bashfunc"
|
|
done
|
|
|
|
### MAIN ###
|
|
|
|
# prepare directories
|
|
mkdir -p ${BASEPATH}/botdata/asset-histories
|
|
mkdir -p ${BASEPATH}/botdata/trade-histories
|
|
cd ${BASEPATH}/botdata
|
|
|
|
touch firstloop
|
|
|
|
# am I the bot (important for functions used by analyze.sh
|
|
echo $0 | grep -q "dabo-bot\.sh" && BOT=1
|
|
|
|
# run endless loop
|
|
while true
|
|
do
|
|
|
|
# wait until next full minute in the beginning to be able to work with continue in this loop
|
|
if [ -f firstloop ]
|
|
then
|
|
rm -f firstloop
|
|
else
|
|
g_echo_note "NEXT LOOP - sleping until next full ${INTERVAL} seconds"
|
|
sleep $((${INTERVAL} - $(date +%s) % ${INTERVAL}))
|
|
fi
|
|
|
|
# reload config
|
|
. ../../dabo-bot.conf
|
|
|
|
# stock data
|
|
if [ ${STOCK_EXCHANGE} = "BINANCE" ]
|
|
then
|
|
#BINANCE_CLI_CMD="docker-compose -f /home/docker/binance-cli/docker-compose.yml exec -T binance-cli binance-cli"
|
|
# command for current token infos (function for setting var QUANTITY_LOT_CUT
|
|
TOKEN_INFO_CMD="binance_get_token_info"
|
|
# command for buying/selling a token
|
|
#TRADE_CMD="$BINANCE_CLI_CMD ACTION -s TOKEN -u QUANTITY -t market"
|
|
TRADE_CMD='binance-api-call POST /api/v3/order "&symbol=TOKEN"eOrderQty=QUANTITY&side=ACTION&type=MARKET"'
|
|
fi
|
|
|
|
# Get current assets
|
|
get_assets || continue
|
|
|
|
# Get current balances
|
|
get_balances || continue
|
|
|
|
# Check the situation on the market
|
|
if ! market_performance
|
|
then
|
|
f_market_performance=$(cat MARKET_PERFORMANCE_LATEST)
|
|
fi
|
|
|
|
##### Sell something? ####
|
|
check_for_sell
|
|
|
|
##### Buy something? ####
|
|
check_for_buy
|
|
|
|
##### Update webpage
|
|
webpage &
|
|
|
|
done
|
|
|