Ejemplo n.º 1
0
        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);
        }
Ejemplo n.º 2
0
        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);
        }
Ejemplo n.º 3
0
        //



        /// <summary>
        /// Gets the session id of user console session
        /// </summary>
        /// <returns>Session id of user console session</returns>
        public static int GetConsoleSessionId()
        {
            ExecutionServiceClient executionServiceClient = ExecutionServiceClient.Connect();

            if (executionServiceClient != null)
            {
                ExecutionServiceClientConnection connection = executionServiceClient.BeginConnection(RuntimeConnectionName, true);
                return(connection.UserSessionGetConsoleSessionId());
            }
            else
            {
                throw new InvalidOperationException("Can't get a connection to ExecutionServiceClient");
            }
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Connects to user session specified by sessionId
        /// </summary>
        /// <param name="sessionId">Session Id to disconnect from</param>
        public static void ConnectToUserSession(int sessionId)
        {
            ExecutionServiceClient executionServiceClient = ExecutionServiceClient.Connect();

            if (executionServiceClient != null)
            {
                ExecutionServiceClientConnection connection = executionServiceClient.BeginConnection(RuntimeConnectionName, true);
                connection.UserSessionConnect(sessionId, "Console");
            }
            else
            {
                throw new InvalidOperationException("Can't get a connection to ExecutionServiceClient");
            }
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Sets a registry value, using the same syntax as Registry.SetValue
        /// </summary>
        /// <param name="keyName">name of the registry key including hive</param>
        /// <param name="valueName">name of the key value, string.empty = default</param>
        /// <param name="value">registry key value, null will delete the registry value</param>
        public static void SetRegistryValue(string keyName, string valueName, object value)
        {
            //Connect to the exectution service
            ExecutionServiceClient executionServiceClient = ExecutionServiceClient.Connect();

            if (executionServiceClient != null)
            {
                ExecutionServiceClientConnection connection = executionServiceClient.BeginConnection(RuntimeConnectionName, true);
                connection.SetRegistryValue(keyName, valueName, value);
            }
            else
            {
                //The Execution Service is not istalled so do this in process
                //NOTE: this wont work for HKEY_LM keys under LUA without ExecutionService
                if (valueName != null && !Object.Equals(value, null))
                {
                    Registry.SetValue(keyName, valueName, value);
                }
                else
                {
                    RegistryState.DeleteRegistryValue(keyName, valueName);
                }
            }
        }