示例#1
0
        public string SendOrder(string buySell, double price, InstrumentProc instrument)
        {
            XTAPI.TTOrderProfileClass TTOrderProfile = new XTAPI.TTOrderProfileClass();

            TTOrderProfile.Instrument = instrument.ttInstrObj;

            TTOrderProfile.Customer = "<Default>";

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

            try
            {
                int submittedQuantity = instrument.ttOrderSet.get_SendOrder(TTOrderProfile);
            }
            catch (Exception ex) {
                if (log.IsErrorEnabled)
                {
                    log.Error(ex.StackTrace);
                }
            }

            return(Convert.ToString(TTOrderProfile.get_GetLast("SiteOrderKey")));
        }
示例#2
0
        public Order( string action, int wkqty, double Price, string SOK, InstrumentProc iproc)
        {
            this.BuySell = action;
            this.wkqty   = wkqty;
            this.price = Price;
            this.orderID = SOK;
            this.iproc = iproc;

            fills = new List<Fill>();
        }
示例#3
0
        public Order(string action, int wkqty, double Price, string SOK, InstrumentProc iproc)
        {
            this.BuySell = action;
            this.wkqty   = wkqty;
            this.price   = Price;
            this.orderID = SOK;
            this.iproc   = iproc;

            fills = new List <Fill>();
        }
示例#4
0
 private bool CancelReplace(string buySell, string key, InstrumentProc iproc, int WkQty, double price)
 {
     if (log.IsDebugEnabled)
     {
         log.Debug(new System.Text.StringBuilder("CXLR ").AppendFormat("{0} price:{1} qty:{2}"
                                                                       , buySell, price, WkQty)
                   );
     }
     return(procSpread.CxlReplace(buySell, key, iproc, price, WkQty));
 }
示例#5
0
        private bool CancelReplace(string buySell, string key, InstrumentProc iproc, int WkQty, int PayUpTicks)
        {
            double price = buySell == "Buy" ? market.bid(iproc.Product) + iproc.TickPrice * PayUpTicks : market.ask(iproc.Product) - iproc.TickPrice * PayUpTicks;

            if (log.IsDebugEnabled)
            {
                log.Debug(
                    new System.Text.StringBuilder("CXLR ").AppendFormat("{0} price:{1} qty:{2}"
                                                                        , buySell, price, WkQty)
                    );
            }
            return(procSpread.CxlReplace(buySell, key, iproc, price, WkQty));
        }
示例#6
0
        public void Connect(Session s)
        {
            productOne = new InstrumentProc(s.instrumentA);
            productTwo = new InstrumentProc(s.instrumentB);

            instruments = new List<Instrument>();
            instruments.Add(s.instrumentA);
            instruments.Add(s.instrumentB);

            productOne.init(TTInstrNotify);
            productTwo.init(TTInstrNotify);

            //setup the events
            TTGate.OnStatusUpdate += new XTAPI._ITTGateEvents_OnStatusUpdateEventHandler(this.OnStatusUpdate);

            productOne.ttOrderSet.OnOrderFillData += new XTAPI._ITTOrderSetEvents_OnOrderFillDataEventHandler(this.OnOrderFillData);
            TTInstrNotify.OnNotifyFound += new XTAPI._ITTInstrNotifyEvents_OnNotifyFoundEventHandler(productOne.OnNotifyFound);
            TTInstrNotify.OnNotifyFound += new XTAPI._ITTInstrNotifyEvents_OnNotifyFoundEventHandler(productTwo.OnNotifyFound);
            TTInstrNotify.OnNotifyUpdate += new XTAPI._ITTInstrNotifyEvents_OnNotifyUpdateEventHandler(this.OnNotifyUpdate);

            productTwo.ttOrderSet.OnOrderFillData += new XTAPI._ITTOrderSetEvents_OnOrderFillDataEventHandler(this.OnOrderFillData);

            if (log.IsInfoEnabled)
            {

                log.Info("trading started for spread");
            }

            setLogname();

            /*
            XTAPI.InstrCollection colInst = (XTAPI.InstrCollection)TTGate.Instruments;
            for (int i = 1; i <= colInst.Count; ++i)
            {
                XTAPI.TTInstrObj instr = (XTAPI.TTInstrObj)colInst[i];
               }
            */
        }
