2020-01-26 12:08:58 +00:00
|
|
|
import logging
|
|
|
|
from typing import Any, Dict
|
|
|
|
|
|
|
|
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
|
2020-01-26 12:08:58 +00:00
|
|
|
from freqtrade.worker import Worker
|
2020-01-26 23:49:25 +00:00
|
|
|
|
|
|
|
# Create and run worker
|
2020-01-26 12:08:58 +00:00
|
|
|
worker = None
|
|
|
|
try:
|
|
|
|
worker = Worker(args)
|
|
|
|
worker.run()
|
2020-05-08 09:44:24 +00:00
|
|
|
except Exception as e:
|
|
|
|
logger.error(str(e))
|
|
|
|
logger.exception("Fatal exception!")
|
2020-01-26 12:08:58 +00:00
|
|
|
except KeyboardInterrupt:
|
|
|
|
logger.info('SIGINT received, aborting ...')
|
|
|
|
finally:
|
|
|
|
if worker:
|
|
|
|
logger.info("worker found ... calling exit")
|
|
|
|
worker.exit()
|
|
|
|
return 0
|
2020-05-22 17:57:17 +00:00
|
|
|
|
|
|
|
|
2020-12-31 19:02:27 +00:00
|
|
|
def start_webserver(args: Dict[str, Any]) -> None:
|
2020-05-22 17:57:17 +00:00
|
|
|
"""
|
|
|
|
Main entry point for webserver mode
|
|
|
|
"""
|
2020-12-31 19:02:27 +00:00
|
|
|
from freqtrade.rpc.api_server import ApiServer
|
|
|
|
from freqtrade.configuration import Configuration
|
|
|
|
from freqtrade.enums import RunMode
|
2020-05-22 17:57:17 +00:00
|
|
|
|
2020-12-31 19:02:27 +00:00
|
|
|
# Initialize configuration
|
|
|
|
config = Configuration(args, RunMode.WEBSERVER).get_config()
|
|
|
|
ApiServer(config, standalone=True)
|