Exemplo 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);
        }
Exemplo 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);
        }
Exemplo n.º 3
0
        public TradeBot(
            TradeBotOptions options,
            ILogger <TradeBot> logger,
            ILoggerFactory loggerFactory,
            IEmailHelper emailHelper,
            BackgroundJobServer hangfireServer)
        {
            this._timeLeftToSendEmail = 0;
            this._options             = options;
            this._logger         = logger;
            this._emailHelper    = emailHelper;
            this._loggerFactory  = loggerFactory;
            this._hangfireServer = hangfireServer;

            this._logger.LogInformation("Bot is created successfully");
        }
Exemplo n.º 4
0
 public TradeBot(TradeBotOptions options)
 {
     this._timeLeftToSendEmail = 0;
     this._options             = options;
 }
Exemplo n.º 5
0
 public TradeInfoAnalyzer(
     TradeBotOptions tradeOptions)
 {
     this._options = tradeOptions;
 }