/// <summary> /// Triggered when the XTAPI receives an order rejection message from the exchange for an /// order in the order set. /// </summary> /// <param name="pRejectedOrderObj">Order object for the rejected order</param> void m_TTOrderSet_OnOrderRejected(XTAPI.TTOrderObj pRejectedOrderObj) { string siteOrderKey = (string)pRejectedOrderObj.get_Get("SiteOrderKey"); txtStatusOut.Text += "Order Rejected by Exchange: " + siteOrderKey + "\r\n\r\n"; }
/// <summary> /// Triggered when a new order is submitted to the exchange or a held order is resubmitted. /// </summary> /// <param name="pNewOrderObj">Order obj containing the updated order info</param> /// <param name="pOldOrderObj">Order obj containing the previous order</param> /// <param name="sSiteOrderKey">UID for the order</param> /// <param name="eOrderAction">Action associated with the submitted order</param> /// <param name="wrkQty">Working qty for the order</param> /// <param name="sOrderType">Order Type associated with the order</param> /// <param name="sOrderTraits">Traits associated with the order</param> void m_TTOrderSet_OnOrderSubmitted(XTAPI.TTOrderObj pNewOrderObj, XTAPI.TTOrderObj pOldOrderObj, string sSiteOrderKey, XTAPI.enumOrderAction eOrderAction, int wrkQty, string sOrderType, string sOrderTraits) { PublishEventOrderData("OnOrderSubmitted", pNewOrderObj, pOldOrderObj); }
/// <summary> /// Publish specific information about each order to the GUI /// </summary> /// <param name="callingMethod">Method that called the publish</param> /// <param name="pNewOrderObj">New order object</param> /// <param name="pOldOrderObj">Old order object</param> private void PublishEventOrderData(string callingMethod, XTAPI.TTOrderObj pNewOrderObj, XTAPI.TTOrderObj pOldOrderObj) { if (pOldOrderObj.IsNull != 0) { txtOrderAuditTrail.Text += callingMethod + " - Old Order: NULL\r\n"; } else { try { Array oldOrderData = (Array)pOldOrderObj.get_Get("Acct,OrdStatus,OrdAction,Contract$,BuySell,OrderQty,Price,SiteOrderKey,OrderNo"); txtOrderAuditTrail.Text += callingMethod + " - Old Order: " + oldOrderData.GetValue(0).ToString() + ", " + oldOrderData.GetValue(1).ToString() + ", " + oldOrderData.GetValue(2).ToString() + ", " + oldOrderData.GetValue(3).ToString() + ", " + oldOrderData.GetValue(4).ToString() + ", " + oldOrderData.GetValue(5).ToString() + ", " + oldOrderData.GetValue(6).ToString() + ", " + oldOrderData.GetValue(7).ToString() + ", " + oldOrderData.GetValue(8).ToString() + "\r\n"; } catch (Exception ex) { txtOrderAuditTrail.Text += callingMethod + " - Old Order: Error Message - " + ex.Message + "\r\n"; } } if (pNewOrderObj.IsNull != 0) { txtOrderAuditTrail.Text += callingMethod + " - New Order: NULL\r\n"; } else { try { Array newOrderData = (Array)pNewOrderObj.get_Get("Acct,OrdStatus,OrdAction,Contract$,BuySell,OrderQty,Price,SiteOrderKey,OrderNo"); txtOrderAuditTrail.Text += callingMethod + " - New Order: " + newOrderData.GetValue(0).ToString() + ", " + newOrderData.GetValue(1).ToString() + ", " + newOrderData.GetValue(2).ToString() + ", " + newOrderData.GetValue(3).ToString() + ", " + newOrderData.GetValue(4).ToString() + ", " + newOrderData.GetValue(5).ToString() + ", " + newOrderData.GetValue(6).ToString() + ", " + newOrderData.GetValue(7).ToString() + ", " + newOrderData.GetValue(8).ToString() + "\r\n"; } catch (Exception ex) { txtOrderAuditTrail.Text += callingMethod + " - New Order: Error Message - " + ex.Message + "\r\n"; } } }
/// <summary> /// This function is called when an instrument is found after it is opened. /// </summary> /// <param name="pNotify">TTInstrNotify object</param> /// <param name="pInstr">TTInstrObj object</param> private void m_TTInstrNotify_OnNotifyFound(XTAPI.TTInstrNotify pNotify, XTAPI.TTInstrObj pInstr) { // Update the Status Bar text. sbaStatus.Text = "Instrument Found."; // Retrieve and display the instrument information. Array data = (Array) pInstr.get_Get("Exchange,Product,ProdType,Contract"); // Test based on Alias property switch (pInstr.Alias) { case "0": txtExchange1.Text = (string)data.GetValue(0); txtProduct1.Text = (string)data.GetValue(1); txtProductType1.Text = (string)data.GetValue(2); txtContract1.Text = (string)data.GetValue(3); break; case "1": txtExchange2.Text = (string)data.GetValue(0); txtProduct2.Text = (string)data.GetValue(1); txtProductType2.Text = (string)data.GetValue(2); txtContract2.Text = (string)data.GetValue(3); break; case "2": txtExchange3.Text = (string)data.GetValue(0); txtProduct3.Text = (string)data.GetValue(1); txtProductType3.Text = (string)data.GetValue(2); txtContract3.Text = (string)data.GetValue(3); break; case "3": txtExchange4.Text = (string)data.GetValue(0); txtProduct4.Text = (string)data.GetValue(1); txtProductType4.Text = (string)data.GetValue(2); txtContract4.Text = (string)data.GetValue(3); break; default: MessageBox.Show(this,"DisplayInstrumentInformation ERROR"); break; } }
/// <summary> /// Triggered when orders are taken out of the market. /// </summary> /// <param name="pNewOrderObj">Order obj containing the updated order info</param> /// <param name="pOldOrderObj">Order obj containing the previous order</param> /// <param name="sSiteOrderKey">UID for the order</param> /// <param name="eOrderState">State of the order before being deleted</param> /// <param name="eOrderAction">Action associated with the submitted order</param> /// <param name="fillQty">Quantity of the delete.</param> void m_TTOrderSet_OnOrderDeleted(XTAPI.TTOrderObj pNewOrderObj, XTAPI.TTOrderObj pOldOrderObj, string sSiteOrderKey, XTAPI.enumOrderNotifyState eOrderState, XTAPI.enumOrderAction eOrderAction, int delQty) { PublishEventOrderData("OnOrderDeleted", pNewOrderObj, pOldOrderObj); }
private void OnNotifyUpdate(XTAPI.TTInstrNotify pNotify, XTAPI.TTInstrObj pInstr) { try { Array data = (Array)pInstr.get_Get("Bid#,Ask#,NetPos,PL.Z,OpenPL^"); //get currency amount of tick double tickvalue = Convert.ToDouble(pInstr.get_TickPrice(0, 1, "^")); for (int i = 0; i < data.Length; ++i) if (data.GetValue(i) == null) return; Update update = new Update(); update.Bid = Convert.ToDouble(data.GetValue(0)); update.Ask = Convert.ToDouble(data.GetValue(1)); update.NetPos = Convert.ToInt16(data.GetValue(2)); //convert number of ticks from PL to currency update.PL = tickvalue * Convert.ToDouble(data.GetValue(3)); update.OpenPL = Convert.ToDouble(data.GetValue(4)); update.Symbol = pInstr.Product; if (OnUpdate != null) OnUpdate(this, new UpdateEventArgs(update)); } catch (Exception ex) { if (log.IsErrorEnabled) log.Error(ex.StackTrace); } }
/// <summary> /// This function is called for every fill update. Obtain the fill /// information by calling the Get() properties from the TTFillObj /// passed as an argument. /// </summary> /// <param name="pFillObj">XTAPI Fill Object</param> private void m_TTOrderSet_OnOrderFillData(XTAPI.TTFillObj pFillObj) { // Update the Status Bar text. sbaStatus.Text = "Fill Recieved."; // Retrieve the fill information using the TTFillObj Get Properties. Array fillData = (Array) pFillObj.get_Get("Contract,Price,Qty,FillType,OrderNo,SiteOrderKey"); txtFillData.Text += (string)fillData.GetValue(0) + ", "; txtFillData.Text += (string)fillData.GetValue(1) + ", "; txtFillData.Text += Convert.ToString(fillData.GetValue(2)) + ", "; txtFillData.Text += (string)fillData.GetValue(3) + ", "; txtFillData.Text += (string)fillData.GetValue(4) + ", "; txtFillData.Text += (string)fillData.GetValue(5) + "\r\n"; }
private void register(XTAPI.TTInstrObj pInstr) { quotes_counter +=1; try { Array data = (Array) pInstr.get_Get("Exchange,Product,Contract,Open$,High$,Low$,Last$,Close$,Settle$"); if(quotes_counter%250==0) { Console.Write('.'); } quote(data); } catch (Exception e) { log("Register Error:"+">>"+e.Message); } }
/// <summary> /// This function is called when an instrument is located after calling m_TTInstrObj.Open() /// </summary> /// <param name="pNotify">TTInstrNotify object</param> /// <param name="pInstr">TTInstrObj object</param> private void m_TTInstrNotify_OnNotifyFound(XTAPI.TTInstrNotify pNotify, XTAPI.TTInstrObj pInstr) { // Update the Status Bar text. sbaStatus.Text = "Instrument Found."; // Retrieve the instrument information using the TTInstrObj Get Properties. // // Notes: // 1) The trailing pound sign (#) returns the decimal format for the requested attribute. // 2) The tilde (~) prefix returns the last change, or delta (delta = current - previous), in the attribute. Array data = (Array) pInstr.get_Get("Exchange,Product,ProdType,Contract,Bid#,BidQty$,Ask$,AskQty$,Last$,LastQty$,~LastQty$"); txtExchange.Text = (string)data.GetValue(0); txtProduct.Text = (string)data.GetValue(1); txtProductType.Text = (string)data.GetValue(2); txtContract.Text = (string)data.GetValue(3); // Use Convert methods rather than explicit casting if the expected variant data type is different than the cast. txtBidPrice.Text = Convert.ToString(data.GetValue(4)); txtBidQty.Text = (string)data.GetValue(5); txtAskPrice.Text = (string)data.GetValue(6); txtAskQty.Text = (string)data.GetValue(7); txtLastPrice.Text = (string)data.GetValue(8); txtLastQty.Text = (string)data.GetValue(9); txtLastQtyDelta.Text = (string)data.GetValue(10); }
private void m_TTOrderSet_OnOrderFillData(XTAPI.TTFillObj pFillObj) { // Retrieve the fill information using the TTFillObj Get Properties. Array fillData = (Array) pFillObj.get_Get(fillRequest); Console.Write('*'); FillMessage(fillData); }
private void pNotify_OnNotifyDepthData(XTAPI.TTInstrNotify pNotify, XTAPI.TTInstrObj pInstr) { Array data = (Array) pInstr.get_Get("Exchange,Product,Contract"); string ex = (string)data.GetValue(0); string product = (string)data.GetValue(1); string contract = (string)data.GetValue(2); StringBuilder idBld = new StringBuilder(); idBld.Append(ex+","); idBld.Append(product+","); idBld.Append(contract); String id = idBld.ToString(); // Obtain the bid depth (Level based on user selection). Array dataArrayBid = (Array)pInstr.get_Get("BidDepth(0)#"); // Test if depth exists. if (dataArrayBid != null) { // Iterate through the depth array. for (int i = 0; i <= dataArrayBid.GetUpperBound(0); i++) { // Break out of FOR LOOP if index value is null. if (dataArrayBid.GetValue(i,0) == null) break; String bidDepth = id+",B,"+dataArrayBid.GetValue(i,0); //Console.WriteLine(bidDepth+":::"+dataArrayBid.GetValue(i,1)); depths.Add(bidDepth,dataArrayBid.GetValue(i,1)); } } // Obtain the ask depth (Level based on user selection). Array dataArrayAsk = (Array) pInstr.get_Get("AskDepth(0)#"); // Test if depth exists. if (dataArrayAsk != null) { // Iterate through the depth array. for (int i = 0; i <= dataArrayAsk.GetUpperBound(0); i++) { // Break out of FOR LOOP if index value is null. if (dataArrayAsk.GetValue(i,0) == null) break; String askDepth = id+",A,"+dataArrayAsk.GetValue(i,0); //Console.WriteLine(askDepth+":::"+dataArrayAsk.GetValue(i,1)); depths.Add(askDepth,dataArrayAsk.GetValue(i,1)); } } }
private void m_TTInstrNotify_OnNotifyUpdate(XTAPI.TTInstrNotify pNotify, XTAPI.TTInstrObj pInstr) { register(pInstr); }
/// <summary> /// Publish specific information about each order to the GUI /// </summary> /// <param name="pNewOrderObj">New order object</param> /// <param name="pOldOrderObj">Old order object</param> private void PublishEventOrderData(XTAPI.TTOrderObj pNewOrderObj, XTAPI.TTOrderObj pOldOrderObj) { if (pOldOrderObj.IsNull != 0) { txtStatusOut.Text += "Old Order: NULL\r\n"; } else { try { Array oldOrderData = (Array)pOldOrderObj.get_Get("Contract$,BuySell,OrderQty,Price,OrderNo,ExecutionType"); txtStatusOut.Text += "Old Order: " + oldOrderData.GetValue(0).ToString() + ", " + oldOrderData.GetValue(1).ToString() + ", " + oldOrderData.GetValue(2).ToString() + ", " + oldOrderData.GetValue(3).ToString() + ", " + oldOrderData.GetValue(4).ToString() + ", " + oldOrderData.GetValue(5).ToString() + "\r\n"; } catch (Exception ex) { txtStatusOut.Text += "Old Order: Error Message - " + ex.Message + "\r\n"; } } if (pNewOrderObj.IsNull != 0) { txtStatusOut.Text += "New Order: NULL\r\n"; } else { try { Array newOrderData = (Array)pNewOrderObj.get_Get("Contract$,BuySell,OrderQty,Price,OrderNo,ExecutionType"); txtStatusOut.Text += "New Order: " + newOrderData.GetValue(0).ToString() + ", " + newOrderData.GetValue(1).ToString() + ", " + newOrderData.GetValue(2).ToString() + ", " + newOrderData.GetValue(3).ToString() + ", " + newOrderData.GetValue(4).ToString() + ", " + newOrderData.GetValue(5).ToString() + "\r\n"; } catch (Exception ex) { txtStatusOut.Text += "New Order: Error Message - " + ex.Message + "\r\n"; } } txtStatusOut.Text += "\r\n"; }
/// <summary> /// Triggered when there is a change in the existing orders state. /// </summary> /// <param name="pNewOrderObj">Order obj containing the updated order info</param> /// <param name="pOldOrderObj">Order obj containing the previous order</param> /// <param name="sSiteOrderKey">UID for the order</param> /// <param name="eOrderState">State of the updated order</param> /// <param name="eOrderAction">Action associated with the submitted order</param> /// <param name="updQty">Working qty if the updated order was in a working state</param> /// <param name="sOrderType">Order Type associated with the order</param> /// <param name="sOrderTraits">Traits associated with the order</param> void m_TTOrderSet_OnOrderUpdated(XTAPI.TTOrderObj pNewOrderObj, XTAPI.TTOrderObj pOldOrderObj, string sSiteOrderKey, XTAPI.enumOrderNotifyState eOrderState, XTAPI.enumOrderAction eOrderAction, int updQty, string sOrderType, string sOrderTraits) { txtStatusOut.Text += "Order Updated: " + sSiteOrderKey + "\r\n\r\n"; PublishEventOrderData(pNewOrderObj, pOldOrderObj); }
/// <summary> /// This function is called when an instrument is found after it is opened. /// </summary> /// <param name="pNotify">TTInstrNotify object</param> /// <param name="pInstr">TTInstrObj object</param> private void m_TTInstrNotify_OnNotifyFound(XTAPI.TTInstrNotify pNotify, XTAPI.TTInstrObj pInstr) { // Update the Status Bar text. sbaStatus.Text = "Instrument Found."; // Retrieve the instrument information using the TTInstrObj Get Properties. Array data = (Array) pInstr.get_Get("Exchange,Product,ProdType,Contract"); txtExchange.Text = (string)data.GetValue(0); txtProduct.Text = (string)data.GetValue(1); txtProductType.Text = (string)data.GetValue(2); txtContract.Text = (string)data.GetValue(3); // Obtain the available customer names and add them to the ComboBox. XTAPI.TTOrderProfileClass orderProfile = new XTAPI.TTOrderProfileClass(); foreach (string entry in orderProfile.Customers as Array) { cboCustomer.Items.Add(entry); } // Set the first item in the customer combo boxes. cboCustomer.SelectedIndex = 0; // Set the Net Limits to false. m_TTOrderSet.Set("NetLimits",false); // Open the TTOrderSet with send orders enabled. m_TTOrderSet.Open(1); // Enable the user interface items. btnBuy.Enabled = true; btnSell.Enabled = true; cboCustomer.Enabled = true; gboDeleteOrder.Enabled = true; gboModifyOrder.Enabled = true; }
/// <summary> /// This function is called when an instrument update /// occurs (i.e. last traded price changes). /// </summary> /// <param name="pNotify">TTInstrNotify object</param> /// <param name="pInstr">TTInstrObj object</param> private void m_TTInstrNotify_OnNotifyUpdate(XTAPI.TTInstrNotify pNotify, XTAPI.TTInstrObj pInstr) { // Retrieve the instrument information using the TTInstrObj Get Properties. Array data = (Array) pInstr.get_Get("Bid#,BidQty$,Ask$,AskQty$,Last$,LastQty$,~LastQty$"); txtBidPrice.Text = Convert.ToString(data.GetValue(0)); txtBidQty.Text = (string)data.GetValue(1); txtAskPrice.Text = (string)data.GetValue(2); txtAskQty.Text = (string)data.GetValue(3); txtLastPrice.Text = (string)data.GetValue(4); txtLastQty.Text = (string)data.GetValue(5); txtLastQtyDelta.Text = (string)data.GetValue(6); }
public int Delete(string key , XTAPI.TTOrderSetClass ttorderSet) { XTAPI.TTOrderObj order = (XTAPI.TTOrderObj)ttorderSet.get_SiteKeyLookup(key); int res = order.DeleteOrder(); if (log.IsDebugEnabled) log.Debug( new System.Text.StringBuilder("Deleted: ").AppendFormat("{0} from {1}",res,key) ); return (res); }
/// <summary> /// This function is called for every order update received by the XTAPI. /// /// Note: The TTOrderTrackerObj has been deprecated in favor of the order status /// events, and remains in this sample for legacy code review. /// TT recommends monitoring orders through the events outlined in the /// OrderUpdate example. /// </summary> /// <param name="pOrderSet">TTOrderSetObj object</param> private void m_TTOrderSet_OnOrderSetUpdate(XTAPI.TTOrderSet pOrderSet) { // Obtain the Next TTOrderTrackerObj object from the TTOrderSet. XTAPI.TTOrderTrackerObj tempOrderTrackerObj = pOrderSet.NextOrderTracker; // Iterate through the list of TTOrderTrackerObj objects. while (tempOrderTrackerObj != null) { // Test if an Old Order (past state) exists. if (tempOrderTrackerObj.HasOldOrder != 0) { txtOutput.Text += "Old Order: "; // Obtain the TTOrderObj from the TTOrderTrackerObj. XTAPI.TTOrderObj tempOldOrder = tempOrderTrackerObj.OldOrder; Array tempOrderData = (Array) tempOldOrder.get_Get("Instr.Exchange,Contract$,BuySell,OrderSource"); // Display the information on the interface. for(int i=0; i<tempOrderData.Length; i++) txtOutput.Text += tempOrderData.GetValue(i) + ", "; txtOutput.Text += "\r\n"; } // Test if an New Order (current state) exists. if (tempOrderTrackerObj.HasNewOrder != 0) { txtOutput.Text += "New Order: "; // Obtain the TTOrderObj from the TTOrderTrackerObj. XTAPI.TTOrderObj tempNewOrder = tempOrderTrackerObj.NewOrder; Array tempOrderData = (Array) tempNewOrder.get_Get("Instr.Exchange,Contract$,BuySell,OrderSource"); // Display the information on the interface. for(int i=0; i<tempOrderData.Length; i++) txtOutput.Text += tempOrderData.GetValue(i) + ", "; txtOutput.Text += "\r\n"; } // Obtain the Next TTOrderTrackerObj object from the TTOrderSet. tempOrderTrackerObj = pOrderSet.NextOrderTracker; } }
private void OnOrderFillData(XTAPI.TTFillObj pFill) { try { Fill fill = new Fill(); Array data = (Array)pFill.get_Get("Key,FillType,BuySell,Qty,Price#,NetQty,Acct,Contract.Product"); fill.Key = (string)data.GetValue(0); fill.Full = ((string)data.GetValue(1)).Equals("F"); fill.Buy = ((string)data.GetValue(2)).Equals("B"); fill.Qty = (int)data.GetValue(3); fill.Price = (double)data.GetValue(4); fill.NetQty = (int)data.GetValue(5); fill.Account = (string)data.GetValue(6); fill.Product = (string)data.GetValue(7); if (OnFill != null ) { OnFill(this, new FillEventArgs(fill)); } } catch (Exception ex) { if (log.IsErrorEnabled) log.Error(ex.StackTrace); } }
/// <summary> /// This function is called when an instrument is found after it is opened. /// </summary> /// <param name="pNotify">TTInstrNotify object</param> /// <param name="pInstr">TTInstrObj object</param> private void m_TTInstrNotify_OnNotifyFound(XTAPI.TTInstrNotify pNotify, XTAPI.TTInstrObj pInstr) { // Update the Status Bar text. sbaStatus.Text = "Instrument Found."; }
/// <summary> /// Display the profit and loss and net position for each instrument. /// </summary> /// <param name="pInstr">TTInstrObj object</param> private void DisplayPLInformation(XTAPI.TTInstrObj pInstr) { // Get the P/L and Net Position per instrument. Array data = (Array) pInstr.get_Get("PL$,NetPos"); switch (pInstr.Alias) { case "0": txtPL1.Text = Convert.ToString(data.GetValue(0)); txtNetPosition1.Text = Convert.ToString(data.GetValue(1)); break; case "1": txtPL2.Text = Convert.ToString(data.GetValue(0)); txtNetPosition2.Text = Convert.ToString(data.GetValue(1)); break; case "2": txtPL3.Text = Convert.ToString(data.GetValue(0)); txtNetPosition3.Text = Convert.ToString(data.GetValue(1)); break; case "3": txtPL4.Text = Convert.ToString(data.GetValue(0)); txtNetPosition4.Text = Convert.ToString(data.GetValue(1)); break; default: MessageBox.Show(this,"PL ERROR"); break; } }
/// <summary> /// This function is called when a trade data update occurs. This will only /// fired when DeliverAllPriceUpdates is enabled. /// </summary> /// <param name="pNotify">TTInstrNotify object</param> private void m_TTInstrNotify_OnPriceListUpdate(XTAPI.TTInstrNotify pNotify) { if (pNotify == null) return; double ltp = 0.0f; int ltq = 0; string direction = ""; try { // Loop through each ITTPriceUpdate in the ITTPriceList. The list will contain // all entries which occurred since the last time the OnPriceListUpdate was fired. foreach (XTAPI.ITTPriceUpdate priceUpdate in pNotify.PriceList) { //Loop through PriceEntries in PriceUpdate foreach (XTAPI.ITTPriceEntry priceEntry in priceUpdate) { switch (priceEntry.PriceID) { // Get Last Traded Price case XTAPI.enumPriceID.ttLastTradedPrice: ltp = priceEntry.toDouble(); break; // Get Last Traded Quantity case XTAPI.enumPriceID.ttLastTradedQty: ltq = (int)priceEntry.toDouble(); break; // Get Hit or Take case XTAPI.enumPriceID.ttHitTake: if (priceEntry.toDouble() == Convert.ToDouble(XTAPI.enumTradeIndicator.TRADE_INDICATOR_HIT)) { direction = "Hit"; // Sell } else if (priceEntry.toDouble() == Convert.ToDouble(XTAPI.enumTradeIndicator.TRADE_INDICATOR_TAKE)) { direction = "Take"; // Buy } else if (priceEntry.toDouble() == Convert.ToDouble(XTAPI.enumTradeIndicator.TRADE_INDICATOR_UNKNOWN)) { direction = "Indeterminate"; // Indeterminate } break; default: break; } } // Build message to output string tsMessage = priceUpdate.TimeStamp.Substring(0, 8) + ", " + // removes date, concatinate to timestamp only priceUpdate.Instrument.Exchange + ", " + priceUpdate.Instrument.Product + ", " + priceUpdate.Instrument.get_Get("Expiry") + ", " + direction + ", " + ltp + ", " + ltq; // Add message to ListBox lboPriceList.Items.Add(tsMessage); // Reset data ltp = 0.0f; ltq = 0; direction = ""; } } catch (Exception ex) { // Display exception message. Console.WriteLine(ex.Message, "Exception"); } }
/// <summary> /// This function is called when the TTOrderSet is opened and /// for every order placed by the user. /// </summary> /// <param name="pNotify">TTInstrNotify object</param> /// <param name="pInstr">TTInstrObj object</param> /// <param name="pOrderSet">TTOrderSetObj object</param> private void m_TTInstrNotify_OnOrderSetUpdate(XTAPI.TTInstrNotify pNotify, XTAPI.TTInstrObj pInstr, XTAPI.TTOrderSet pOrderSet) { // Update the P/L text boxes. DisplayPLInformation(pInstr); }
/// <summary> /// This function is called when an instrument is found after it is opened. /// </summary> /// <param name="pNotify">TTInstrNotify object</param> /// <param name="pInstr">TTInstrObj object</param> private void m_TTInstrNotify_OnNotifyFound(XTAPI.TTInstrNotify pNotify, XTAPI.TTInstrObj pInstr) { // Update the Status Bar text. sbaStatus.Text = "Instrument Found."; // Retrieve the instrument information using the TTInstrObj Get Properties. // The use of a tilde before the property name will return the delta (current - previous). Array data = (Array) pInstr.get_Get("Exchange,Product,ProdType,Contract"); txtExchange.Text = (string)data.GetValue(0); txtProduct.Text = (string)data.GetValue(1); txtProductType.Text = (string)data.GetValue(2); txtContract.Text = (string)data.GetValue(3); }
/// <summary> /// Triggered when an order is filled /// </summary> /// <param name="pNewOrderObj">Order obj containing the updated order info</param> /// <param name="pOldOrderObj">Order obj containing the previous order</param> /// <param name="sSiteOrderKey">UID for the order</param> /// <param name="eOrderState">Action associated with the submitted order</param> /// <param name="fillQty">Quantity of the fill.</param> void m_TTOrderSet_OnOrderFilled(XTAPI.TTOrderObj pNewOrderObj, XTAPI.TTOrderObj pOldOrderObj, string sSiteOrderKey, XTAPI.enumOrderNotifyState eOrderState, int fillQty) { PublishEventOrderData("OnOrderFilled", pNewOrderObj, pOldOrderObj); }
/// <summary> /// This function displays is called for every change to the instrument depth. /// </summary> /// <param name="pNotify">TTInstrNotify object</param> /// <param name="pInstr">TTInstrObj object</param> private void pNotify_OnNotifyDepthData(XTAPI.TTInstrNotify pNotify, XTAPI.TTInstrObj pInstr) { // Clear the depth list boxes. lboBidDepth.Items.Clear(); lboAskDepth.Items.Clear(); // Obtain the bid depth (Level based on user selection). Array dataArrayBid = (Array)pInstr.get_Get(m_bidDepthValue); // Test if depth exists. if (dataArrayBid != null) { // Iterate through the depth array. for (int i = 0; i <= dataArrayBid.GetUpperBound(0); i++) { // Break out of FOR LOOP if index value is null. if (dataArrayBid.GetValue(i,0) == null) break; // Update the bid depth list box. lboBidDepth.Items.Add("BidPrice: " + dataArrayBid.GetValue(i,0) + " | " + " BidQty: " + dataArrayBid.GetValue(i,1)); } } // Obtain the ask depth (Level based on user selection). Array dataArrayAsk = (Array) pInstr.get_Get(m_askDepthValue); // Test if depth exists. if (dataArrayAsk != null) { // Iterate through the depth array. for (int i = 0; i <= dataArrayAsk.GetUpperBound(0); i++) { // Break out of FOR LOOP if index value is null. if (dataArrayAsk.GetValue(i,0) == null) break; // Update the bid depth list box. lboAskDepth.Items.Add(" AskPrice: " + dataArrayAsk.GetValue(i,0) + " | " + " AskQty: " + dataArrayAsk.GetValue(i,1)); } } }
/// <summary> /// Triggered when there is a change in the existing orders state. /// </summary> /// <param name="pNewOrderObj">Order obj containing the updated order info</param> /// <param name="pOldOrderObj">Order obj containing the previous order</param> /// <param name="sSiteOrderKey">UID for the order</param> /// <param name="eOrderState">State of the updated order</param> /// <param name="eOrderAction">Action associated with the submitted order</param> /// <param name="updQty">Working qty if the updated order was in a working state</param> /// <param name="sOrderType">Order Type associated with the order</param> /// <param name="sOrderTraits">Traits associated with the order</param> void m_TTOrderSet_OnOrderUpdated(XTAPI.TTOrderObj pNewOrderObj, XTAPI.TTOrderObj pOldOrderObj, string sSiteOrderKey, XTAPI.enumOrderNotifyState eOrderState, XTAPI.enumOrderAction eOrderAction, int updQty, string sOrderType, string sOrderTraits) { PublishEventOrderData("OnOrderUpdated", pNewOrderObj, pOldOrderObj); }
/// <summary> /// This function is called when an instrument update occurs (i.e. LTP changes). /// </summary> /// <param name="pNotify">TTInstrNotify object</param> /// <param name="pInstr">TTInstrObj object</param> private void m_TTInstrNotify_OnNotifyUpdate(XTAPI.TTInstrNotify pNotify, XTAPI.TTInstrObj pInstr) { // Retrieve the instrument information using the TTInstrObj Get Properties. Array data = (Array) pInstr.get_Get("Bid$,Ask$,Last$,Change$"); // Populate the user interface textboxes. txtBidPrice.Text = (string)data.GetValue(0); txtAskPrice.Text = (string)data.GetValue(1); txtLastPrice.Text = (string)data.GetValue(2); txtChange.Text = (string)data.GetValue(3); }
/// <summary> /// This function is called when an instrument is located after calling m_TTInstrObj.Open() /// </summary> /// <param name="pNotify">TTInstrNotify object</param> /// <param name="pInstr">TTInstrObj object</param> private void m_TTInstrNotify_OnNotifyFound(XTAPI.TTInstrNotify pNotify, XTAPI.TTInstrObj pInstr) { // Update the Status Bar text. sbaStatus.Text = "Instrument Found."; // Retrieve the instrument information using the TTInstrObj Get Properties. Array data = (Array)pInstr.get_Get("Exchange,Product,ProdType,Contract"); txtMFoundExchange.Text = (string)data.GetValue(0); txtMFoundProduct.Text = (string)data.GetValue(1); txtMFoundProdType.Text = (string)data.GetValue(2); txtMFoundContract.Text = (string)data.GetValue(3); // Enable the other parts of the "Publish" section for publishing SODs txtPublishPrice.Enabled = true; txtPublishQty.Enabled = true; cboMPublishPriceFormat.Enabled = true; btnCreateManualFill.Enabled = true; optBuy.Enabled = true; optSell.Enabled = true; }
/// <summary> /// Triggered when a TT Gateway receives a hold order /// </summary> /// <param name="pNewOrderObj">Order obj containing the updated order info</param> /// <param name="pOldOrderObj">Order obj containing the previous order</param> /// <param name="sSiteOrderKey">UID for the order</param> /// <param name="eOrderAction">Action associated with the submitted order</param> /// <param name="ordQty">Quantity of the held order.</param> void m_TTOrderSet_OnOrderHeld(XTAPI.TTOrderObj pNewOrderObj, XTAPI.TTOrderObj pOldOrderObj, string sSiteOrderKey, XTAPI.enumOrderAction eOrderAction, int ordQty) { txtStatusOut.Text += "Order Held: " + sSiteOrderKey + "\r\n\r\n"; PublishEventOrderData(pNewOrderObj, pOldOrderObj); }