Ejemplo n.º 1
0
        public ITradeBot Build()
        {
            this._configureServicesDelegate(this._serviceCollection);
            this._serviceCollection.AddSingleton <IConfiguration>(this._configuration);
            this._serviceProvider = this._serviceCollection.BuildServiceProvider();

            this._options = new TradeBotOptions(this._configuration);

            var logger        = this._serviceProvider.GetRequiredService <ILogger <TradeBot> >();
            var loggerFactory = this._serviceProvider.GetRequiredService <ILoggerFactory>();

            this._logger = logger;

            var tradeFlowAnalyzer = this.AnalyzeTradeFlow();

            this._options.TradeAccounts = tradeFlowAnalyzer.TradeAccounts;
            this._options.BuyAccount    = tradeFlowAnalyzer.BuyAccount;
            this._options.SellAccount   = tradeFlowAnalyzer.SellAccount;
            this._options.CapPublisher  = this._capPublisher;

            var emailHelper = this._serviceProvider.GetRequiredService <IEmailHelper>();

            GlobalConfiguration.Configuration.UseSqlServerStorage(this._configuration["Hangfire:ConnectionString"]);
            var hangfireServer = new BackgroundJobServer();

            var tradeBot = new TradeBot(
                this._options,
                logger,
                loggerFactory,
                emailHelper,
                hangfireServer);

            return(tradeBot);
        }
Ejemplo n.º 2
0
        public ITradeBot Build()
        {
            this._options = new TradeBotOptions(this._configuration);

            var tradeFlowAnalyzer = this.AnalyzeTradeFlow();

            this._options.BuyAccount  = tradeFlowAnalyzer.BuyAccount;
            this._options.SellAccount = tradeFlowAnalyzer.SellAccount;

            var tradeBot = new TradeBot(_options);

            return(tradeBot);
        }