freqtrade_origin/freqtrade/commands/trade_commands.py

31 lines
744 B
Python
Raw Permalink Normal View History

import logging
import signal
from typing import Any
logger = logging.getLogger(__name__)
def start_trading(args: dict[str, Any]) -> int:
"""
Main entry point for trading mode
"""
2020-01-26 23:49:25 +00:00
# Import here to avoid loading worker module when it's not used
from freqtrade.worker import Worker
2020-01-26 23:49:25 +00:00
def term_handler(signum, frame):
# Raise KeyboardInterrupt - so we can handle it in the same way as Ctrl-C
raise KeyboardInterrupt()
2020-01-26 23:49:25 +00:00
# Create and run worker
worker = None
try:
signal.signal(signal.SIGTERM, term_handler)
worker = Worker(args)
worker.run()
finally:
if worker:
logger.info("worker found ... calling exit")
worker.exit()
return 0