Exemplo n.º 1
0
        public async Task <IActionResult> AddRoute([FromBody] NewMatchingEngineRouteRequest request)
        {
            var newRoute = DomainObjectsFactory.CreateRoute(request);
            await _routesManager.AddOrReplaceRouteAsync(newRoute);

            return(Ok(newRoute));
        }
Exemplo n.º 2
0
        public void OneTimeSetUp()
        {
            RegisterDependencies();
            _accountsCacheService        = Container.Resolve <IAccountsCacheService>();
            _tradingConditionsManager    = Container.Resolve <TradingConditionsManager>();
            _matchingEngineRoutesManager = Container.Resolve <MatchingEngineRoutesManager>();
            if (_matchingEngineRoutesManager == null)
            {
                throw new Exception("Unable to resolve MatchingEngineRoutesCacheService");
            }

            // Add user accounts
            var account1 = new MarginTradingAccount()
            {
                ClientId = "CLIENT001"
            };
            var account2 = new MarginTradingAccount()
            {
                ClientId = "CLIENT002"
            };
            var account3 = new MarginTradingAccount()
            {
                ClientId = "CLIENT003"
            };
            var account4 = new MarginTradingAccount()
            {
                ClientId = "CLIENT004"
            };

            _accountsCacheService.UpdateAccountsCache(account1.ClientId, new[] { account1 });
            _accountsCacheService.UpdateAccountsCache(account2.ClientId, new[] { account2 });
            _accountsCacheService.UpdateAccountsCache(account3.ClientId, new[] { account3 });
            _accountsCacheService.UpdateAccountsCache(account4.ClientId, new[] { account4 });

            // Add trading conditions
            System.Threading.Tasks.Task.Run(async() =>
            {
                await _tradingConditionsManager.AddOrReplaceTradingConditionAsync(new TradingCondition()
                {
                    Id = "TCID001", Name = "MarginTradingCondition 1", IsDefault = true
                });
                await _tradingConditionsManager.AddOrReplaceTradingConditionAsync(new TradingCondition()
                {
                    Id = "TCID003", Name = "MarginTradingCondition 3", IsDefault = false
                });
                await _tradingConditionsManager.AddOrReplaceTradingConditionAsync(new TradingCondition()
                {
                    Id = "TCID004", Name = "MarginTradingCondition 4", IsDefault = false
                });
                await _tradingConditionsManager.AddOrReplaceTradingConditionAsync(new TradingCondition()
                {
                    Id = "TCID005", Name = "MarginTradingCondition 5", IsDefault = false
                });
            }).Wait();


            System.Threading.Tasks.Task.Run(async() =>
            {
                await _matchingEngineRoutesManager.AddOrReplaceRouteAsync(new MatchingEngineRoute()
                {
                    Id = "1", Rank = 10, MatchingEngineId = "LYKKE"
                });
                await _matchingEngineRoutesManager.AddOrReplaceRouteAsync(new MatchingEngineRoute()
                {
                    Id = "2", Rank = 5, Instrument = "BTCUSD", MatchingEngineId = "ICM"
                });
                await _matchingEngineRoutesManager.AddOrReplaceRouteAsync(new MatchingEngineRoute()
                {
                    Id = "3", Rank = 4, TradingConditionId = "TCID001", Instrument = "EURCHF", Type = OrderDirection.Buy, MatchingEngineId = "LYKKE"
                });
                await _matchingEngineRoutesManager.AddOrReplaceRouteAsync(new MatchingEngineRoute()
                {
                    Id = "4", Rank = 3, TradingConditionId = "TCID001", ClientId = "CLIENT001", Instrument = "EURCHF", Type = OrderDirection.Buy, MatchingEngineId = "ICM"
                });
                await _matchingEngineRoutesManager.AddOrReplaceRouteAsync(new MatchingEngineRoute()
                {
                    Id = "5", Rank = 4, TradingConditionId = "TCID001", ClientId = "CLIENT002", Instrument = "EURCHF", Type = OrderDirection.Buy, MatchingEngineId = "LYKKE"
                });
                await _matchingEngineRoutesManager.AddOrReplaceRouteAsync(new MatchingEngineRoute()
                {
                    Id = "6", Rank = 4, Instrument = "EURCHF", Type = OrderDirection.Buy, MatchingEngineId = "LYKKE"
                });
                await _matchingEngineRoutesManager.AddOrReplaceRouteAsync(new MatchingEngineRoute()
                {
                    Id = "7", Rank = 4, Instrument = "EURCHF", MatchingEngineId = "LYKKE"
                });
                await _matchingEngineRoutesManager.AddOrReplaceRouteAsync(new MatchingEngineRoute()
                {
                    Id = "8", Rank = 5, ClientId = "CLIENT003", Instrument = "EURCHF", MatchingEngineId = "LYKKE"
                });
                await _matchingEngineRoutesManager.AddOrReplaceRouteAsync(new MatchingEngineRoute()
                {
                    Id = "9", Rank = 6, TradingConditionId = "TCID003", ClientId = "CLIENT002", Instrument = "EURCHF", Type = OrderDirection.Sell, MatchingEngineId = "ICM"
                });
                await _matchingEngineRoutesManager.AddOrReplaceRouteAsync(new MatchingEngineRoute()
                {
                    Id = "10", Rank = 4, TradingConditionId = "TCID004", ClientId = "CLIENT004", Instrument = "EURJPY", MatchingEngineId = "ICM"
                });
                await _matchingEngineRoutesManager.AddOrReplaceRouteAsync(new MatchingEngineRoute()
                {
                    Id = "11", Rank = 4, TradingConditionId = "TCID004", Instrument = "EURJPY", Type = OrderDirection.Buy, MatchingEngineId = "LYKKE"
                });
                await _matchingEngineRoutesManager.AddOrReplaceRouteAsync(new MatchingEngineRoute()
                {
                    Id = "12", Rank = 4, TradingConditionId = "TCID005", Instrument = "EURUSD", Type = OrderDirection.Buy, MatchingEngineId = "LYKKE"
                });
                await _matchingEngineRoutesManager.AddOrReplaceRouteAsync(new MatchingEngineRoute()
                {
                    Id = "13", Rank = 4, TradingConditionId = "TCID005", Instrument = "EURUSD", Type = OrderDirection.Buy, MatchingEngineId = "ICM"
                });
                await _matchingEngineRoutesManager.AddOrReplaceRouteAsync(new MatchingEngineRoute()
                {
                    Id = "14", Rank = 9, Instrument = "BTCEUR", MatchingEngineId = "LYKKE"
                });
                await _matchingEngineRoutesManager.AddOrReplaceRouteAsync(new MatchingEngineRoute()
                {
                    Id = "15", Rank = 7, Type = OrderDirection.Buy, MatchingEngineId = "ICM", Asset = "EUR"
                });
                await _matchingEngineRoutesManager.AddOrReplaceRouteAsync(new MatchingEngineRoute()
                {
                    Id = "16", Rank = 8, Type = OrderDirection.Sell, MatchingEngineId = "ICM", Asset = "EUR"
                });
            }).Wait();

            /* TABLE PROTOTYPE
             *  Id	Rank	tradingConditionId	clientId	instrument	type	matchingEngineId	asset
             *
             *  1	10	    *	                *	        *	        *	    LYKKE
             *  2	5	    *	                *	        BTCUSD	    *	    ICM
             *  3	4	    TCID001	            *	        EURCHF	    Buy	    LYKKE
             *  4	3	    TCID001	            CLIENT001	EURCHF	    Buy	    ICM
             *  5	4	    TCID001	            CLIENT002	EURCHF	    Buy	    LYKKE
             *  6	4	    *	                *	        EURCHF	    Buy	    LYKKE
             *  7	4	    *	                *	        EURCHF	    *	    LYKKE
             *  8	5	    *	                CLIENT003	EURCHF	    *	    LYKKE
             *  9	6	    TCID003	            CLIENT002	EURCHF	    Sell	ICM
             *  10	4	    TCID004	            CLIENT004	EURJPY	    *	    ICM
             *  11	4	    TCID004	            *	        EURJPY	    Buy	    LYKKE
             *  12	4	    TCID005	            *	        EURUSD	    Buy	    LYKKE
             *  13	4	    TCID005	            *	        EURUSD	    Buy	    ICM
             *  14	9	    *	                *	        BTCEUR	    *	    LYKKE
             *  15	7	    *	                *		                Buy	    ICM	                EUR
             *  16	8	    *	                *		                Buy     LYKKE	            EUR
             *
             *
             */
        }