public void ShutDown() { m_Notify.OnNotifyUpdate -= new InstrNotifyClass.OnNotifyUpdateEventHandler(OnNotifyUpdate); m_OrderSet.OnOrderFillData -= new OrderSetClass.OnOrderFillDataEventHandler(OnOrderFillData); m_Notify = null; m_Instr = null; m_OrderSet = null; }
public Instrument() { //Trade matcher below set at FIFO, AvgCost m_Matcher = new TradeMatcher(RoundTurnMethod.FIFO); //dataGridView1.DataSource = m_Matcher.BuyTable; //dataGridView2.DataSource = m_Matcher.SellTable; //dataGridView3.DataSource = m_Matcher.RoundTurns; // Create a new InstrObjClass object //Making Calls to Trader API m_Instr = new InstrObjClass("CME", "ES", InstrObjClass.ProdType.FUTURE, "Sep16", 125000); // Create a new InstrNotifyClass object from the InstrObjClass object. //subscribe to the observer m_Notify = ( InstrNotifyClass )m_Instr.CreateNotifyObj; // Enable price updates. m_Notify.EnablePriceUpdates = true; // Set UpdateFilter so event will fire anytime any one of these changes in the // associated InstrObjClass object. m_Notify.UpdateFilter = "LAST,LASTQTY"; // Subscribe to the OnNotifyUpdate event. m_Notify.OnNotifyUpdate += new InstrNotifyClass.OnNotifyUpdateEventHandler(OnNotifyUpdate); // Set the exchange, product, contract and product type. // Open m_Instr. m_Instr.Open(true); // Create a new OrderSetClass object. m_OrderSet = new OrderSetClass(); // Set the limits accordingly. If any of these limits is reached, // trading through the API will be shut down automatically. m_OrderSet.set_Set("MAXORDERS", 1000); m_OrderSet.set_Set("MAXORDERQTY", 1000); m_OrderSet.set_Set("MAXWORKING", 1000); m_OrderSet.set_Set("MAXPOSITION", 1000); // Enable deleting of orders. Enable the OnOrderFillData event. Enable order sending. m_OrderSet.EnableOrderAutoDelete = true; m_OrderSet.EnableOrderFillData = true; m_OrderSet.EnableOrderSend = true; // Subscribe to the OnOrderFillData event. m_OrderSet.OnOrderFillData += new OrderSetClass.OnOrderFillDataEventHandler(OnOrderFillData); // Open the m_OrderSet. m_OrderSet.Open(true); // Associate m_OrderSet with m_Instr. m_Instr.OrderSet = m_OrderSet; }
public Instrument() { m_Matcher = new TradeMatcher(RoundTurnMethod.FIFO); // Create a new InstrObjClass object m_Instr = new InstrObjClass(); // Create a new InstrNotifyClass object from the InstrObjectClass object. m_Notify = (InstrNotifyClass)m_Instr.CreateNotifyObj; // Enable price updates. m_Notify.EnablePriceUpdates = true; // Set UpdateFilter so event will fire anytime any one of these changes in the // associated InstrObjClass object. m_Notify.UpdateFilter = "LAST, LASTQTY"; // Subscribe to the OnNotifyUpdate event. m_Notify.OnNotifyUpdate += new InstrNotifyClass.OnNotifyUpdateEventHandler(OnNotifyUpdate); // Set the exchange, product, contract and product type. m_Instr.Exchange = "CME"; m_Instr.Product = "ES"; m_Instr.Contract = "Sep12"; m_Instr.ProdType = "FUTURE"; // Open m_Instr. m_Instr.Open(true); // Create a new OrderSetClass object. m_OrderSet = new OrderSetClass(); // Set the limits accordingly. If any of these limits is reached, // trading through the API will be shut down automatically. m_OrderSet.set_Set("MAXORDERS", 1000); m_OrderSet.set_Set("MAXORDERQTY", 1000); m_OrderSet.set_Set("MAXWORKING", 1000); m_OrderSet.set_Set("MAXPOSITION", 1000); // Enable deleting of orders. Enable the OnOrderFillData event. Enable order sending. m_OrderSet.EnableOrderAutoDelete = true; m_OrderSet.EnableOrderFillData = true; m_OrderSet.EnableOrderSend = true; // Subscribe to the OnOrderFillData event. m_OrderSet.OnOrderFillData += new OrderSetClass.OnOrderFillDataEventHandler(OnOrderFillData); // Open the m_OrderSet. m_OrderSet.Open(true); // Associate m_OrderSet with m_Instr. m_Instr.OrderSet = m_OrderSet; }
private void startButton_Click(System.Object sender, System.EventArgs e) { // Create a new InstrObjClass object m_Instr = new InstrObjClass(); // Create a new InstrNotifyClass object from the InstrObjClass object. m_Notify = ( InstrNotifyClass )m_Instr.CreateNotifyObj; // Enable price updates. m_Notify.EnablePriceUpdates = true; // Set UpdateFilter so event will fire anytime any one of these changes in the // associated InstrObjClass object. m_Notify.UpdateFilter = "BIDQTY,BID,ASK,ASKQTY,LAST,LASTQTY"; // Subscribe to the OnNotifyUpdate event. m_Notify.OnNotifyUpdate += new InstrNotifyClass.OnNotifyUpdateEventHandler(this.OnUpdate); // Set the exchange, product, contract and product type. m_Instr.Exchange = "CME"; m_Instr.Product = "ES"; m_Instr.Contract = "Dec12"; m_Instr.ProdType = "FUTURE"; // Open m_Instr. m_Instr.Open(true); // Create a new OrderSetClass object. m_OrderSet = new OrderSetClass(); // Set the limits accordingly. If any of these limits is reached, // trading through the API will be shut down automatically. m_OrderSet.set_Set("MAXORDERS", 1000); m_OrderSet.set_Set("MAXORDERQTY", 1000); m_OrderSet.set_Set("MAXWORKING", 1000); m_OrderSet.set_Set("MAXPOSITION", 1000); // Enable deleting of orders. Enable the OnOrderFillData event. Enable order sending. m_OrderSet.EnableOrderAutoDelete = true; m_OrderSet.EnableOrderFillData = true; m_OrderSet.EnableOrderSend = true; // Subscribe to the OnOrderFillData event. m_OrderSet.OnOrderFillData += new OrderSetClass.OnOrderFillDataEventHandler(this.OnFill); // Open the m_OrderSet. m_OrderSet.Open(true); // Associate m_OrderSet with m_Instr. m_Instr.OrderSet = m_OrderSet; }
private void shutdown(object sender, EventArgs e) { // Shut down should include explicit object destruction. m_Notify.OnNotifyUpdate -= new InstrNotifyClass.OnNotifyUpdateEventHandler(this.OnUpdate); m_OrderSet.OnOrderFillData -= new OrderSetClass.OnOrderFillDataEventHandler(this.OnFill); m_Instr = null; m_OrderSet = null; m_Notify = null; GC.Collect(); }