public void Initialize(string username, string[] servers, ILoggerFactory loggerFactory = null, string authToken = null) { _loggerFactory = loggerFactory ?? new DebugLoggerFactory(); _log = _loggerFactory.Create(typeof(ReactiveTrader)); _connectionProvider = new ConnectionProvider(username, servers, _loggerFactory); var referenceDataServiceClient = new ReferenceDataServiceClient(_connectionProvider, _loggerFactory); var executionServiceClient = new ExecutionServiceClient(_connectionProvider); var blotterServiceClient = new BlotterServiceClient(_connectionProvider, _loggerFactory); var pricingServiceClient = new PricingServiceClient(_connectionProvider, _loggerFactory); if (authToken != null) { var controlServiceClient = new ControlServiceClient(new AuthTokenProvider(authToken), _connectionProvider, _loggerFactory); _controlRepository = new ControlRepository(controlServiceClient); } PriceLatencyRecorder = new PriceLatencyRecorder(); var concurrencyService = new ConcurrencyService(); var tradeFactory = new TradeFactory(); var executionRepository = new ExecutionRepository(executionServiceClient, tradeFactory, concurrencyService); var priceFactory = new PriceFactory(executionRepository, PriceLatencyRecorder); var priceRepository = new PriceRepository(pricingServiceClient, priceFactory, _loggerFactory); var currencyPairUpdateFactory = new CurrencyPairUpdateFactory(priceRepository); TradeRepository = new TradeRepository(blotterServiceClient, tradeFactory); ReferenceData = new ReferenceDataRepository(referenceDataServiceClient, currencyPairUpdateFactory); }
public void Initialize(string username, string[] servers, ILoggerFactory loggerFactory = null, string authToken = null) { _loggerFactory = loggerFactory ?? new DebugLoggerFactory(); _log = _loggerFactory.Create(typeof(ReactiveTrader)); var concurrencyService = new ConcurrencyService(); _serviceClientContainer = new WampServiceClientContainer(servers[0], username, concurrencyService, _loggerFactory); // TODO: Make the Async Connection better _serviceClientContainer.ConnectAsync().Wait(); var referenceDataServiceClient = new ReferenceDataServiceClient(_serviceClientContainer.Reference, _loggerFactory); var executionServiceClient = new ExecutionServiceClient(_serviceClientContainer.Execution); var blotterServiceClient = new BlotterServiceClient(_serviceClientContainer.Blotter, _loggerFactory); var pricingServiceClient = new PricingServiceClient(_serviceClientContainer.Pricing, _loggerFactory); PricingServiceClient = pricingServiceClient; PriceLatencyRecorder = new PriceLatencyRecorder(); var tradeFactory = new TradeFactory(); var executionRepository = new ExecutionRepository(executionServiceClient, tradeFactory, concurrencyService); var priceFactory = new PriceFactory(executionRepository, PriceLatencyRecorder); var priceRepository = new PriceRepository(pricingServiceClient, priceFactory, _loggerFactory); var currencyPairUpdateFactory = new CurrencyPairUpdateFactory(priceRepository); TradeRepository = new TradeRepository(blotterServiceClient, tradeFactory); ReferenceData = new ReferenceDataRepository(referenceDataServiceClient, currencyPairUpdateFactory); }