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();
     return response;
 }
 public void Send(TradeRequest tradeRequest)
 {
     // post process message from conversion before sending
     MessageQueueTemplate.ConvertAndSend(tradeRequest, delegate(Message message)
                                                           {
                                                               message.ResponseQueue = GetResponseQueue();
                                                               message.AppSpecific = random.Next();
                                                               return message;
                                                           });
 }
예제 #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);
 }
예제 #4
0
        public TradeResponse Handle(TradeRequest tradeRequest)
        {
            log.Info("received trade request - sleeping 2s to simulate long-running task");
            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);

            Thread.Sleep(2000);
            return tradeResponse;
        }
예제 #5
0
 public void ProcessTrade(TradeRequest request, TradeResponse response)
 {
     //do nothing implementation, typical implementations would persist state to the database.
 }
 public bool CanExecute(TradeRequest tradeRequest, IList errors)
 {
     return true;
 }