Simple POCO class that represents a simple trade request
 public void Send(TradeRequest tradeRequest)
 {
     RabbitTemplate.ConvertAndSend(tradeRequest, delegate(Message message)
     {
         message.MessageProperties.ReplyToAddress = new Address(defaultReplyToQueue);
         message.MessageProperties.CorrelationId = new Guid().ToByteArray();
         return message;
     });
 }
        public TradeResponse ExecuteTradeRequest(TradeRequest request)
        {
            TradeResponse response = new TradeResponse();
            response.OrderType = request.OrderType;
            response.Price = CalculatePrice(request.Ticker, request.Quantity, request.OrderType, request.Price, request.UserName);
            response.Quantity = request.Quantity;
            response.Ticker = request.Ticker;
            response.ConfirmationNumber = new Guid().ToString();

            logger.Info("Sleeping 2 seconds to simulate processing...");
            Thread.Sleep(2000);
            return response;
        }
Ejemplo n.º 3
0
        public void SendTradeRequest()
        {
            TradeRequest tradeRequest = new TradeRequest();
            tradeRequest.AccountName = "ACCT-123";
            tradeRequest.BuyRequest = true;
            tradeRequest.OrderType = "MARKET";
            tradeRequest.Quantity = 314000000;
            tradeRequest.RequestId = "REQ-1";
            tradeRequest.Ticker = "CSCO";
            tradeRequest.UserName = "******";

            stockService.Send(tradeRequest);
        }
Ejemplo n.º 4
0
        public TradeResponse Handle(TradeRequest tradeRequest)
        {
            logger.Info("Recieved trade request");
            TradeResponse tradeResponse;
            ArrayList errors = new ArrayList();
            if (creditCheckService.CanExecute(tradeRequest, errors))
            {
                tradeResponse = executionVenueService.ExecuteTradeRequest(tradeRequest);
            }
            else
            {
                tradeResponse = new TradeResponse();
                tradeResponse.Error = true;
                tradeResponse.ErrorMessage = StringUtils.ArrayToCommaDelimitedString(errors.ToArray());

            }
            tradingService.ProcessTrade(tradeRequest, tradeResponse);
            return tradeResponse;
        }
 public bool CanExecute(TradeRequest tradeRequest, IList errors)
 {
     return true;
 }
 public void ProcessTrade(TradeRequest request, TradeResponse response)
 {
     //do nothing implementation, typical implementations would persist state to the database.
 }