}// WriteFillToLog() // // // ************************************************************* // **** Create Fill EventArgs() **** // ************************************************************* private FillEventArgs CreateFillEventArg(FillType fillType, TradingTechnologies.TTAPI.Fill ttFill) { int qty = 0; if (ttFill.BuySell == BuySell.Buy) { qty = ttFill.Quantity.ToInt(); // qty > 0 --> buy; } else if (ttFill.BuySell == BuySell.Sell) { qty = -ttFill.Quantity.ToInt(); // qty < 0 --> sell; } Misty.Lib.OrderHubs.Fill aFill = Misty.Lib.OrderHubs.Fill.Create(qty, ttFill.MatchPrice.ToDouble(), Log.GetTime(), ttFill.TransactionDateTime); FillEventArgs e = new FillEventArgs(ttFill.InstrumentKey, fillType, aFill); e.FillKey = ttFill.FillKey; e.AccountID = ttFill.AccountName; return(e); }//CreateFillEventArg()
/// <summary> /// Creates a fill event from the pair-wise info in drop. /// Allowed keys: /// Time - the time the drop was made. /// LocalFillTime - local time fill was received. /// </summary> /// <param name="pairs"></param> /// <returns></returns> private FillEventArgs CreateFillEvent(Dictionary <string, string> pairs) { string sQty; string sPrice; if (pairs.TryGetValue("Qty", out sQty) && pairs.TryGetValue("Price", out sPrice)) { Misty.Lib.OrderHubs.Fill aFill = Misty.Lib.OrderHubs.Fill.Create(); aFill.Qty = Convert.ToInt32(sQty); aFill.Price = Convert.ToDouble(sPrice); // Extract fill times. if (pairs.ContainsKey("LocalFillTime")) { aFill.LocalTime = Convert.ToDateTime(pairs["LocalFillTime"]); // use fill time, if available. } else { aFill.LocalTime = Convert.ToDateTime(pairs["Time"]); // else use last drop time- legacy approach } // Extract TT's instrument key. InstrumentKey key; string sForeignKey; if (pairs.TryGetValue("ForeignKey", out sForeignKey) && TTConvert.TryCreateInstrumentKey(sForeignKey, out key)) { FillEventArgs e = new FillEventArgs(key, FillType.InitialPosition, aFill); return(e); // success! } else { Log.NewEntry(LogLevel.Error, "Failed to recreate instrument key from {0}.", sForeignKey); return(null); } } else { Log.NewEntry(LogLevel.Error, "Failed to create a fill event"); return(null); } }// CreateFillEvent()
public void SetAttributes(Dictionary <string, string> attributes) { this.Fill = new Misty.Lib.OrderHubs.Fill(); ((IStringifiable)this.Fill).SetAttributes(attributes); FillType type; TradingTechnologies.TTAPI.InstrumentKey ttInstrumentKey; foreach (string key in attributes.Keys) { if (key == "Type" && Enum.TryParse <FillType>(attributes[key], out type)) { this.Type = type; } else if (key == "InstrumentKey" && TTConvert.TryCreateInstrumentKey(attributes[key], out ttInstrumentKey)) { this.TTInstrumentKey = ttInstrumentKey; } else if (key == "FillKey") { this.FillKey = attributes[key]; } } }
// // // // // #endregion//Public Methods #region Private Methods // ***************************************************************** // **** Private Methods **** // ***************************************************************** // // private void CreatePropertyInventory(Misty.Lib.OrderHubs.Fill fill) { FindNewProperties(fill); // Automatically collect all Property names. //if (fill.FillDetails != null) // FindNewProperties(fill.FillDetails); }// CreatePropertyInventory()
}//SetConfirmMode() // #endregion//Private Methods #region Event Handlers // ***************************************************************** // **** Event Handlers **** // ***************************************************************** // // private void buttonSubmitFill_Click(object sender, EventArgs e) { if (m_IsConfirmMode) { // The user has confirmed to send this. // Read numbers again bool isGoodToSendOrder = true; int qty = 0; if (!Int32.TryParse(textBoxQty.Text, out qty)) { isGoodToSendOrder = false; } double price = 0; if (!Double.TryParse(textBoxPrice.Text, out price)) { isGoodToSendOrder = false; } if (isGoodToSendOrder) { // Submit fill now Misty.Lib.OrderHubs.Fill aFill = Misty.Lib.OrderHubs.Fill.Create(); aFill.Price = price; aFill.Qty = qty; aFill.LocalTime = Log.GetTime(); /* * //Misty.Lib.Products.InstrumentBase instrBase = null; * TradingTechnologies.TTAPI.InstrumentDetails details; * if (m_CurrentInstrument != m_EmptyInstrument && m_Market.TryGetInstrumentDetails(m_CurrentInstrument, out details) && details != null && details.Key != null) * { // TODO: Somewhere around here a null exception was thrown. * if ( Log != null) * Log.NewEntry(Misty.Lib.Hubs.LogLevel.Major, "FormAddFills.SubmitFill_Click: Submitting fill request {0} or ForeignKey is null", m_CurrentInstrument); * TradingTechnologies.TTAPI.InstrumentKey instrKey = (TradingTechnologies.TTAPI.InstrumentKey)details.Key; * Ambre.TTServices.Fills.FillEventArgs fillEventArgs = new Ambre.TTServices.Fills.FillEventArgs(instrKey, Ambre.TTServices.Fills.FillType.UserAdjustment, aFill); * m_FillHub.HubEventEnqueue(fillEventArgs); * } * else if (Log != null) * Log.NewEntry(Misty.Lib.Hubs.LogLevel.Warning, "FormAddFills.SubmitFill_Click: Failed {0} or ForeignKey is null", m_CurrentInstrument); */ TradingTechnologies.TTAPI.InstrumentKey instrumentKey; if (m_CurrentInstrument != m_EmptyInstrument && m_FillHub.TryGetInstrumentKey(m_CurrentInstrument, out instrumentKey)) { // TODO: Somewhere around here a null exception was thrown. if (Log != null) { Log.NewEntry(Misty.Lib.Hubs.LogLevel.Major, "FormAddFills.SubmitFill_Click: Submitting fill request {0}.", m_CurrentInstrument); } Ambre.TTServices.Fills.FillEventArgs fillEventArgs = new Ambre.TTServices.Fills.FillEventArgs(instrumentKey, Ambre.TTServices.Fills.FillType.UserAdjustment, aFill); m_FillHub.HubEventEnqueue(fillEventArgs); } else if (Log != null) { Log.NewEntry(Misty.Lib.Hubs.LogLevel.Warning, "FormAddFills.SubmitFill_Click: Failed {0} or ForeignKey is null", m_CurrentInstrument); } // REset the colors textBoxQty.Text = string.Empty; // protection against user's adding fill twice. SetConfirmMode(buttonSubmitFill, false, 0); // reset colors and text on button } } else { bool isGood = true; int qty = 0; if (Int32.TryParse(textBoxQty.Text, out qty)) { textBoxQty.Text = string.Format("{0:+0;-0;0}", qty); } else { textBoxQty.Text = "0"; isGood = false; } double price = 0; if (Double.TryParse(textBoxPrice.Text, out price)) { textBoxPrice.Text = string.Format("{0}", price); } else { textBoxPrice.Text = ""; isGood = false; } // Set SetConfirmMode(buttonSubmitFill, isGood, qty); // set colors to "confirm" mode. } }
public FillEventArgs(TradingTechnologies.TTAPI.InstrumentKey ttKey, FillType fillType, Misty.Lib.OrderHubs.Fill theFill) { this.TTInstrumentKey = ttKey; this.Type = fillType; this.Fill = theFill; }