mirror of
https://github.com/freqtrade/freqtrade.git
synced 2024-11-10 10:21:59 +00:00
31 lines
750 B
Python
31 lines
750 B
Python
import logging
|
|
import signal
|
|
from typing import Any, Dict
|
|
|
|
|
|
logger = logging.getLogger(__name__)
|
|
|
|
|
|
def start_trading(args: Dict[str, Any]) -> int:
|
|
"""
|
|
Main entry point for trading mode
|
|
"""
|
|
# Import here to avoid loading worker module when it's not used
|
|
from freqtrade.worker import Worker
|
|
|
|
def term_handler(signum, frame):
|
|
# Raise KeyboardInterrupt - so we can handle it in the same way as Ctrl-C
|
|
raise KeyboardInterrupt()
|
|
|
|
# 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
|