Example #1
0
        void stiEvents_OnSTIOrderUpdate(ref structSTIOrderUpdate structOrderUpdate)
        {
            Order o = new OrderImpl();

            o.symbol = structOrderUpdate.bstrSymbol;
            uint id = 0;

            if (!uint.TryParse(structOrderUpdate.bstrClOrderId, out id))
            {
                id = (uint)structOrderUpdate.nOrderRecordId;
            }
            o.id      = id;
            o.size    = structOrderUpdate.nQuantity;
            o.side    = o.size > 0;
            o.price   = (decimal)structOrderUpdate.fLmtPrice;
            o.stopp   = (decimal)structOrderUpdate.fStpPrice;
            o.TIF     = structOrderUpdate.bstrTif;
            o.Account = structOrderUpdate.bstrAccount;
            o.ex      = structOrderUpdate.bstrDestination;
            long now  = Convert.ToInt64(structOrderUpdate.bstrUpdateTime);
            int  xsec = (int)(now % 100);
            long rem  = (now - xsec) / 100;

            o.time = ((int)(rem % 10000)) * 100 + xsec;
            o.date = (int)((rem - o.time) / 10000);
            tl.newOrder(o);
        }
Example #2
0
 void stiEvents_OnSTIOrderUpdate(ref structSTIOrderUpdate structOrderUpdate)
 {
     if (UseXmlMode)
     {
         return;
     }
     doorderupdate(ref structOrderUpdate);
 }
Example #3
0
 void stiEvents_OnSTIOrderUpdateXML(ref string bstrOrder)
 {
     try
     {
         XmlSerializer        xs = new XmlSerializer(typeof(SterlingLib.structSTIOrderUpdate));
         structSTIOrderUpdate q  = (structSTIOrderUpdate)xs.Deserialize(new System.IO.StringReader(bstrOrder));
         doorderupdate(ref q);
     }
     catch (Exception ex)
     {
         debug("Error deserializing order: " + bstrOrder);
         debug(ex.Message + ex.StackTrace);
     }
 }
Example #4
0
 void stiEvents_OnSTIOrderUpdate(ref structSTIOrderUpdate structOrderUpdate)
 {
     if (UseXmlMode) return;
     doorderupdate(ref structOrderUpdate);
 }
Example #5
0
        void doorderupdate(ref structSTIOrderUpdate structOrderUpdate)
        {
            Order o = new OrderImpl();
            o.symbol = structOrderUpdate.bstrSymbol;
            long id = 0;
            // see if the order id is unknown
            if (!long.TryParse(structOrderUpdate.bstrClOrderId, out id))
            {
                // use the norderrecordid as our order id
                id = (long)structOrderUpdate.nOrderRecordId;

                // ensure this is not a secondary notification of same order
                string tmp;
                if (!idacct.TryGetValue(id, out tmp))
                {

                    // save the id
                    debug("manual order: " + id + " " + structOrderUpdate.bstrAccount);
                    idacct.Add(id, structOrderUpdate.bstrAccount);
                    ismanorder.Add(id, true);
                }
            }
            // if this is a cancel notification, pass along
            if (structOrderUpdate.nOrderStatus == (int)STIOrderStatus.osSTICanceled)
            {
                // if it's a cancel, we'll have cancel id rather than order id
                // get new id
                long orderid = 0;
                if (_cancel2order.TryGetValue(id, out orderid))
                {
                    tl.newCancel(orderid);
                    if (VerboseDebugging)
                        debug("cancel received for: " + orderid);
                }
                else
                    debug("manual cancel sent with id: " + id);
                return;
            }
            // don't notify for same order more than once
            if (_onotified.Contains(id)) return;
            if (structOrderUpdate.bstrLogMessage.Contains("REJ"))
                debug(id+" "+structOrderUpdate.bstrLogMessage);
            o.id = id;
            o.size = structOrderUpdate.nQuantity;
            o.side = structOrderUpdate.bstrSide == "B";
            o.price = (decimal)structOrderUpdate.fLmtPrice;
            o.stopp = (decimal)structOrderUpdate.fStpPrice;
            o.TIF = structOrderUpdate.bstrTif;
            o.Account = structOrderUpdate.bstrAccount;
            o.ex = structOrderUpdate.bstrDestination;
            long now = Convert.ToInt64(structOrderUpdate.bstrUpdateTime);
            int xsec = (int)(now % 100);
            long rem = (now - xsec) / 100;
            o.time = ((int)(rem % 10000)) * 100 + xsec;
            o.date = (int)((rem - o.time) / 10000);
            _onotified.Add(o.id);
            if (VerboseDebugging)
                debug("order acknowledgement: " + o.ToString());
            tl.newOrder(o);
        }
