Beispiel #1
0
        public int Delete(string key, XTAPI.TTOrderSetClass ttorderSet)
        {
            XTAPI.TTOrderObj order = (XTAPI.TTOrderObj)ttorderSet.get_SiteKeyLookup(key);
            int res = order.DeleteOrder();

            if (log.IsDebugEnabled)
            {
                log.Debug(
                    new System.Text.StringBuilder("Deleted: ").AppendFormat("{0} from {1}", res, key)
                    );
            }

            return(res);
        }
Beispiel #2
0
        public bool CxlReplace(string buySell, string key, InstrumentProc iproc, double price, int WkQty)
        {
            bool status = true;

            if (log.IsDebugEnabled)
            {
                log.Debug(
                    new System.Text.StringBuilder("cxlreplace called ")
                    .AppendFormat("{0} {1} qty:{2}", key, price, WkQty)
                    );
            }


            XTAPI.TTOrderObj orderobj = (XTAPI.TTOrderObj)iproc.ttOrderSet.get_SiteKeyLookup(key);


            /*
             * http://devnetkb.tradingtechnologies.com/ViewKnowledgeEntry.aspx?KnowledgeEntryID=2387
             */

            try
            {
                while ((orderobj != null) && (Convert.ToInt32(orderobj.get_Get("ExecutionType")) != 1))
                //while ( (orderobj.IsNull == 0) && (Convert.ToInt32(orderobj.get_Get("ExecutionType")) != 1) )
                {
                    System.Threading.Thread.Sleep(5);
                    orderobj = (XTAPI.TTOrderObj)iproc.ttOrderSet.get_SiteKeyLookup(key);
                }
            }
            catch (Exception exo) {
                return(false);
            }


            if (orderobj.IsNull == 0)
            {
                XTAPI.TTOrderProfile TTOrderProfile = new XTAPI.TTOrderProfile();

                TTOrderProfile = orderobj.CreateOrderProfile;

                TTOrderProfile.Instrument = iproc.ttInstrObj;
                TTOrderProfile.Customer   = "<Default>";

                TTOrderProfile.Set("Acct", iproc.Account);
                TTOrderProfile.Set("AcctType", "M1");
                TTOrderProfile.Set("BuySell", buySell);
                TTOrderProfile.Set("Qty", WkQty);
                TTOrderProfile.Set("OrderType", "L");
                TTOrderProfile.Set("Limit#", Convert.ToString(price));
                TTOrderProfile.Set("FFT2", "M");
                TTOrderProfile.Set("FFT3", "CXLR");

                try
                {
                    iproc.ttOrderSet.UpdateOrder(TTOrderProfile, 0);
                }
                catch (Exception ex)
                {
                    status = false;

                    if (log.IsErrorEnabled)
                    {
                        System.Text.StringBuilder msg = new System.Text.StringBuilder("ERROR cxlreplace order ")
                                                        .AppendFormat("{0} {1} {2}", key, buySell, WkQty);
                        log.Error(msg);
                        log.Error(ex.StackTrace);
                        log.Error(ex.Message);
                    }
                }
            }

            return(status);
        }