private void processCancelOrder(IDownStreamAdaptor adaptor, CancelOrderRequest req) { if (adaptor != null) { try { adaptor.cancelOrder(req.orderId); CancelOrderReply rsp = new CancelOrderReply(); rsp.result = true; rsp.orderId = req.orderId; rsp.exchangeAccount = req.exchangeAccount; rsp.message = "success"; _manager.Publish(rsp); } catch (Exception e) { CancelOrderReply rsp = new CancelOrderReply(); rsp.result = false; rsp.orderId = req.orderId; rsp.exchangeAccount = req.exchangeAccount; rsp.message = e.Message; _manager.Publish(rsp); } } else { CancelOrderReply rsp = new CancelOrderReply(); rsp.result = false; rsp.orderId = req.orderId; rsp.exchangeAccount = req.exchangeAccount; rsp.message = req.exchangeAccount + " not exist"; _manager.Publish(rsp); } }
private void processAmendOrder(IDownStreamAdaptor adaptor, AmendOrderRequest req) { if (adaptor != null) { try { adaptor.amendOrder(req.orderId, req.price, req.quantity); AmendOrderReply rsp = new AmendOrderReply(); rsp.result = true; rsp.orderId = req.orderId; rsp.exchangeAccount = req.exchangeAccount; rsp.message = "sucess"; _manager.Publish(rsp); } catch (Exception e) { AmendOrderReply rsp = new AmendOrderReply(); rsp.result = false; rsp.orderId = req.orderId; rsp.exchangeAccount = req.exchangeAccount; rsp.message = e.Message; _manager.Publish(rsp); } } else { AmendOrderReply rsp = new AmendOrderReply(); rsp.result = false; rsp.orderId = req.orderId; rsp.message = req.exchangeAccount + " not exist"; _manager.Publish(rsp); } }
private void processNewOrder(IDownStreamAdaptor adaptor, NewOrderRequest req) { if (adaptor != null) { try { Order order = new Order(req.exchangeAccount, req.symbol, req.orderId, req.price, req.quantity, (OrderSide)req.orderSide, (OrderType)req.orderType, req.account); adaptor.newOrder(order); NewOrderReply rsp = new NewOrderReply(); rsp.result = true; rsp.orderId = req.orderId; rsp.exchangeAccount = req.exchangeAccount; rsp.message = "sucess"; _manager.Publish(rsp); } catch (Exception e) { NewOrderReply rsp = new NewOrderReply(); rsp.result = false; rsp.orderId = req.orderId; rsp.exchangeAccount = req.exchangeAccount; rsp.message = e.Message; _manager.Publish(rsp); } } else { NewOrderReply rsp = new NewOrderReply(); rsp.result = false; rsp.orderId = req.orderId; rsp.exchangeAccount = req.exchangeAccount; rsp.message = req.exchangeAccount + " not exist"; _manager.Publish(rsp); } }
public void OnMessage(object obj) { if (!(obj is ISpecificRecord)) { return; } ISpecificRecord avroObj = (ISpecificRecord)obj; ObjectType type = (ObjectType)avroObj.Get(0); switch (type) { case ObjectType.AmendOrderRequest: { AmendOrderRequest req = (AmendOrderRequest)avroObj; logger.Info("Get AmendOrderRequest: " + req.ToString()); IDownStreamAdaptor adaptor = _manager.downStreamManager.getAdaptorById(req.exchangeAccount); processAmendOrder(adaptor, req); break; } case ObjectType.CancelOrderRequest: { CancelOrderRequest req = (CancelOrderRequest)avroObj; logger.Info("Get CancelOrderRequest: " + req.ToString()); IDownStreamAdaptor adaptor = _manager.downStreamManager.getAdaptorById(req.exchangeAccount); processCancelOrder(adaptor, req); break; } case ObjectType.NewOrderRequest: { NewOrderRequest req = (NewOrderRequest)avroObj; logger.Info("Get NewOrderRequest: " + req.ToString()); IDownStreamAdaptor adaptor = _manager.downStreamManager.getAdaptorById(req.exchangeAccount); processNewOrder(adaptor, req); break; } case ObjectType.SubscribeQuote: { SubscribeQuote req = (SubscribeQuote)avroObj; break; } case ObjectType.UnsubscribeQuote: { break; } default: { //Log Error logger.Error("Undefined ObjectType: " + type); return; } } }
public AdaptorListener(BusniessManager remoteEventManager, IDownStreamAdaptor adaptor) { this._manager = remoteEventManager; this._adaptor = adaptor; }