示例#1
0
        public bool Delete(Order delorder)
        {
            bool      orderDeleted;
            Container container = ProcessContainers(bookRoot, delorder.Instrument, delorder, null);

            //container = ProcessContainers(container.ChildContainers, order.OrderType, order, container);
            if (container.ChildContainers.Exists(delorder.BuySell.ToString()) == false)
            {
                LeafContainer buyContainer  = new LeafContainer(this, "B", container);
                LeafContainer sellContainer = new LeafContainer(this, "S", container);
                container.ChildContainers["B"] = buyContainer;
                container.ChildContainers["S"] = sellContainer;
            }
            LeafContainer leafContainer = container.ChildContainers[delorder.BuySell.ToString()] as LeafContainer;

            if (leafContainer != null)
            {
                orderDeleted = leafContainer.DeleteOrder(delorder);
            }
            else
            {
                orderDeleted = false;
            }

            return(orderDeleted);
        }
示例#2
0
        public void newPriceQuote(Object a)
        {
            while (true)
            {
                newQuote.WaitOne(10000, false);

                LeafContainer buyBook  = this.parentContainer.ChildContainers["B"] as LeafContainer;
                LeafContainer sellBook = this.parentContainer.ChildContainers["S"] as LeafContainer;

                if (buyBook != null && sellBook != null)
                {
                    if (buyBook.OrderQuote() == "" || sellBook.OrderQuote() == "")
                    {
                        Console.WriteLine("No price");
                    }

                    string buyBookQuote  = buyBook.OrderQuote();
                    string sellBookQuote = sellBook.OrderQuote();

                    //currentPrice = buyBookQuote == "N/A" ? Convert.ToDouble(sellBookQuote) : sellBookQuote == "N/A" ?
                    //    Convert.ToDouble(buyBookQuote) : (Convert.ToDouble(buyBook.OrderQuote()) + Convert.ToDouble(sellBook.OrderQuote())) / 2.0;

                    XElement xml = new XElement("Method");
                    xml.Add(new XAttribute("PriceQuote", "RSXM"));
                    xml.Add(new XElement("Field", new XAttribute("Name", "Buy"), buyBookQuote),
                            new XElement("Field", new XAttribute("Name", "Sell"), sellBookQuote));


                    string quote = this.parentContainer.contName + "," + buyBook.OrderQuote() + "," + sellBook.OrderQuote();
                    Exchange.QuoteSender.sendQuote(xml.ToString());
                }
                newQuote.Reset();
            }
        }
示例#3
0
        public Order CurrentPrice(string Instrument, string BuySell)
        {
            //Order curPrice = bookRoot[Instrument].ChildContainers["Regular"].ChildContainers["B"];
            LeafContainer leafContainer = bookRoot[Instrument].ChildContainers[BuySell] as LeafContainer;

            Order curOrder = leafContainer.OrderQuote();

            return(curOrder);
        }
示例#4
0
        public void ProcessMktOrder(Order order)
        {
            //LeafContainer leafContainer = bookRoot[order.Instrument].ChildContainers["Limit"].ChildContainers[order.BuySell.ToString()] as LeafContainer;
            LeafContainer leafContainer = bookRoot[order.Instrument].ChildContainers[order.BuySell.ToString()] as LeafContainer;

            if (leafContainer != null)
            {
                leafContainer.ProcessMktOrder(order);
            }
            else
            {
                Console.WriteLine("No order book setup");
            }
        }
示例#5
0
        public void ProcessStopOrder(Order order)
        {
            Container container = ProcessContainers(bookRoot, order.Instrument, order, null);

            //container = ProcessContainers(container.ChildContainers, order.OrderType, order, container);
            if (container.ChildContainers.Exists(order.BuySell.ToString()) == false)
            {
                LeafContainer buyContainer  = new LeafContainer(this, "B", container);
                LeafContainer sellContainer = new LeafContainer(this, "S", container);
                container.ChildContainers["B"] = buyContainer;
                container.ChildContainers["S"] = sellContainer;
            }
            LeafContainer leafContainer = container.ChildContainers[order.BuySell.ToString()] as LeafContainer;

            leafContainer.useResourceAddStop(order);
        }
