示例#1
0
        public void Start(bool coinigyEnabled, bool bittrexEnabled, bool poloEnabled, bool bagManagementEnabled)
        {
            // Needs to be called here as if we use DI, the config has not been binded yet
            _bot.StartBot(_telegramConfig);

            var registry = new Registry();

            if (bittrexEnabled || poloEnabled)
            {
                SendStartupMessage().Wait();

                registry.Schedule(() => GetNewOrders().Wait())
                .ToRunNow()
                .AndEvery(5)
                .Minutes();
            }

            if (bittrexEnabled || poloEnabled || coinigyEnabled)
            {
                registry.Schedule(() => CheckBalances().Wait()).ToRunNow().AndEvery(1).Hours().At(0);
            }

            if (bagManagementEnabled)
            {
                registry.Schedule(() => CheckForBags().Wait()).ToRunEvery(6).Hours();
            }

            if (coinigyEnabled)
            {
                _bus.SendAsync(new GetCoinigyAccountCommand());
            }

            JobManager.Initialize(registry);
        }
示例#2
0
        public async Task Start()
        {
            // Needs to be called here as if we use DI, the config has not been binded yet
            _bot.StartBot(_telegramConfig);

            var registry = new Registry();

            if (_bittrexConfig.Enabled || _poloniexConfig.Enabled)
            {
                SendStartupMessage().Wait();

                registry.Schedule(() => GetNewOrders().Wait())
                .ToRunNow()
                .AndEvery(1)
                .Minutes();
            }

            if (_bittrexConfig.Enabled)
            {
                if (!string.IsNullOrEmpty(_bittrexConfig.DailyNotifications))
                {
                    var dailyBalance = _bittrexConfig.DailyNotifications.Split(':');
                    int.TryParse(dailyBalance[0], out int hour);
                    int.TryParse(dailyBalance[1], out int min);

                    registry.Schedule(() => DailyBalanceCheck(Constants.Bittrex).Wait()).ToRunEvery(1).Days().At(hour, min);
                }
            }

            if (_poloniexConfig.Enabled)
            {
                if (!string.IsNullOrEmpty(_poloniexConfig.DailyNotifications))
                {
                    var dailyBalance = _poloniexConfig.DailyNotifications.Split(':');
                    int.TryParse(dailyBalance[0], out int hour);
                    int.TryParse(dailyBalance[1], out int min);

                    registry.Schedule(() => DailyBalanceCheck(Constants.Poloniex).Wait()).ToRunEvery(1).Days().At(hour, min);
                }
            }

            if (_bittrexConfig.Enabled || _poloniexConfig.Enabled || _coinigyConfig.Enabled)
            {
                registry.Schedule(() => CheckBalances().Wait()).ToRunNow().AndEvery(1).Hours().At(0);
                registry.Schedule(() => CheckDepositAndWithdrawals().Wait()).ToRunEvery(2).Minutes();
            }

            if (_bagConfig.Enabled || _lowBtcConfig.Enabled || _dustConfig.Enabled)
            {
                registry.Schedule(() => CheckForBags().Wait()).ToRunEvery(8).Hours();
                registry.Schedule(() => CheckForBags().Wait()).ToRunOnceIn(5).Minutes();
            }

            if (_coinigyConfig.Enabled)
            {
                await _bus.SendAsync(new GetCoinigyAccountCommand());
            }

            JobManager.Initialize(registry);
        }
        public void Start(bool coinigyEnabled, bool bittrexEnabled, bool poloEnabled, bool bagManagementEnabled, bool bittrexTradeNotifcations, bool poloniexTradeNotifcation)
        {
            // Needs to be called here as if we use DI, the config has not been binded yet
            _bot.StartBot(_telegramConfig);

            var registry = new Registry();

            if (bittrexEnabled || poloEnabled)
            {
                registry
                .Schedule(() => GetNewOrdersOnStartup(bittrexTradeNotifcations, poloniexTradeNotifcation).Wait())
                .ToRunNow();
                registry.Schedule(() => GetNewOrders(bittrexTradeNotifcations, poloniexTradeNotifcation).Wait())
                .ToRunEvery(5)
                .Minutes();
            }

            if (bittrexEnabled || poloEnabled || coinigyEnabled)
            {
                registry.Schedule(() => CheckBalances().Wait()).ToRunNow().AndEvery(1).Hours().At(0);
            }

            if (bagManagementEnabled)
            {
                registry.Schedule(() => CheckForBags().Wait()).ToRunNow().AndEvery(6).Hours();
            }

            JobManager.Initialize(registry);
        }
        public void Start()
        {
            // Needs to be called here as if we use DI, the config has not been binded yet
            _bot.StartBot(_telegramConfig);

            var registry = new Registry();

            if (_bittrexConfig.Enabled || _poloniexConfig.Enabled || _binanceConfig.Enabled)
            {
                registry.Schedule(() => GetNewOrders().Wait())
                .NonReentrant()     //first time account trades request it is longest than one minute, and will be good if we will wait end of requests and next sheduler will run after fully completed previous.
                .ToRunEvery(1)
                .Minutes();
            }

            if (_bittrexConfig.Enabled)
            {
                if (!string.IsNullOrEmpty(_bittrexConfig.DailyNotifications))
                {
                    var dailyBalance = _bittrexConfig.DailyNotifications.Split(':');
                    int.TryParse(dailyBalance[0], out var hour);
                    int.TryParse(dailyBalance[1], out var min);

                    registry.Schedule(() => DailyBalanceCheck(Constants.Bittrex).Wait()).ToRunEvery(1).Days().At(hour, min);
                }
            }

            if (_binanceConfig.Enabled)
            {
                if (!string.IsNullOrEmpty(_bittrexConfig.DailyNotifications))
                {
                    var dailyBalance = _bittrexConfig.DailyNotifications.Split(':');
                    int.TryParse(dailyBalance[0], out var hour);
                    int.TryParse(dailyBalance[1], out var min);

                    registry.Schedule(() => DailyBalanceCheck(Constants.Binance).Wait()).ToRunEvery(1).Days().At(hour, min);
                }
            }

            if (_poloniexConfig.Enabled)
            {
                if (!string.IsNullOrEmpty(_poloniexConfig.DailyNotifications))
                {
                    var dailyBalance = _poloniexConfig.DailyNotifications.Split(':');
                    int.TryParse(dailyBalance[0], out var hour);
                    int.TryParse(dailyBalance[1], out var min);

                    registry.Schedule(() => DailyBalanceCheck(Constants.Poloniex).Wait()).ToRunEvery(1).Days().At(hour, min);
                }
            }

            if (_bittrexConfig.Enabled || _poloniexConfig.Enabled || _binanceConfig.Enabled || _coinigyConfig.Enabled)
            {
                registry.Schedule(() => CheckBalances().Wait()).ToRunEvery(1).Hours().At(0);
                registry.Schedule(() => CheckBalances().Wait()).ToRunOnceIn(30).Seconds();
                registry.Schedule(() => CheckDepositAndWithdrawals().Wait()).ToRunEvery(2).Minutes();
            }

            registry.Schedule(() => CheckForBags().Wait()).ToRunEvery(8).Hours();

            if (_coinigyConfig.Enabled)
            {
                registry.Schedule(() => GetCoinigyAccounts().Wait()).ToRunOnceIn(3).Minutes();
            }

            registry.Schedule(() => ForceGC()).ToRunEvery(15).Minutes();

            JobManager.Initialize(registry);

            SendStartupMessage().Wait();
        }