#!/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