Exemple #1
0
        void tl_newOrderCancelRequest(long number)
        {
            int orderid = Convert.ToInt32(number);



            if (orderid == 0)
            {
                return;
            }


            if (!socketOrderServer.sitemOrder.sordermap.ContainsKey(Convert.ToInt32(number)))
            {
                return;
            }

            itemOrder porder = socketOrderServer.sitemOrder.sordermap[orderid];

            if (!porder.IsOpenOrder())
            {
                return;
            }

            if (porder.mlvsqty > 0)
            {
                iManager im = new iManager(socketOrderServer);
                im.Send_CancelOrder(porder, 0);

                tl.newCancel(number);
            }
        }
Exemple #2
0
        private void TradeHandler(object sender, TradeArgs e)
        {
            itemTrade itrade = e.ItemTrade;



            // Order o = new OrderImpl(iorder.msecsym, iorder.IsBuyOrder(), iorder.mqty, Convert.ToDecimal(iorder.mprice), Convert.ToDecimal(iorder.mstopprice), "", iorder.mc_date, iorder.mc_date, iorder.morderid);
            Trade trade = new TradeImpl();

            trade.symbol = itrade.msecsym;
            itemOrder lorder = socketOrderServer.sitemOrder.FindItem(itrade.morderid);

            if (lorder == null)
            {
                return;
            }
            trade.side   = lorder.IsBuyOrder();
            trade.xprice = Convert.ToDecimal(itrade.mprice);
            trade.xsize  = itrade.mqty;
            DateTime mdate = ComFucs.GetDate(itrade.mm_date);

            trade.Account = "";
            trade.xdate   = mdate.Day + mdate.Month * 100 + mdate.Year * 10000;
            trade.xtime   = mdate.Second + mdate.Minute * 100 + mdate.Hour * 10000;
            tl.newFill(trade);
            v(trade.symbol + " received fill ack for: " + trade.ToString());
        }
Exemple #3
0
        private void OrderNotifyHandler(object sender, OrderArgs e)
        {
            itemOrder iorder = e.ItemOrder;
            // if (!ls.Contains(iorder.morigtkn)) return;
            DateTime mdate = ComFucs.GetDate(iorder.mm_date);
            Order    o     = new OrderImpl(iorder.msecsym, iorder.IsBuyOrder(), iorder.mqty, Convert.ToDecimal(iorder.mprice), Convert.ToDecimal(iorder.mstopprice), "",
                                           mdate.Second + mdate.Minute * 100 + mdate.Hour * 10000, mdate.Second + mdate.Minute * 100 + mdate.Hour * 10000, iorder.morderid);

            tl.newOrder(o);
        }
Exemple #4
0
        void tl_newOrderCancelRequest(long number)
        {
            int orderid = Convert.ToInt32(number);



            if (orderid == 0)
            {
                v("ignoring cancel for invalid id: 0");
                return;
            }


            if (!socketOrderServer.sitemOrder.sordermap.ContainsKey(Convert.ToInt32(number)))
            {
                v("ignoring cancel for unknown order: " + number);
                return;
            }

            itemOrder porder = socketOrderServer.sitemOrder.sordermap[orderid];

            if (!porder.IsOpenOrder())
            {
                v("ignoring cancel for closed order, tlid: " + number + " sym: " + porder.msecsym + " ord: " + porder.ToString());
                return;
            }

            if (porder.mlvsqty > 0)
            {
                try
                {
                    iManager im = new iManager(socketOrderServer);
                    im.Send_CancelOrder(porder, 0);
                    v("requested cancel for: " + number + " sym: " + porder.msecsym + " ord: " + porder.ToString());
                }
                catch (Exception ex)
                {
                    debug("DAS error canceling order: " + number + " err: " + ex.Message + ex.StackTrace);
                }

                tl.newCancel(number);
            }
            else
            {
                v("ignoring cancel for order with zero size, tlid: " + number + " sym: " + porder.msecsym + " ord: " + porder.ToString());
            }
        }
Exemple #5
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
            {
                
            }

            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;
        }
Exemple #6
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);
        }
Exemple #7
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;
        }
Exemple #8
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);
        }