Ejemplo n.º 1
0
        long tl_gotSrvFillRequest(Order o)

        {
            //if (!ok)
            //{
            //    debug("not logged in.");
            //    return (long)MessageTypes.SYMBOL_NOT_LOADED;
            //}
            // string action = o.side ? "buy" : "sell";
            string otype = o.isLimit ? "limit" : "market";


            if (o.id == 0)
            {
                o.id = OrderImpl.Unique;
            }

            //if (o.ex.ToUpper().Contains("ARCA"))
            //    route = "ecn_arca";
            //else if (o.ex.ToUpper().Contains("INET"))
            //    route = "inet";



            itemOrder newOrder = new itemOrder();

            newOrder.mtrid    = traderid;
            newOrder.msecsym  = o.symbol.ToUpper();
            newOrder.mstatus  = 0;
            newOrder.morderid = 0;

            newOrder.mexchange = Convert.ToByte(o.ex);

            if (o.side)
            {
                newOrder.mstatus |= 1 << 6;
            }
            else
            {
                int ty = 1;
            }

            if (o.isMarket)
            {
                newOrder.mstatus |= 1 << 9;
            }


            if (o.isLimit)
            {
                newOrder.mprice = Convert.ToDouble(o.price);
            }

            if (o.isStop)
            {
                newOrder.mstatus   |= 1 << 10;
                newOrder.mstopprice = Convert.ToDouble(o.stopp);
            }


            int err = 0;

            try
            {
                // itemAccount itemA = socketOrderServer.sitemAccount.FindItemByName(Session["acct_num"].ToString());

                foreach (int i in socketOrderServer.sitemAcct_Access.GetAccountIDs(traderid))
                {
                    accid = i;
                    //break;
                }

                itemAccount itemA = socketOrderServer.sitemAccount.FindItem(accid);
                newOrder.maccid = itemA.mitemifo.maccid;
                newOrder.mbrid  = itemA.mitemifo.mbrid;
                newOrder.mrrno  = itemA.mitemifo.mrrno;



                newOrder.mtmforce = 65535;  //Day Order

                newOrder.mroute = "AUTO";;
                newOrder.mqty   = Math.Abs(o.size);

                string errMsg = "";
                long   morig  = 0;



                err = itemOrder.LSendOrder(newOrder, ref errMsg, true, socketOrderServer, ref morig);
                if ((err != 0) || ((errMsg != null) && (errMsg != string.Empty)))
                {
                    debug("error occured sending order: " + o.ToString() + " err: " + Util.PrettyError(Providers.DAS, err));
                }
                else
                {
                    v(o.symbol + " successfully sent: " + o.ToString() + " morig: " + morig);
                }
                ls.Add(morig);
            }

            catch (Exception ex)
            {
                debug("DAS exception occured sending order: " + o.ToString() + " err: " + ex.Message + ex.StackTrace);
                return((long)MessageTypes.INVALID_ORDERSIZE);
            }

            return((long)err);
        }
Ejemplo n.º 2
0
        long tl_gotSrvFillRequest(Order o)

        {
            string otype = o.isLimit ? "limit" : "market";


            if (o.id == 0)
            {
                o.id = OrderImpl.Unique;
            }
            string route = "auto";



            itemOrder newOrder = new itemOrder();

            newOrder.mtrid    = traderid;
            newOrder.msecsym  = o.symbol.ToUpper();
            newOrder.mstatus  = 0;
            newOrder.morderid = 0;

            newOrder.mexchange = Convert.ToByte(o.ex);

            if (o.side)
            {
                newOrder.mstatus |= 1 << 6;
            }
            else
            {
                int ty = 1;
            }

            if (o.isMarket)
            {
                newOrder.mstatus |= 1 << 9;
            }


            if (o.isLimit)
            {
                newOrder.mprice = Convert.ToDouble(o.price);
            }

            if (o.isStop)
            {
                newOrder.mstatus   |= 1 << 10;
                newOrder.mstopprice = Convert.ToDouble(o.stopp);
            }



            try
            {
                // itemAccount itemA = socketOrderServer.sitemAccount.FindItemByName(Session["acct_num"].ToString());

                foreach (int i in socketOrderServer.sitemAcct_Access.GetAccountIDs(traderid))
                {
                    accid = i;
                    //break;
                }

                itemAccount itemA = socketOrderServer.sitemAccount.FindItem(accid);
                newOrder.maccid = itemA.mitemifo.maccid;
                newOrder.mbrid  = itemA.mitemifo.mbrid;
                newOrder.mrrno  = itemA.mitemifo.mrrno;



                newOrder.mtmforce = 65535;  //Day Order

                newOrder.mroute = "AUTO";;
                newOrder.mqty   = Math.Abs(o.size);

                string errMsg = "";
                long   morig  = 0;



                itemOrder.LSendOrder(newOrder, ref errMsg, true, socketOrderServer, ref morig);
                ls.Add(morig);
            }

            catch (Exception e1)
            {
                return((long)MessageTypes.INVALID_ORDERSIZE);
            }

            return((long)MessageTypes.OK);
        }