Example #1
0
        public LottoXClient(RagingBullConfig rbConfig, OCRConfig ocrConfig, PortfolioDatabase database, MarketDataClient marketDataClient) : base(rbConfig, database, marketDataClient)
        {
            PositionBuilder    positionBuilder = new PositionBuilder(marketDataClient, database);
            FilledOrderBuilder orderBuilder    = new FilledOrderBuilder(marketDataClient, database);

            ImageToPositionsConverter = new ImageToPositionsConverter(ocrConfig, positionBuilder);
            ImageToOrdersConverter    = new ImageToOrdersConverter(ocrConfig, orderBuilder);
            QuantityConsistencyClient = new ImageConsistencyClient();
            HeaderConsistencyClient   = new ImageConsistencyClient();
            OrderConsistencyClient    = new ImageConsistencyClient();
        }
Example #2
0
        public Worker(
            IHostApplicationLifetime hostApplicationLifetime,
            IOptions <RagingBullConfig> rbOptions,
            IOptions <TDAmeritradeConfig> tdOptions,
            IOptions <OCRConfig> ocrOptions,
            IOptions <GeneralConfig> generalOptions,
            IOptions <OrderConfig> orderOptions,
            IOptions <ElmahConfig> elmahOptions)
        {
            _hostApplicationLifetime = hostApplicationLifetime;
            _ragingBullConfig        = rbOptions.Value;
            _tdAmeritradeConfig      = tdOptions.Value;
            _ocrConfig     = ocrOptions.Value;
            _generalConfig = generalOptions.Value;
            _orderConfig   = orderOptions.Value;
            _elmahConfig   = elmahOptions.Value;

            ElmahClient = ElmahioAPI.Create(_elmahConfig.ApiKey);
            TDClient tdClient = new TDClient(_tdAmeritradeConfig);

            MarketDataClient = tdClient;
            string            lottoxDbPath   = _generalConfig.DatabasePath + "/LottoX.db";
            string            symbolsDbPath  = _generalConfig.DatabasePath + "/Symbols.db";
            PortfolioDatabase lottoxDatabase = new LitePortfolioDatabase(lottoxDbPath, symbolsDbPath);

            LivePortfolioClient = new LottoXClient(_ragingBullConfig, _ocrConfig, lottoxDatabase, MarketDataClient);

            if (_generalConfig.UsePaperTrade)
            {
                Log.Information("PAPER TRADING");
                string            paperDbPath        = _generalConfig.DatabasePath + "/Paper.db";
                string            paperSymbolsDbPath = _generalConfig.DatabasePath + "/PaperSymbols.db";
                PortfolioDatabase paperDatabase      = new LitePortfolioDatabase(paperDbPath, paperSymbolsDbPath);
                BrokerClient = new PaperTradeBrokerClient(paperDatabase, MarketDataClient);
            }
            else
            {
                Log.Information("*****Trading with real account");
                BrokerClient = tdClient;
            }
            OrderManager = new OrderManager(BrokerClient, MarketDataClient, _orderConfig);
        }