示例#6
0
        public bool Delete(Order delorder)
        {
            bool orderDeleted;

            LeafContainer leafContainer = bookRoot[delorder.Instrument].ChildContainers[delorder.BuySell.ToString()] as LeafContainer;

            if (leafContainer != null)
            {
                orderDeleted = leafContainer.DeleteOrder(delorder);
            }
            else
            {
                orderDeleted = false;
            }

            return(orderDeleted);
        }
示例#7
0
        public void Process(Order order)
        {
            Container container = ProcessContainers(bookRoot, order.Instrument, order, null);

            container = ProcessContainers(container.ChildContainers, order.OrderType, order, container);
            if (container.ChildContainers.Exists(order.BuySell.ToString()) == false)
            {
                LeafContainer buyContainer  = new LeafContainer(this, "B", container);
                LeafContainer sellContainer = new LeafContainer(this, "S", container);
                container.ChildContainers["B"] = buyContainer;
                container.ChildContainers["S"] = sellContainer;
            }
            LeafContainer leafContainer = container.ChildContainers[order.BuySell.ToString()] as LeafContainer;

            //Console.WriteLine("enter......");
            leafContainer.ProcessOrder(order);
        }
示例#8
0
        public void StopToMarket(object Order)
        {
            FuturesOrder order = (FuturesOrder)Order;
            //  OrderBook temp = new OrderBook();
            Container container = ProcessContainers(bookRoot, order.Instrument, order, null);

            container = ProcessContainers(container.ChildContainers, order.OrderType, order, container);
            if (container.ChildContainers.Exists(order.BuySell.ToString()) == false)
            {
                LeafContainer buyContainer  = new LeafContainer(this, "B", container);
                LeafContainer sellContainer = new LeafContainer(this, "S", container);
                container.ChildContainers["B"] = buyContainer;
                container.ChildContainers["S"] = sellContainer;
            }
            LeafContainer leafContainer = container.ChildContainers[order.BuySell.ToString()] as LeafContainer;

            Console.WriteLine("check stop order at orderBook StopToMarket");
            leafContainer.ProcessStopOrder(order);
        }
示例#9
0
        public void newPriceQuote(Object a)
        {
            while (true)
            {
                newQuote.WaitOne(10000, false);

                LeafContainer buyBook  = this.parentContainer.ChildContainers["B"] as LeafContainer;
                LeafContainer sellBook = this.parentContainer.ChildContainers["S"] as LeafContainer;

                if (buyBook != null && sellBook != null)
                {
                    if (buyBook.OrderQuote() == "" || sellBook.OrderQuote() == "")
                    {
                        Console.WriteLine("No price");
                    }
                    string quote = this.parentContainer.contName + "," + buyBook.OrderQuote() + "," + sellBook.OrderQuote();
                    Exchange.QuoteSender.sendQuote(quote);
                }
                newQuote.Reset();
            }
        }
示例#10
0
        //This method looks after the arrangement of order in order tree,
        //based on key attributes of the order it seeks appropriate node
        //in tree, in case if a node doesn’t exists it creates a new node
        //by instantiating the appropriate Container Class.
        //The logic deviates a bit when it comes to creation of leaf node of
        //the tree (i.e. Buy or Sell Node), we fallback to LeafContainer
        //class that is where the actual order is rested.
        public void Process(Order order)
        {
            Container container = ProcessContainers(bookRoot, order.Instrument, order, null);

            container = ProcessContainers(container.ChildContainers, order.OrderType, order, container);

            //Logic deviates a bit, if it is a buy or sell node
            //then leafcontainer is created which actually holds the order
            if (container.ChildContainers.Exists(order.BuySell.ToString()) == false)
            {
                //create buy and sell leaf container
                LeafContainer buyContainer  = new LeafContainer(this, "B", container);
                LeafContainer sellContainer = new LeafContainer(this, "S", container);
                container.ChildContainers["B"] = buyContainer;
                container.ChildContainers["S"] = sellContainer;
            }

            //Based on the buy/sell attribute of the order
            //access the underlying leaf container
            LeafContainer leafContainer = container.ChildContainers[order.BuySell.ToString()] as LeafContainer;

            //process the order
            leafContainer.ProcessOrder(order);
        }