Exemple #1
0
        public static void Add(QuickFix42.Message msg)
        {
            ClOrdID clientId  = new ClOrdID();
            OrdType orderType = new OrdType();

            msg.getField(clientId);


            Msgs.Add(clientId.getValue(), msg);


            if (msg.isSetField(orderType))
            {
                msg.getField(orderType);
                if (orderType.getValue() == OrdType.LIMIT)
                {
                    LimitOrders.Add(clientId.getValue());
                    LimitLib.Add(clientId.getValue());
                }
            }
        }
Exemple #2
0
        public QuickFix42.OrderCancelReplaceRequest GenerateReplaceRequest(string clOrdId, int qty, double limitPx, double stopPx, int index)
        {
            string originalId = (string)LimitOrders[index];

            QuickFix42.Message msg = Msgs[originalId];


            //check for a recent ID
            string temp = LimitLib.GetRecentId(originalId);

            if (temp != null)
            {
                LimitLib.Add(originalId, clOrdId);  //associate new Id
                originalId = temp;                  //send with most recent from previous request
            }
            else
            {
                LimitLib.Add(originalId, clOrdId);
            }

            Side oldSide = new Side();

            msg.getField(oldSide);

            TransactTime uTime = new TransactTime();

            msg.getField(uTime);

            QuickFix42.OrderCancelReplaceRequest ocrr = new QuickFix42.OrderCancelReplaceRequest(
                new OrigClOrdID(originalId),
                new ClOrdID(clOrdId),
                new HandlInst('1'),
                new Symbol(msg.getField(Symbol.FIELD)),
                oldSide,
                uTime,
                new OrdType(OrdType.LIMIT));

            // Update prices and quantity
            ocrr.set(limitPx > 0 ? new Price(limitPx) : new Price(double.Parse(msg.getField(Price.FIELD))));

            if (stopPx > 0) // If the user specified a new stop price
            {
                ocrr.set(new StopPx(stopPx));
            }
            else
            { // Otherwise use the original stop price
                StopPx spx = new StopPx();
                if (msg.isSetField(spx))
                {
                    msg.getField(spx);
                    ocrr.set(spx);
                }
                else
                {
                    msg.setField(spx);
                }
            }

            ocrr.set(qty > 0 ? new OrderQty(qty) : new OrderQty(int.Parse(msg.getField(OrderQty.FIELD))));

            OrderID oid = new OrderID("x");

            ocrr.setField(oid);
            ocrr.setField(57, msg.getField(57));
            ocrr.setField(9102, msg.getField(9102));

            return(ocrr);
        }