public override void CancelOrder(long orderId, int botId)
        {
            CCommandStucture cs = new CCommandStucture();

            cs.CommandName = "FutDelOrder";
            cs.Command     = new CCommandDelOrder(orderId);
            // m_connOrderControl.CommandQueue.Add(cs);
            m_dictConnOrderControl[botId].CommandQueue.Add(cs);
        }
        public override void CancelAllOrders(int buy_sell, int ext_id, string isin, int botId)
        {
            CCommandStucture cs = new CCommandStucture();

            cs.CommandName = "FutDelUserOrders";
            cs.Command     = new CCommandDelUserOrders(buy_sell, ext_id, isin);
            // m_connOrderControl.CommandQueue.Add(cs);
            //m_dictConnOrderControl[botId].CommandQueue.Add(cs);
            m_dictConnOrderControl[botId].CommandQueue.Add(cs);
            Log("Cancel all orders. ext_id=" + ext_id + " isin=" + isin);
        }
Esempio n. 3
0
        private void ProcessCommandStructure(CCommandStucture cs)
        {
            switch (cs.CommandName)
            {
            case "FutAddOrder": AddOrder(cs); break;

            case "FutDelOrder": DeleteOrder(cs); break;

            case "FutDelUserOrders": DeleteUserOrders(cs); break;

            case "Dummy": ProcessDummyStruct(); break;
            }
        }
Esempio n. 4
0
        private void ThreadProcessCommands()
        {
            CommandQueue = new System.Collections.Concurrent.BlockingCollection <CCommandStucture>();

            CCommandStucture comStruct = new CCommandStucture();

            comStruct.CommandName = "Dummy";   //to remove first iteration delay
            CommandQueue.Add(comStruct);

            foreach (CCommandStucture cs in CommandQueue.GetConsumingEnumerable())
            {
                if (bEnableCommandQueue)
                {
                    Log("Process command struct");
                    ProcessCommandStructure(cs);
                }
            }
        }
Esempio n. 5
0
        private void AddOrder(CCommandStucture cs)
        {
            CCommandAddOrder ao = (CCommandAddOrder)cs.Command;

            Message     sendMessage = m_publishersList[0].Publisher.NewMessage(MessageKeyType.KeyName, "FutAddOrder");
            DataMessage smsg        = (DataMessage)sendMessage;



            DateTime dtExp = DateTime.Now.AddHours(48);

            try
            {
                smsg.UserId = (uint)ao.UserId;

                smsg["broker_code"].set(ao.Broker_code);
                smsg["isin"].set(ao.Isin);
                smsg["client_code"].set(ao.Client_code);
                smsg["type"].set((int)ao.Type);
                smsg["dir"].set((int)ao.Dir);    //1 -buy 2 -sell
                smsg["amount"].set(ao.Amount);
                smsg["price"].set(ao.Price);
                smsg["ext_id"].set(ao.Ext_id);
                smsg["date_exp"].set(dtExp.ToString("yyyyMMdd"));



                m_publishersList[0].Publisher.Post(sendMessage, PublishFlag.NeedReply);
                // Log("Add order isin=" + smsg["isin"] + " type=" + smsg["type"] + " dir=" + smsg["dir"] + " price="  +  smsg["price"] +  " amount=" + smsg["amount"]);
                Log("Add order isin=" + ao.Isin + " type=" + ao.Type + " dir=" + ao.Dir + " price=" + ao.Price + " amount=" + ao.Amount + " ext_id=" + ao.Ext_id);
            }
            catch (Exception e)
            {
                if ((DateTime.Now - m_dtLastOKConnection).TotalSeconds < m_parSecsSinceConnOK)
                {
                    Log("Error in  CConnection.AddOrder. " + e.Message);
                    Error("Error in  CConnection.AddOrder. ", e);
                }
            }



            sendMessage.Dispose();
        }
        //TODO remove supervisorID
        public override void AddOrder(int botId, string isin, decimal price, EnmOrderDir dir, decimal dcmlAmount)
        {
            int iAmount         = Convert.ToInt32(dcmlAmount);
            CCommandStucture cs = new CCommandStucture();

            cs.CommandName = "FutAddOrder";

            cs.Command = (object)new CCommandAddOrder(1, Broker_code, isin, Client_code, OrderTypes.Part, dir, iAmount, price.ToString(), botId);
            //m_connOrderControl.CommandQueue.Add(cs);
            int connId = 0;

            /*if (supervisorID == 0)*/
            connId = botId;

            /*else
             *  connId = supervisorID;
             */
            m_dictConnOrderControl[connId].CommandQueue.Add(cs);

            Log("Add new order dir=" + dir + " amount=" + dcmlAmount + " price=" + price + " botId=" + botId);
        }
Esempio n. 7
0
        private void DeleteOrder(CCommandStucture cs)

        {
            try
            {                                                                                           //TODO change to commandname
                Message     sendMessage = m_publishersList[0].Publisher.NewMessage(MessageKeyType.KeyName, "FutDelOrder");
                DataMessage smsg        = (DataMessage)sendMessage;

                CCommandDelOrder delo = (CCommandDelOrder)cs.Command;

                smsg["order_id"].set(delo.Order_id);


                m_publishersList[0].Publisher.Post(sendMessage, PublishFlag.NeedReply);


                smsg.Dispose();
            }catch (Exception e)
            {
                Log("Error deleting order. " + e.Message);
                Error("Error deleting order", e);
            }
        }
Esempio n. 8
0
        private void DeleteUserOrders(CCommandStucture cs)
        {
            try
            {
                Message     sendMessage = m_publishersList[0].Publisher.NewMessage(MessageKeyType.KeyName, cs.CommandName);
                DataMessage smsg        = (DataMessage)sendMessage;

                CCommandDelUserOrders delu = (CCommandDelUserOrders)cs.Command;

                smsg["buy_sell"].set(delu.Buy_sell);
                smsg["non_system"].set(0);
                smsg["code"].set(m_plaza2Connector.Client_code);
                smsg["ext_id"].set(delu.Ext_id);
                smsg["isin"].set(delu.Isin);
                m_publishersList[0].Publisher.Post(sendMessage, PublishFlag.NeedReply);
                Log("Cancel user orders Buy_Sell=" + delu.Buy_sell + " Ext_id" + delu.Ext_id + " Isin=" + delu.Isin);
            }
            catch (Exception e)
            {
                string err = "Error delete user orders";
                Log(err);
                Error(err, e);
            }
        }