Ejemplo n.º 1
0
        public QuickFix42.OrderCancelReplaceRequest SendLimitOrderCancelReplace(string originalId, string orderId, string exId)
        {
            QuickFix42.OrderCancelReplaceRequest m = new QuickFix42.OrderCancelReplaceRequest(new OrigClOrdID(originalId), new ClOrdID(orderId), new HandlInst('1'), new Symbol("ZVZZT"), new Side(Side.BUY), new TransactTime(DateTime.UtcNow), new OrdType(OrdType.LIMIT));

            //additional required fields
            m.set(new OrderQty(100));
            m.set(new OrderID(exId));
            m.set(new Account("1234"));
            m.set(new Price(2.00));
            m.set(new TimeInForce(TimeInForce.DAY));
            m.set(new StopPx(0));

            //RMG Routing
            m.setField(57, "ALGO");
            m.setField(9102, "T");
            m.setField(6210, "0");

            //Price p = new Price(12.99);
            //m.set(p);
            //Session.sendToTarget(m, oKnightSessionID);
            return(m);
        }
Ejemplo n.º 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);
        }