コード例 #1
0
ファイル: telegram_service.py プロジェクト: lipq525/OctoBot
    def prepare(self):
        if not self.telegram_api:
            self.chat_id = self.config[CONFIG_CATEGORY_SERVICES][CONFIG_TELEGRAM]["chat_id"]
            self.telegram_api = telegram.Bot(
                token=self.config[CONFIG_CATEGORY_SERVICES][CONFIG_TELEGRAM][CONFIG_TOKEN])

        if not self.telegram_app:
            if not self.telegram_updater:
                self.telegram_updater = Updater(
                    token=self.config[CONFIG_CATEGORY_SERVICES][CONFIG_TELEGRAM][CONFIG_TOKEN])

            if TelegramApp.is_enabled(self.config):
                self.telegram_app = TelegramApp(self.config, self, self.telegram_updater)
コード例 #2
0
    def prepare(self):
        if not self.telegram_api:
            self.chat_id = self.config[CONFIG_CATEGORY_SERVICES][CONFIG_TELEGRAM]["chat_id"]
            self.telegram_api = telegram.Bot(
                token=self.config[CONFIG_CATEGORY_SERVICES][CONFIG_TELEGRAM][CONFIG_TOKEN])

        if not self.telegram_app:
            if not self.telegram_updater:
                self.telegram_updater = Updater(
                    token=self.config[CONFIG_CATEGORY_SERVICES][CONFIG_TELEGRAM][CONFIG_TOKEN])

            if TelegramApp.is_enabled(self.config):
                self.telegram_app = TelegramApp(self.config, self, self.telegram_updater)
コード例 #3
0
ファイル: start.py プロジェクト: mrgreedy911/OctoBot
def start_octobot(starting_args):
    fileConfig(LOGGING_CONFIG_FILE)

    logger = logging.getLogger("OctoBot Launcher")

    # Force new log file creation not to log at the previous one's end.
    logger.parent.handlers[1].doRollover()

    sys.excepthook = _log_uncaught_exceptions

    try:
        if starting_args.version:
            print(LONG_VERSION)
        else:
            # Version
            logger.info("Version : {0}".format(LONG_VERSION))

            logger.info("Loading config files...")
            config = load_config(error=False)
            if config is None:
                raise ConfigError

            # Handle utility methods before bot initializing if possible
            if starting_args.packager:
                Commands.package_manager(config, starting_args.packager)

            elif starting_args.creator:
                Commands.tentacle_creator(config, starting_args.creator)

            elif starting_args.encrypter:
                Commands.exchange_keys_encrypter()

            else:

                config[CONFIG_EVALUATOR] = load_config(
                    CONFIG_EVALUATOR_FILE_PATH, False)
                if config[CONFIG_EVALUATOR] is None:
                    raise ConfigEvaluatorError

                config[CONFIG_TRADING_TENTACLES] = load_config(
                    CONFIG_TRADING_FILE_PATH, False)
                if config[CONFIG_TRADING_TENTACLES] is None:
                    raise ConfigTradingError

                if starting_args.data_collector:
                    Commands.data_collector(config)

                elif starting_args.strategy_optimizer:
                    Commands.start_strategy_optimizer(
                        config, starting_args.strategy_optimizer)

                else:

                    # In those cases load OctoBot
                    from octobot import OctoBot
                    from interfaces.telegram.bot import TelegramApp
                    from services import WebService

                    TelegramApp.enable(config, starting_args.telegram)

                    WebService.enable(config, not starting_args.no_web)

                    update_config_with_args(starting_args, config)

                    bot = OctoBot(config)

                    import interfaces

                    interfaces.__init__(bot, config)
                    try:
                        main.__init__(config)
                    except NameError as e:
                        logging.error(
                            "{0}, impossible to display GUI".format(e))

                    if starting_args.start:
                        Commands.start_bot(bot, logger)

    except ConfigError:
        logger.error("OctoBot can't start without " + CONFIG_FILE +
                     " configuration file.")
        os._exit(-1)

    except ModuleNotFoundError as e:
        if 'tentacles' in str(e):
            logger.error(
                "Impossible to start OctoBot, tentacles are missing.\nTo install tentacles, "
                "please use the following command:\nstart.py -p install all")
        os._exit(-1)

    except ConfigEvaluatorError:
        logger.error(
            "OctoBot can't start without a valid " +
            CONFIG_EVALUATOR_FILE_PATH +
            " configuration file.\nThis file is generated on tentacle "
            "installation using the following command:\nstart.py -p install all"
        )
        os._exit(-1)

    except ConfigTradingError:
        logger.error(
            "OctoBot can't start without a valid " + CONFIG_TRADING_FILE_PATH +
            " configuration file.\nThis file is generated on tentacle "
            "installation using the following command:\nstart.py -p install all"
        )
        os._exit(-1)