Example #6
0
        void doorderupdate(ref structSTIOrderUpdate structOrderUpdate)
        {
            STIOrderStatus stat = (STIOrderStatus)structOrderUpdate.nOrderStatus;
            Order o = new OrderImpl();
            string ssym = structOrderUpdate.bstrSymbol;
            if (UseSubscribedSymbolForNotify)
            {
                int idx = getlongsymbolidx(ssym);
                // check for error
                if ((idx < 0) || (idx>=syms.Length))
                {
                    debug(ssym + " order ack error identifying symbol idx: " + idx + " symbols: " + string.Join(",", syms));
                    o.symbol = ssym;
                }
                else
                    o.symbol = syms[idx];
            }
            else
                o.symbol = ssym;
            long id = 0;
            // see if the order id is unknown
            if (!long.TryParse(structOrderUpdate.bstrClOrderId, out id))
            {
                // see if we know the sterling id (sometimes sterling doesn't send full client id)
                if (sterid2tlid.ContainsKey(structOrderUpdate.nOrderRecordId))
                {
                    id = sterid2tlid[structOrderUpdate.nOrderRecordId];

                }
                else
                {
                    // use the norderrecordid as our order id
                    id = (long)structOrderUpdate.nOrderRecordId;

                    // ensure this is not a secondary notification of same order
                    string tmp;
                    if (!idacct.TryGetValue(id, out tmp))
                    {

                        // save the id
                        debug("manual order: " + id + " " + structOrderUpdate.bstrAccount);
                        idacct.Add(id, structOrderUpdate.bstrAccount);
                        ismanorder.Add(id, true);
                    }
                }
            }
            // if this is a cancel notification, pass along
            if (stat == STIOrderStatus.osSTICanceled)
            {
                // if it's a cancel, we'll have cancel id rather than order id
                // get new id
                long orderid = 0;
                if (_cancel2order.TryGetValue(id, out orderid))
                {
                    newcancel(orderid);

                }
                else if (sterid2tlid.ContainsKey(structOrderUpdate.nOrderRecordId))
                {
                    newcancel(sterid2tlid[structOrderUpdate.nOrderRecordId]);
                }
                else
                {
                    debug("exchange_or_user cancel sent with unknown id: " + id);
                    string clid = structOrderUpdate.bstrClOrderId == null ? string.Empty : structOrderUpdate.bstrClOrderId;
                    v("order information.  clid:" + clid + " status: " + stat.ToString() + " nrecid: " + structOrderUpdate.nOrderRecordId + " other: " + Util.DumpObjectProperties(structOrderUpdate));

                }
                return;
            }
            else if (stat == STIOrderStatus.osSTIPendingCancel)
            {
                string clid = structOrderUpdate.bstrClOrderId == null ? string.Empty : structOrderUpdate.bstrClOrderId;
                v("order information.  clid:" + clid + " status: " + stat.ToString() + " nrecid: " + structOrderUpdate.nOrderRecordId + " other: " + Util.DumpObjectProperties(structOrderUpdate));
                return;
            }
            // don't notify for same order more than once
            if (_onotified.Contains(id))
            {
                string clid = structOrderUpdate.bstrClOrderId == null ? string.Empty : structOrderUpdate.bstrClOrderId;
                v("order information.  clid:" + clid + " status: " + stat.ToString() + " nrecid: " + structOrderUpdate.nOrderRecordId+" other: "+Util.DumpObjectProperties(structOrderUpdate));
                return;
            }
            if (structOrderUpdate.bstrLogMessage.Contains("REJ"))
                debug(id+" "+structOrderUpdate.bstrLogMessage);
            o.id = id;
            o.size = structOrderUpdate.nQuantity;
            o.side = structOrderUpdate.bstrSide == "B";
            o.price = (decimal)structOrderUpdate.fLmtPrice;
            o.stopp = (decimal)structOrderUpdate.fStpPrice;
            o.TIF = structOrderUpdate.bstrTif;
            o.Account = structOrderUpdate.bstrAccount;
            o.ex = structOrderUpdate.bstrDestination;
            long now = Convert.ToInt64(structOrderUpdate.bstrUpdateTime);
            int xsec = (int)(now % 100);
            long rem = (now - xsec) / 100;
            o.time = ((int)(rem % 10000)) * 100 + xsec;
            o.date = (int)((rem - o.time) / 10000);
            _onotified.Add(o.id);
            v("order acknowledgement: " + o.ToString()+" status: "+stat.ToString()+" id: "+id+" nrecid: "+structOrderUpdate.nOrderRecordId);
            updateidmap(structOrderUpdate.nOrderRecordId, o.id);
            if (RegSHOShorts)
                sho.GotOrder(o);
            tl.newOrder(o);
            
        }
