예제 #1
0
        public void Start()
        {
            loggingService.Info($"Start Trading service (Virtual: {Config.VirtualTrading})...");

            IsTradingSuspended = true;

            orderingService = Application.Resolve <IOrderingService>();
            rulesService    = Application.Resolve <IRulesService>();
            OnTradingRulesChanged();
            rulesService.RegisterRulesChangeCallback(OnTradingRulesChanged);
            Exchange.Start(Config.VirtualTrading);
            signalsService = Application.Resolve <ISignalsService>();

            if (!Config.VirtualTrading)
            {
                Account = new ExchangeAccount(loggingService, notificationService, healthCheckService, signalsService, this);
            }
            else
            {
                Account = new VirtualAccount(loggingService, notificationService, healthCheckService, signalsService, this);
            }

            accountRefreshTimedTask = tasksService.AddTask(
                name: nameof(AccountRefreshTimedTask),
                task: new AccountRefreshTimedTask(loggingService, healthCheckService, this),
                interval: Config.AccountRefreshInterval * 1000 / Application.Speed,
                startDelay: Constants.TaskDelays.ZeroDelay,
                startTask: false,
                runNow: true,
                skipIteration: 0);

            if (signalsService.Config.Enabled)
            {
                signalsService.Start();
            }

            tradingTimedTask = tasksService.AddTask(
                name: nameof(TradingTimedTask),
                task: new TradingTimedTask(loggingService, notificationService, healthCheckService, signalsService, orderingService, this),
                interval: Config.TradingCheckInterval * 1000 / Application.Speed,
                startDelay: Constants.TaskDelays.NormalDelay,
                startTask: false,
                runNow: false,
                skipIteration: 0);

            tradingRulesTimedTask = tasksService.AddTask(
                name: nameof(TradingRulesTimedTask),
                task: new TradingRulesTimedTask(loggingService, notificationService, healthCheckService, rulesService, signalsService, this),
                interval: RulesConfig.CheckInterval * 1000 / Application.Speed,
                startDelay: Constants.TaskDelays.MidDelay,
                startTask: false,
                runNow: false,
                skipIteration: 0);

            IsTradingSuspended = false;

            loggingService.Info("Trading service started");
        }
예제 #2
0
        public void Start()
        {
            loggingService.Info($"Start Trading service (Virtual: {Config.VirtualTrading})...");

            IsTradingSuspended = true;

            rulesService = Application.Resolve <IRulesService>();
            OnTradingRulesChanged();
            rulesService.RegisterRulesChangeCallback(OnTradingRulesChanged);

            exchangeService.Start(Config.VirtualTrading);

            signalsService = Application.Resolve <ISignalsService>();

            if (!Config.VirtualTrading)
            {
                Account = new ExchangeAccount(loggingService, notificationService, healthCheckService, signalsService, this);
            }
            else
            {
                Account = new VirtualAccount(loggingService, notificationService, healthCheckService, signalsService, this);
            }

            accountTimedTask          = new AccountTimedTask(loggingService, healthCheckService, this);
            accountTimedTask.Interval = Config.AccountRefreshInterval * 1000 / Application.Speed;
            accountTimedTask.Run();
            Application.Resolve <ICoreService>().AddTask(nameof(AccountTimedTask), accountTimedTask);

            if (signalsService.Config.Enabled)
            {
                signalsService.Start();
            }

            tradingTimedTask                = new TradingTimedTask(loggingService, notificationService, healthCheckService, signalsService, this);
            tradingTimedTask.Interval       = Config.TradingCheckInterval * 1000 / Application.Speed;
            tradingTimedTask.StartDelay     = Constants.TimedTasks.StandardDelay;
            tradingTimedTask.LoggingEnabled = !isReplayingSnapshots;
            Application.Resolve <ICoreService>().AddTask(nameof(TradingTimedTask), tradingTimedTask);

            tradingRulesTimedTask          = new TradingRulesTimedTask(loggingService, notificationService, healthCheckService, rulesService, signalsService, this);
            tradingRulesTimedTask.Interval = RulesConfig.CheckInterval * 1000 / Application.Speed;
            Application.Resolve <ICoreService>().AddTask(nameof(TradingRulesTimedTask), tradingRulesTimedTask);

            IsTradingSuspended = false;

            loggingService.Info("Trading service started");
        }