Ejemplo n.º 1
0
        public Initializer(OctoBot octobot)
        {
            Octobot = octobot;

            // Logger
            loggingService = Application.Resolve <ILoggingService>();

            PerformanceAnalyser = null;
            TimeFrames          = null;
            RelevantEvaluators  = new List <object>();
        }
Ejemplo n.º 2
0
        public TaskManager(OctoBot octobot)
        {
            Octobot = octobot;

            // Logger
            loggingService = Application.Resolve <ILoggingService>();

            AsyncLoop         = null;
            Ready             = false;
            Watcher           = null;
            MainTaskGroup     = null;
            CurrentLoopThread = null;
        }
Ejemplo n.º 3
0
        public EvaluatorFactory(OctoBot octobot)
        {
            Octobot = octobot;

            // Logger
            loggingService = Application.Resolve <ILoggingService>();

            SymbolTasksManager          = new Dictionary <string, object>();
            SymbolEvaluatorList         = new Dictionary <string, object>();
            CryptoCurrencyEvaluatorList = new Dictionary <string, object>();
            DispatchersList             = new List <object>();
            SocialEvalTasks             = new List <object>();
            RealTimeEvalTasks           = new List <object>();
        }
Ejemplo n.º 4
0
        private void AutoOpenWeb(ICoreConfig config, OctoBot bot)
        {
            try
            {
                // Ожидаем готовность бота к работе
                while (bot.IsReady() == false)
                {
                    Thread.Sleep(100);
                }

                //webbrowser.open(String.Format("http://{0}:{1}", socket.gethostbyname(socket.gethostname()), config.Services[] [CONFIG_WEB][CONFIG_WEB_PORT]);
            }
            catch (Exception exc)
            {
                loggingService.Error(String.Format("{0}, невозможно автоматически открыть веб-интерфейс", exc.Message));
            }
        }
Ejemplo n.º 5
0
        public ExchangeFactory(OctoBot octobot, bool ignoreConfig = false)
        {
            Octobot      = octobot;
            IgnoreConfig = ignoreConfig;

            // Logger
            loggingService = Application.Resolve <ILoggingService>();

            ExchangeTraders          = new Dictionary <string, object>();
            ExchangeTraderSimulators = new Dictionary <string, object>();
            ExchangeTradingModes     = new Dictionary <string, object>();
            TradingMode = null;
            PreviousTradingStateManager = null;
            ExchangesList            = new Dictionary <string, object>();
            GlobalUpdatersByExchange = new Dictionary <string, object>();

            AvailableExchanges = new List <string>()
            {
                "binance"
            };
        }
Ejemplo n.º 6
0
        public void Start(ParseResult parseResult)
        {
            try
            {
                if (parseResult["version"] != null)
                {
                    Debug.WriteLine(1);
                }
                else
                {
                    loggingService.Info($"Запуск OctoBot Core. Версия: {ConfigVars.LONG_VERSION}");

                    CheckPublicAnnouncements();

                    loggingService.Info("Загрузка файлов конфигурации...");

                    // загрузка конфигурации
                    // ConfigJson config = ConfigBase.LoadConfig(logger, "", false, true);

                    if (Config == null /*&& ConfigBase.IsConfigEmptyOrMissing() == true*/)
                    {
                        Debug.WriteLine(1);

                        /*Log.Information("Конфигурация не была найдена. Создаём файл конфигурации по умолчанию...");
                         *
                         * ConfigBase.InitConfig();
                         *
                         * config = ConfigBase.LoadConfig(logger, "", false);*/
                    }
                    else
                    {
                        Debug.WriteLine(1);

                        /*(bool isValid, string e) tuple = ConfigManager.ValidateConfigFile(config);
                         * if (tuple.isValid == false)
                         * {
                         *      logger.Error("OctoBot не может починить Ваш файл config.json: неверный json формат: " + tuple.e);
                         *
                         *      throw new ConfigError();
                         * }
                         *
                         * ConfigManager.ConfigHealthCheck(logger, config);*/
                    }

                    if (Config == null)
                    {
                        throw new ConfigError();
                    }

                    // Если возможно, то обрабатываем служебные методы перед инициализацией бота
                    if (parseResult["packager"] != null)
                    {
                        Debug.WriteLine(1);
                    }
                    else if (parseResult["creator"] != null)
                    {
                        Debug.WriteLine(1);
                    }
                    else if (parseResult["encrypter"] != null)
                    {
                        Debug.WriteLine(1);
                    }
                    else
                    {
                        if (tentacleManagerService.TentaclesArchExists() == false)
                        {
                            loggingService.Info("Tentacles не найдены. Установка tentacles по умолчанию...");
                            Commands.PackageManager(tentacleManagerService, Config, new List <string>()
                            {
                                "install", "all"
                            }, force: true);
                        }

                        ConfigManager.ReloadTentacleConfig(Config);

                        if (parseResult["data_collector"] != null)
                        {
                            Debug.WriteLine(1);
                        }
                        else if (parseResult["strategy_optimizer"] != null)
                        {
                            Debug.WriteLine(1);
                        }
                        else
                        {
                            // При этом условии загружаем OctoBot
                            // TelegramApp.enable(Config, parseResult["no_telegram"] == null);
                            // WebService.enable(Config, parseResult["no_web"] == null);

                            UpdateConfigWithArgs(parseResult, Config);

                            bool resetTradingHistory = parseResult["reset_trading_history"] != null ? (bool)parseResult["reset_trading_history"] : false;

                            var bot = new OctoBot(Config, resetTradingHistory: resetTradingHistory);

                            LogTermsIfUnaccepted(Config);

                            bool noOpenWeb = parseResult["no_open_web"] != null ? (bool)parseResult["no_open_web"] : false;
                            bool noWeb     = parseResult["no_web"] != null ? (bool)parseResult["no_web"] : false;

                            if (noOpenWeb == false && noWeb == false)
                            {
                                Debug.WriteLine(1);
                            }

                            // Установите debug_mode = true для активвации режима отладки в asyncio
                            var debugMode = ConfigManager.IsInDevMode(Config) || ConfigVars.FORCE_ASYNCIO_DEBUG_OPTION;
                            var t         = Task.Run(() => Commands.StartBot(bot));
                        }
                    }
                }
            }
            catch (ConfigError exc)
            {
                Debug.WriteLine(1);
            }
            catch (ConfigEvaluatorError exc)
            {
                Debug.WriteLine(1);
            }
            catch (ConfigTradingError exc)
            {
                Debug.WriteLine(1);
            }
            catch (Exception exc)
            {
                Debug.WriteLine(1);
            }
        }