コード例 #4
0
ファイル: start.py プロジェクト: lipq525/OctoBot
        Commands.package_manager(config, args.packager)

    elif args.creator:
        Commands.tentacle_creator(config, args.creator)

    elif args.update:
        Commands.update(logger)

    else:
        # In those cases load OctoBot
        from octobot import OctoBot

        config[CONFIG_EVALUATOR] = load_config(CONFIG_EVALUATOR_FILE_PATH,
                                               False)

        TelegramApp.enable(config, args.telegram)

        WebService.enable(config, args.web)

        bot = OctoBot(config)

        import interfaces

        interfaces.__init__(bot, config)

        if args.data_collector:
            Commands.data_collector(config)

        # start crypto bot options
        else:
            if args.backtesting:
コード例 #5
0
    args = parser.parse_args()

    fileConfig('config/logging_config.ini')

    logger = logging.getLogger("MAIN")
    sys.excepthook = _log_uncaught_exceptions

    # Version
    logger.info("Version : {0}".format(LONG_VERSION))

    logger.info("Load config files...")
    config = load_config()
    config[CONFIG_EVALUATOR] = load_config(CONFIG_EVALUATOR_FILE, False)

    if args.telegram:
        TelegramApp.enable(config)

    if args.web:
        WebService.enable(config)

    bot = CryptoBot(config)

    import interfaces
    interfaces.__init__(bot, config)

    if args.update:
        Commands.update(logger)

    elif args.data_collector:
        Commands.data_collector(config)
コード例 #6
0
ファイル: start.py プロジェクト: CryptoRichy/OctoBot
def start_octobot(starting_args):
    if starting_args.pause_time is not None:
        sleep(starting_args.pause_time)

    fileConfig('config/logging_config.ini')

    logger = logging.getLogger("OctoBot Launcher")

    # Force new log file creation not to log at the previous one's end.
    logger.parent.handlers[1].doRollover()

    sys.excepthook = _log_uncaught_exceptions

    # Version
    logger.info("Version : {0}".format(LONG_VERSION))

    # Test update
    if starting_args.update:
        Commands.update(logger)
    else:
        Commands.check_bot_update(logger)

        logger.info("Loading config files...")
        config = load_config()

        # Handle utility methods before bot initializing if possible
        if starting_args.packager:
            Commands.package_manager(config, starting_args.packager)

        elif starting_args.creator:
            Commands.tentacle_creator(config, starting_args.creator)

        else:
            # In those cases load OctoBot
            from octobot import OctoBot

            config[CONFIG_EVALUATOR] = load_config(CONFIG_EVALUATOR_FILE_PATH,
                                                   False)

            TelegramApp.enable(config, starting_args.telegram)

            WebService.enable(config, starting_args.web)

            bot = OctoBot(config)

            import interfaces

            interfaces.__init__(bot, config)

            if starting_args.data_collector:
                Commands.data_collector(config)

            # start crypto bot options
            else:
                if starting_args.backtesting:
                    import backtesting

                    backtesting.__init__(bot)

                    config[CONFIG_BACKTESTING][CONFIG_ENABLED_OPTION] = True
                    config[CONFIG_CATEGORY_NOTIFICATION][
                        CONFIG_ENABLED_OPTION] = False

                    config[CONFIG_TRADER][CONFIG_ENABLED_OPTION] = False
                    config[CONFIG_SIMULATOR][CONFIG_ENABLED_OPTION] = True

                if starting_args.simulate:
                    config[CONFIG_TRADER][CONFIG_ENABLED_OPTION] = False
                    config[CONFIG_SIMULATOR][CONFIG_ENABLED_OPTION] = True

                if starting_args.risk is not None and 0 < starting_args.risk <= 1:
                    config[CONFIG_TRADER][
                        CONFIG_TRADER_RISK] = starting_args.risk

                if starting_args.start:
                    Commands.start_bot(bot, logger)