示例#7
0
        public void Connect(Session s)
        {
            productOne = new InstrumentProc(s.instrumentA);
            productTwo = new InstrumentProc(s.instrumentB);

            instruments = new List <Instrument>();
            instruments.Add(s.instrumentA);
            instruments.Add(s.instrumentB);

            productOne.init(TTInstrNotify);
            productTwo.init(TTInstrNotify);

            //setup the events
            TTGate.OnStatusUpdate += new XTAPI._ITTGateEvents_OnStatusUpdateEventHandler(this.OnStatusUpdate);

            productOne.ttOrderSet.OnOrderFillData += new XTAPI._ITTOrderSetEvents_OnOrderFillDataEventHandler(this.OnOrderFillData);
            TTInstrNotify.OnNotifyFound           += new XTAPI._ITTInstrNotifyEvents_OnNotifyFoundEventHandler(productOne.OnNotifyFound);
            TTInstrNotify.OnNotifyFound           += new XTAPI._ITTInstrNotifyEvents_OnNotifyFoundEventHandler(productTwo.OnNotifyFound);
            TTInstrNotify.OnNotifyUpdate          += new XTAPI._ITTInstrNotifyEvents_OnNotifyUpdateEventHandler(this.OnNotifyUpdate);

            productTwo.ttOrderSet.OnOrderFillData += new XTAPI._ITTOrderSetEvents_OnOrderFillDataEventHandler(this.OnOrderFillData);

            if (log.IsInfoEnabled)
            {
                log.Info("trading started for spread");
            }

            setLogname();

            /*
             * XTAPI.InstrCollection colInst = (XTAPI.InstrCollection)TTGate.Instruments;
             * for (int i = 1; i <= colInst.Count; ++i)
             * {
             *  XTAPI.TTInstrObj instr = (XTAPI.TTInstrObj)colInst[i];
             * }
             */
        }
示例#8
0
 private bool CancelReplace(string buySell, string key, InstrumentProc iproc, int WkQty, int PayUpTicks)
 {
     double price = buySell == "Buy" ? market.bid(iproc.Product) + iproc.TickPrice * PayUpTicks : market.ask(iproc.Product) - iproc.TickPrice * PayUpTicks;
     if(log.IsDebugEnabled){
         log.Debug(
             new System.Text.StringBuilder("CXLR ").AppendFormat("{0} price:{1} qty:{2}"
                                     ,buySell,price,WkQty)
          );
     }
     return procSpread.CxlReplace(buySell, key, iproc, price,WkQty);
 }
示例#9
0
 private bool CancelReplace(string buySell, string key, InstrumentProc iproc, int WkQty, double price)
 {
     if (log.IsDebugEnabled)
     {
         log.Debug(new System.Text.StringBuilder("CXLR ").AppendFormat("{0} price:{1} qty:{2}"
                                     ,buySell,price,WkQty)
                                     );
     }
     return procSpread.CxlReplace(buySell, key, iproc, price, WkQty);
 }
示例#10
0
        public string SendOrder(string buySell, double price, InstrumentProc instrument)
        {
            XTAPI.TTOrderProfileClass TTOrderProfile = new XTAPI.TTOrderProfileClass();

            TTOrderProfile.Instrument = instrument.ttInstrObj;

            TTOrderProfile.Customer = "<Default>";

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

            try
            {
                int submittedQuantity = instrument.ttOrderSet.get_SendOrder(TTOrderProfile);
            }
            catch (Exception ex) {
                if (log.IsErrorEnabled) log.Error(ex.StackTrace);
            }

            return (Convert.ToString(TTOrderProfile.get_GetLast("SiteOrderKey")));
        }
示例#11
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;
        }
示例#12
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);
        }