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);
        }
        public void Initialize(IObservable <PriceDto> priceStream, ICurrencyPair currencyPair)
        {
            _loggerFactory = new DebugLoggerFactory();
            var pricingServiceClient = new WatchPricingServiceClient(priceStream);
            var priceFactory         = new PriceFactory(new WatchExecutionRepository(), new PriceLatencyRecorder());
            var priceRepository      = new PriceRepository(pricingServiceClient, priceFactory, _loggerFactory);

            PriceStream = priceRepository.GetPriceStream(currencyPair);
        }
示例#4
0
        public decimal GetPrice(Item item)
        {
            if (item == null || item == default(Item))
            {
                return(0m);
            }
            var _priceFactory = new PriceFactory(item);
            var price         = _priceFactory.GetDiscount();

            return(Math.Round(price, 2));
        }
示例#5
0
        private void Domain()
        {
            Converts.Repository
            .AddJsonEnumSearchHandler()
            .AddJsonPrimitivesSearchHandler()
            .AddJsonObjectSearchHandler()
            .AddJsonKey()
            .AddJsonTimeSpan()
            .Add(new ColorConverter());

            EventStore      = new EntityEventStore(Factory.Default <EventSourcingContext>());
            eventDispatcher = new PersistentEventDispatcher(new EmptyEventStore());
            eventDispatcher.DispatcherExceptionHandlers.Add(this);
            eventDispatcher.EventExceptionHandlers.Add(this);

            IFactory <ICompositeStorage> compositeStorageFactory = Factory.Default <JsonCompositeStorage>();

            ICompositeTypeProvider typeProvider = new ReflectionCompositeTypeProvider(
                new ReflectionCompositeDelegateFactory(),
                BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public
                );

            EventFormatter = new CompositeEventFormatter(typeProvider, compositeStorageFactory);

            OutcomeRepository = new AggregateRootRepository <Outcome>(
                EventStore,
                EventFormatter,
                new ReflectionAggregateRootFactory <Outcome>(),
                eventDispatcher,
                new NoSnapshotProvider(),
                new EmptySnapshotStore()
                );

            CategoryRepository = new AggregateRootRepository <Category>(
                EventStore,
                EventFormatter,
                new ReflectionAggregateRootFactory <Category>(),
                eventDispatcher,
                new NoSnapshotProvider(),
                new EmptySnapshotStore()
                );

            PriceFactory = new PriceFactory("CZK");
            DomainFacade = new DefaultDomainFacade(
                OutcomeRepository,
                CategoryRepository,
                PriceFactory
                );
        }