add freqtrade bot
This commit is contained in:
@ -0,0 +1,45 @@
|
||||
#!/command/with-contenv bashio
|
||||
# shellcheck shell=bash
|
||||
# ==============================================================================
|
||||
# Home Assistant Community Add-on: Example
|
||||
# ==============================================================================
|
||||
declare exit_code
|
||||
readonly exit_code_container=$(</run/s6-linux-init-container-results/exitcode)
|
||||
readonly exit_code_service="${1}"
|
||||
readonly exit_code_signal="${2}"
|
||||
readonly service="fqmbotnfix5"
|
||||
|
||||
bashio::log.info \
|
||||
"Service ${service} exited with code ${exit_code_service}" \
|
||||
"(by signal ${exit_code_signal})"
|
||||
|
||||
# Received a signal
|
||||
if [[ "${exit_code_service}" -eq 256 ]]; then
|
||||
|
||||
# The signal might be a result of another service crashing. Only
|
||||
# overwrite the container exit code if it is not already set.
|
||||
if [[ "${exit_code_container}" -eq 0 ]]; then
|
||||
echo $((128 + $exit_code_signal)) > /run/s6-linux-init-container-results/exitcode
|
||||
fi
|
||||
|
||||
# If the signal is SIGTERM, we should halt the container and take down
|
||||
# the whole process tree.
|
||||
[[ "${exit_code_signal}" -eq 15 ]] && exec /run/s6/basedir/bin/halt
|
||||
|
||||
# The service exited with a non-zero exit code, which means it crashed.
|
||||
elif [[ "${exit_code_service}" -ne 0 ]]; then
|
||||
|
||||
# The service might be a result of another service crashing. Only
|
||||
# overwrite the container exit code if it is not already set.
|
||||
if [[ "${exit_code_container}" -eq 0 ]]; then
|
||||
echo "${exit_code_service}" > /run/s6-linux-init-container-results/exitcode
|
||||
fi
|
||||
|
||||
# We should halt the container and take down the whole process tree.
|
||||
exec /run/s6/basedir/bin/halt
|
||||
|
||||
# The service exited with a zero exit code, which means it exited, let
|
||||
# S6 supervision restart it.
|
||||
else
|
||||
bashio::log.info "Service ${service} restarting..."
|
||||
fi
|
@ -0,0 +1,56 @@
|
||||
#!/command/with-contenv bashio
|
||||
# shellcheck shell=bash
|
||||
# ==============================================================================
|
||||
# Home Assistant Community Add-on: Example
|
||||
# Example init script, runs before any other service
|
||||
# ==============================================================================
|
||||
|
||||
declare log_level
|
||||
|
||||
bashio::log.info 'Starting Freqtrade NostalgiaForInfinity x5 bot...'
|
||||
|
||||
journal_path='/var/log/journal'
|
||||
if ! bashio::fs.directory_exists "${journal_path}" || [ -z "$(ls -A ${journal_path})" ]; then
|
||||
bashio::log.info "No journal at ${journal_path}, looking for journal in /run/log/journal instead"
|
||||
journal_path='/run/log/journal'
|
||||
fi
|
||||
|
||||
case "$(bashio::config 'log_level')" in \
|
||||
trace) ;& \
|
||||
debug) log_level='debug' ;; \
|
||||
notice) ;& \
|
||||
warning) log_level='warn' ;; \
|
||||
error) ;& \
|
||||
fatal) log_level='error' ;; \
|
||||
*) log_level='info' ;; \
|
||||
esac;
|
||||
bashio::log.info "Freqtrade log level set to ${log_level}"
|
||||
|
||||
export "JOURNAL_PATH=${journal_path}"
|
||||
export "LOG_LEVEL=${log_level}"
|
||||
|
||||
bashio::log.info "Export Freqtrade environment variables"
|
||||
|
||||
export "FREQTRADE__BOT_NAME=$(bashio::config 'bot_name')"
|
||||
export "FREQTRADE__MAX_OPEN_TRADES=$(bashio::config 'max_open_trade')"
|
||||
export "FREQTRADE__TRADING_MODE=$(bashio::config 'trading_mode')"
|
||||
export "FREQTRADE__EXCHANGE__NAME=$(bashio::config 'exchange_name')"
|
||||
export "FREQTRADE__EXCHANGE__KEY=$(bashio::config 'exchange_key')"
|
||||
export "FREQTRADE__EXCHANGE__SECRET=$(bashio::config 'exchange_token')"
|
||||
export "FREQTRADE__TELEGRAM__ENABLED=$(bashio::config 'telegram_enabled')"
|
||||
export "FREQTRADE__TELEGRAM__TOKEN=$(bashio::config 'telegram_token')"
|
||||
export "FREQTRADE__TELEGRAM__CHAT_ID=$(bashio::config 'telegram_chat_id')"
|
||||
export "FREQTRADE__API_SERVER__ENABLED=$(bashio::config 'api_server_enabled')"
|
||||
export "FREQTRADE__API_SERVER__LISTEN_PORT=$(bashio::config 'api_server_port')"
|
||||
export "FREQTRADE__API_SERVER__USERNAME=$(bashio::config 'api_server_username')"
|
||||
export "FREQTRADE__API_SERVER__PASSWORD=$(bashio::config 'api_server_password')"
|
||||
export "FREQTRADE__API_SERVER__JWT_SECRET_KEY=$(bashio::config 'api_server_jwt_secret_key')"
|
||||
export "FREQTRADE__API_SERVER__WS_TOKEN=$(bashio::config 'api_server_ws_token')"
|
||||
# Time Zone
|
||||
export "TZ=$(bashio::config 'timezone')"
|
||||
export "FREQTRADE__DRY_RUN=$(bashio::config 'dry_run')"
|
||||
export "FREQTRADE__STRATEGY=$(bashio::config 'strategy')"
|
||||
|
||||
bashio::log.info "starting the bot ..."
|
||||
|
||||
exec /freqtrade/.venv/bin/freqtrade trade --db-url sqlite:////freqtrade/user_data/${FREQTRADE__BOT_NAME:-Example_Test_Account}_${FREQTRADE__EXCHANGE__NAME:-binance}_${FREQTRADE__TRADING_MODE:-spot}-tradesv3.sqlite --log-file /freqtrade/user_data/logs/${FREQTRADE__BOT_NAME:-Example_Test_Account}-${FREQTRADE__EXCHANGE__NAME:-binance}-${FREQTRADE__STRATEGY:-NostalgiaForInfinityX5}-${FREQTRADE__TRADING_MODE:-spot}.log
|
@ -0,0 +1 @@
|
||||
longrun
|
Reference in New Issue
Block a user