Example #7
0
        void doorderupdate(ref structSTIOrderUpdate structOrderUpdate)
        {
            Order o = new OrderImpl();

            o.symbol = structOrderUpdate.bstrSymbol;
            long id = 0;

            // see if the order id is unknown
            if (!long.TryParse(structOrderUpdate.bstrClOrderId, out id))
            {
                // use the norderrecordid as our order id
                id = (long)structOrderUpdate.nOrderRecordId;

                // ensure this is not a secondary notification of same order
                string tmp;
                if (!idacct.TryGetValue(id, out tmp))
                {
                    // save the id
                    debug("manual order: " + id + " " + structOrderUpdate.bstrAccount);
                    idacct.Add(id, structOrderUpdate.bstrAccount);
                    ismanorder.Add(id, true);
                }
            }
            // if this is a cancel notification, pass along
            if (structOrderUpdate.nOrderStatus == (int)STIOrderStatus.osSTICanceled)
            {
                // if it's a cancel, we'll have cancel id rather than order id
                // get new id
                long orderid = 0;
                if (_cancel2order.TryGetValue(id, out orderid))
                {
                    tl.newCancel(orderid);
                    if (VerboseDebugging)
                    {
                        debug("cancel received for: " + orderid);
                    }
                }
                else
                {
                    debug("manual cancel sent with id: " + id);
                }
                return;
            }
            // don't notify for same order more than once
            if (_onotified.Contains(id))
            {
                return;
            }
            if (structOrderUpdate.bstrLogMessage.Contains("REJ"))
            {
                debug(id + " " + structOrderUpdate.bstrLogMessage);
            }
            o.id      = id;
            o.size    = structOrderUpdate.nQuantity;
            o.side    = structOrderUpdate.bstrSide == "B";
            o.price   = (decimal)structOrderUpdate.fLmtPrice;
            o.stopp   = (decimal)structOrderUpdate.fStpPrice;
            o.TIF     = structOrderUpdate.bstrTif;
            o.Account = structOrderUpdate.bstrAccount;
            o.ex      = structOrderUpdate.bstrDestination;
            long now  = Convert.ToInt64(structOrderUpdate.bstrUpdateTime);
            int  xsec = (int)(now % 100);
            long rem  = (now - xsec) / 100;

            o.time = ((int)(rem % 10000)) * 100 + xsec;
            o.date = (int)((rem - o.time) / 10000);
            _onotified.Add(o.id);
            if (VerboseDebugging)
            {
                debug("order acknowledgement: " + o.ToString());
            }
            tl.newOrder(o);
        }
Example #8
0
        void stiEvents_OnSTIOrderUpdate(ref structSTIOrderUpdate structOrderUpdate)
        {
            Order o = new OrderImpl();
            o.symbol = structOrderUpdate.bstrSymbol;
            uint id = 0;
            if (!uint.TryParse(structOrderUpdate.bstrClOrderId, out id))
                id = (uint)structOrderUpdate.nOrderRecordId;
            o.id = id;
            o.size = structOrderUpdate.nQuantity;
            o.side = o.size > 0;
            o.price = (decimal)structOrderUpdate.fLmtPrice;
            o.stopp = (decimal)structOrderUpdate.fStpPrice;
            o.TIF = structOrderUpdate.bstrTif;
            o.Account = structOrderUpdate.bstrAccount;
            o.ex= structOrderUpdate.bstrDestination;
            long now = Convert.ToInt64(structOrderUpdate.bstrUpdateTime);
            int xsec = (int)(now % 100);
            long rem = (now - xsec) / 100;
            o.time = ((int)(rem % 10000)) * 100 + xsec;
            o.date = (int)((rem - o.time) / 10000);
            tl.newOrder(o);

        }