Ejemplo n.º 1
0
 public static OrderState c(QuickFix.Fields.OrdStatus s)
 {
     var val = s_ordState.Find(v => v.first.getValue() == s.getValue());
     if (val == null)
         throw new Exception("Unmapped QuickFix.Fields.OrdStatus value : " + s.ToString());
     return val.second;
 }
Ejemplo n.º 2
0
 public static OrderAction c(QuickFix.Fields.Side s)
 {
     var val = s_sides.Find(v => v.first.getValue() == s.getValue());
     if (val == null)
         throw new Exception("Unmapped QuickFix.Fields.Side value : " + s.ToString());
     return val.second;
 }
Ejemplo n.º 3
0
        protected void RejectCancelRequest(QuickFix.SessionID session, QuickFix.Fields.ClOrdID clordid, QuickFix.Fields.OrigClOrdID origordid, IOrder nt7_order, string rej_reason, int cxl_rej, bool is_cancelreplace_request)
        {
            QuickFix.FIX42.OrderCancelReject rej = new QuickFix.FIX42.OrderCancelReject();
            if (nt7_order == null)
                rej.Set(new QuickFix.Fields.OrderID("NONE"));
            else
                rej.Set(new QuickFix.Fields.OrderID(clordid.getValue()));

            rej.Set(origordid);
            rej.Set(Converter.c(nt7_order.OrderState));
            rej.Set(new QuickFix.Fields.CxlRejResponseTo(is_cancelreplace_request ? QuickFix.Fields.CxlRejResponseTo.ORDER_CANCEL_REPLACE_REQUEST : QuickFix.Fields.CxlRejResponseTo.ORDER_CANCEL_REQUEST));
            rej.Set(new QuickFix.Fields.CxlRejReason(cxl_rej));
            rej.Set(new QuickFix.Fields.Text(rej_reason));
            rej.Set(new QuickFix.Fields.TransactTime(DateTime.Now, true));

            QuickFix.Session.SendToTarget(rej, session);
        }
Ejemplo n.º 4
0
        protected void ProcessOrderCancelRequest(QuickFix.SessionID session, QuickFix.Fields.ClOrdID clordid, QuickFix.Fields.OrigClOrdID origordid
            , bool is_cancelreplace_request, int new_qty, double new_px, double new_stop_px)
        {
            IOrder order = null;
            try
            {
                // order exists ?
                OrderFixBridge order_bridge ;
                lock(locker_)
                    order_bridge = m_orders.AddOrGet(null, origordid.getValue(), session);

                if (order_bridge.Order == null)
                {
                    RejectCancelRequest(session, clordid, origordid, null, "Unknown order !", QuickFix.Fields.CxlRejReason.UNKNOWN_ORDER, true);
                    return;
                }

                order = order_bridge.Order;

                switch (order.OrderState)
                {
                    // order is still alive, go ahead
                    case OrderState.Accepted:
                    case OrderState.PartFilled:
                    case OrderState.Working:
                        if (is_cancelreplace_request)
                            QuickFixStaticAcceptor.FromFIX_ChangeOrder(order, new_qty, new_px, new_stop_px);
                        else
                            QuickFixStaticAcceptor.FromFIX_CancelOrder(order);

                        return;

                    // pending
                    case OrderState.PendingChange: //VV?
                    case OrderState.PendingSubmit: //VV?
                    case OrderState.PendingCancel: //VV?
                        {
                            string error_message = "Invalid cancel or cancel/replace request since order " + origordid.getValue() + " is in pending state : " + order.OrderState.ToString();
                            RejectCancelRequest(session, clordid, origordid, order, error_message, QuickFix.Fields.CxlRejReason.ALREADY_PENDING, is_cancelreplace_request);
                            return;
                        }

                    // terminal state
                    case OrderState.Cancelled:
                    case OrderState.Filled:
                    case OrderState.Rejected:
                        {
                            string error_message = "Invalid cancel or cancel/replace request since order " + origordid.getValue() + " is in terminal/closed state : " + order.OrderState.ToString();
                            RejectCancelRequest(session, clordid, origordid, order, error_message, QuickFix.Fields.CxlRejReason.TOO_LATE_TO_CANCEL, is_cancelreplace_request);
                            return;
                        }
                    case OrderState.Unknown:
                        {
                            string error_message = "Invalid cancel or cancel/replace request since order " + origordid.getValue() + " is in unknow NT7 state : " + order.OrderState.ToString();
                            RejectCancelRequest(session, clordid, origordid, order, error_message, QuickFix.Fields.CxlRejReason.OTHER, is_cancelreplace_request);
                            return;
                        }
                }
            }
            catch (Exception e)
            {
                RejectCancelRequest(session, clordid, origordid, order, "ProcessOrderCancelRequest : internal Error : " + e.ToString()
                , QuickFix.Fields.CxlRejReason.OTHER, is_cancelreplace_request);
            }
        }