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); }
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(); } }
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); }
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"); } }
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); }
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); }
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); }
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); }
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(); } }
//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); }