Пример #1
0
        public int addFills(OrderFillStruct ofs) // stored the fills in db and send it to fillpublisher
        {
            OrderDAO ord       = new OrderDAO();
            int      ordStatus = ord.addOrderFills(ofs);

            if (ordStatus == -1)
            {
                Console.WriteLine("error in DB");
                return(-1);
            }
            else if (ordStatus == 0)
            {
                Console.WriteLine("This Order is completed now [Order ID] = " + ofs.OrderNo);
            }
            else
            {
                Console.WriteLine("Order qty diff : " + ordStatus);
            }
            string machineID = "";
            string userID    = "";

            ord.getMachineAndUserFromDB(ofs.OrderNo, ref machineID, ref userID);
            OMFillPub ofp = new OMFillPub();

            if (ofp.zmqUpdate(ofs, machineID, userID) == 0)
            {
                Console.WriteLine("Zmq update success");
            }
            else
            {
                Console.WriteLine("Zmq update fail");
            }
            return(0);
        }
Пример #2
0
        public int FIXResponseHandler(Int32 OrderID, string ExchangeOrderId, Int32 origOrdID, char status, string status_msg, string other_msg, float price, char orderType)
        {
            string      data = "";
            OrderDAO    ord  = new OrderDAO();
            OrderStruct os   = new OrderStruct();
            int         iret = -1;

            if (status == 'X') // i am considering the reject of amendment.
            {                  // rejected so move the order to originalID
                iret = ord.setOrdersWithReplacedFixResponse(origOrdID, getExecType(status), ExchangeOrderId, ref os);
            }
            else if (status == '5')
            { // accepted the amendment i.e. Replaced so add the new ord no.
                iret = ord.setOrdersWithReplacedFixResponse(OrderID, getExecType(status), ExchangeOrderId, ref os);
            } // In case of Order Rejected - call DB for reject status.
            else if (status == 'D')
            {
                iret = ord.setOrdersWithFixResponseRestated(OrderID, getExecType(status), ExchangeOrderId, price, orderType, ref os);

                os.price     = price;
                os.orderType = Convert.ToInt32(orderType);
            }
            else
            {
                iret = ord.setOrdersWithFixResponse(OrderID, getExecType(status), ExchangeOrderId, ref os);
            }
            if (iret == -1)
            {
                Console.WriteLine("Error from DB [" + data + "]");
                //return -1;
            }
            else
            {
                Console.WriteLine("Order Updated");
            }
            data = new string(os.machineID) + ":" + new string(os.userID) + ":" + os.OrderNo + ":" + new string(os.OrderStatus) + ":" + ExchangeOrderId + ":" + status + ":" + status_msg + ":" + other_msg;
            OMFillPub ofp = new OMFillPub();

            if (ofp.zmqUpdates(data) == 0)
            {
                Console.WriteLine("Zmq update success");
            }
            else
            {
                Console.WriteLine("Zmq update fail");
            }
            ord.addFIXResponse(OrderID, ExchangeOrderId, status, status_msg, other_msg);
            return(0);
        }
Пример #3
0
        public int FIXResponseCanModRejectHandler(Int32 OrderID, string ExchangeOrderId, Int32 origOrdID, char status, string status_msg, string other_msg)
        {
            string      data = "";
            OrderDAO    ord  = new OrderDAO();
            OrderStruct os   = new OrderStruct();
            int         iret = -1;

            Console.WriteLine("FIXResponseCanModRejectHandler : " + status);
            if (status == '1')
            { // rejected so move the order to originalID
                //iret = ord.setOrdersWithReplacedFixResponse(origOrdID, "CANCEL_REJECTED", ExchangeOrderId, ref os);
                iret = ord.setOrdersWithFixResponse(OrderID, "CANCEL_REJECTED", ExchangeOrderId, ref os);
            }
            else if (status == '2')
            { // rejected so move the order to originalID
                //iret = ord.setOrdersWithReplacedFixResponse(origOrdID, "MODIFY_REJECTED", ExchangeOrderId, ref os);
                iret = ord.setOrdersWithFixResponse(OrderID, "MODIFY_REJECTED", ExchangeOrderId, ref os);
            }
            if (iret == -1)
            {
                Console.WriteLine("Error from DB [" + data + "]");
                //return -1;
            }
            else
            {
                Console.WriteLine("Order Updated");
            }
            data = new string(os.machineID) + ":" + new string(os.userID) + ":" + os.OrderNo + ":" + new string(os.OrderStatus) + ":" + ExchangeOrderId + ":" + status + ":" + status_msg + ":" + other_msg;
            OMFillPub ofp = new OMFillPub();

            if (ofp.zmqUpdates(data) == 0)
            {
                Console.WriteLine("Zmq update success");
            }
            else
            {
                Console.WriteLine("Zmq update fail");
            }
            ord.addFIXResponse(OrderID, ExchangeOrderId, status, status_msg, other_msg);
            return(0);
        }
Пример #4
0
        public int FIXResponseHandlerForFill(int OrderID, string ExchangeOrderId, float qty, float price, float filledQty, string status, char exectype)
        {
            OrderDAO    ord     = new OrderDAO();
            OrderStruct os      = new OrderStruct();
            int         orderNo = ord.getOrderNoFromOrderID(OrderID);

            ord.addOrderFillsFromFIX(OrderID, orderNo, ExchangeOrderId, qty, price, filledQty, status);
            ord.getOrderFromDB(orderNo, ref os);
            float     pos       = ord.getCurrentPosition(os.tokenID, new string(os.userID));
            string    other_msg = Convert.ToString(pos);
            string    data      = new string(os.machineID) + ":" + new string(os.userID) + ":" + os.OrderNo + ":" + new string(os.OrderStatus) + ":" + ExchangeOrderId + ":" + exectype + ":" + status + ":" + other_msg;
            OMFillPub ofp       = new OMFillPub();

            if (ofp.zmqUpdates(data) == 0)
            {
                Console.WriteLine("Zmq update success");
            }
            else
            {
                Console.WriteLine("Zmq update fail");
            }
            return(0);
        }